Visit our new site E2Mod.com - The source for all your Motorola ROKR E2 modding needs

 
Home arrow Patches arrow P2KApi 2.9
P2KApi 2.9
Thursday, 29 March 2007

Dynamically linked library for Motorola P2K phones
Copyright Vilko :)

Download HERE

Functions:

P2K_SendCMD (DWORD Cmd, void* SendBuff, DWORD SendSize, void* RecvBuff,
DWORD* RecvSize);
this function only for advanced users

File_ListEx(ptr Buffer, dword Count,ProgressFuncPtr)
First parameter as in File_List
ProgressFuncPtr - pointer to function:
void __stdcall TestFunc(FILELIST* fl, int CurIndex, int TotalCount)
fl - pointer to FILELIST structures File_listEx
CurIndex - index of last file name
TotalCount - count of records
Example:
void __stdcall TestFunc(FILELIST* fl, int CurIndex, int TotalCount)
{
  if (!TotalCount) return;
  float f = ((float)CurIndex/TotalCount) * 100;
  Log(clBlack,"p2kapi.GetFileListEx: completed %2.0f%% - %s",f,fl[CurIndex].FileName);
}
...
// somewhere, when we want to get filelist
int FileCount = p2k->GetFileCountEx("/a/*");
FILELIST *fl = new FILELIST[FileCount];
p2k->GetFileListEx(FileList,FileCount,TestFunc);

 

Mode_SwitchToP2k(StatusProc)
  Switch phone from AT mode to P2K
  if not called P2K_Init, it's will be called with StatusProc parameter
  (no return value)
 
Mode_SwitchToAT()
  Switch phone from P2K mode to AT
  (no return value)


P2K_Init(StatusProc);
     Library initialization, phone status monitor starting.
     StatusProc - pointer to a procedure, that will be called on phone detect/disconect (or 0, if procedure call is not needing).
     Returns 0 on initialization success or 1 on failure.

     Library calls StatusProc procedure with one parameter:
     1 - if phone detected; 0 - if phone not detected.


P2K_Restart();
     Restart a phone.

P2K_Suspend();
     Switch phone to suspended mode

P2K_GetStatus();
     Gets connection status.
     Returns 0 if phone not found or 1 if phone found.

File_CreateDir(lpstr FileName, byte Attribute);
     Creates new directory

     lpstr DirName - pointer to string containing a directory name
     byte Attribute - new attribute for a created dir
       Attribute is combination of 3 bits:
       bit0 - readonly
       bit1 - hidden
       bit2 - system
     Returns always 0.

File_DeleteDir(lpstr DirName);
     Deleting a directory

     lpstr FileName - pointer to a string containing directory name

     Returns 0 if success or -1 on error.


File_Create(lpstr FileName, byte Attribute);
     Creates new or opens existing file

     lpstr FileName - pointer to string containing a file name (in case of nested filesystem - full path with directories)
     byte Attribute - new attribute for a created/opened file
       Attribute is combination of 3 bits:
       bit0 - readonly
       bit1 - hidden
       bit2 - system

     Phone not allows to open more than 1 file simultaneously.
     Returns 0 if opening was success or -1 on error.
     (advanced error codes - :) please wait for next version)

File_Close();
     Closes previously opened file.
     Returns 0 if closing was success or -1 on error.

File_Read(ptr Buffer, dword Size);
     Reading data from file.
     Reads data from BOF or from position, what was setted by File_SetPointer function.

     ptr Buffer - pointer to a buffer for receiving data from a file.
     dword Size - data size to read. Buffer size couldn't be less then this size.

     Returns 0 if reading was success or -1 on error.

File_Write(ptr Buffer, dword Size);
     Writing data to a file.
     Writes data from BOF or from position, what was setted by File_SetPointer function.

     ptr Buffer - pointer to a buffer containing data to write.
     dword Size - data size to write.

     Returns 0 if writing was success or -1 on error.

      ATTENTION! This function not checks a free space for writing.
      But phone needs for a some free space for temporary files created by phone.

File_SetPointer(dword Offset, byte MoveMethod);
     Set pointer to file reading/writing

     dword Offset - new position of pointer
     byte MoveMethod - pointer setting method:
      0 - offset from BOF
      1 - offset from current position of pointer
      2 - offset from EOF

     Returns 0 if success or -1 on error.

File_Delete(lpstr FileName);
     Deleting a file

     lpstr FileName - pointer to a string containing file name (in case of nested filesystem - full path with directories) to delete.

     Returns 0 if success or -1 on error.

File_VolInfo(ptr Buffer);
     Receiving an information about free space and volume name.

     ptr Buffer - pointer to a buffer for volume name receiving (must be >= 128 bytes)

     Returns free space size in bytes or -1 on error.

File_GetFreeSpace(lpstr disk)
     Receiving an information about free space     
     lpstr disk - name of idsk ("/c/")

File_CountEx(lpstr disk_and_mask);
     Receiving an information about files count in phone.
     Returns files count or -1 on error.
     lpstr disk_and_mask) - pointer to disk name and mask ("/c/*.mp3").

File_Count();
     Receiving an information about files count in phone.

     Returns files count or -1 on error.

File_List(ptr Buffer, word Count);
     Receiving a file list from phone. File_Count() function must be called directly before this function.

     ptr Buffer - pointer to a buffer for files list receiving
       files list is saved as:
       dd file size
       dw attribute 1
       dw attribute 2
       string of 1F8h length - file name.
       Record size per 1 file is 200h bytes
       Records count is equivalent to files count in phone (result of File_Count() function)
       According to this, size of buffer for files list must be File_Count*200h

     word Count - files count to read (result of File_Count() function)

     Returns a maximum length of file name for current phone model or -1 on error..


Seem_Read(word SeemNo, word RecordNo,word StartOffset,word Bytes, ptr Data);
     Reading of seem cell

     SeemNo - Seem cell number
     RecordNo - Seem record number
     StartOffset - Offset for seem reading from (0 - from cell beginning)
     Bytes - Bytes count for reading (0 - read from beginning to end)
     ptr Data - pointer to a buffer for receiving seem cell data
     If "Bytes" parameter not specified, then buffer length must be >= 2710h bytes

     Returns count of readed bytes or -1 on error.

Seem_Write(word SeemNo, word RecordNo, word StartOffset, word Bytes, ptr Data);
     Writing seem cell

     SeemNo - Seem cell number
     RecordNo - Seem record number
     StartOffset - Offset for seem writing from (0 - from cell beginning)
     Bytes - Bytes count for writing (0 - write from beginning to end)
     ptr Data - pointer to a buffer containing seem cell data for writing

     Returns 0 if writing was success or -1 on error.

Last Updated ( Thursday, 29 March 2007 )
 
< Prev   Next >
© 2005 – 2024 Motorola E398 Modders