Diffstat (limited to 'gammu/emb/common/phone/nokia/dct3/n7110.c') (more/less context) (show whitespace changes)
-rw-r--r-- | gammu/emb/common/phone/nokia/dct3/n7110.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c index 5a02c9c..b597f9b 100644 --- a/gammu/emb/common/phone/nokia/dct3/n7110.c +++ b/gammu/emb/common/phone/nokia/dct3/n7110.c @@ -1,98 +1,101 @@ /* (c) 2001-2004 by Marcin Wiacek */ -/* based on some work from Markus Plail and Gnokii */ +/* based on some Markus Plail work from Gnokii (www.gnokii.org) + * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot + * GNU GPL version 2 or later + */ #include "../../../gsmstate.h" #ifdef GSM_ENABLE_NOKIA7110 #include <string.h> #include <time.h> #include "../../../misc/coding/coding.h" #include "../../../gsmcomon.h" #include "../../../service/gsmlogo.h" #include "../../pfunc.h" #include "../nfunc.h" #include "../nfuncold.h" #include "n7110.h" #include "dct3func.h" static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) { return DCT3_GetAlarm(s, alarm, 0x19); } static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) { return DCT3_SetAlarm(s, alarm, 0x19); } static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Phonebook entry received\n"); switch (msg.Buffer[6]) { case 0x0f: return N71_65_ReplyGetMemoryError(msg.Buffer[10], s); default: return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false); } return ERR_UNKNOWN; } static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) { unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 0x02, /* memory type */ 0x05, 0x00, 0x00, /* location */ 0x00, 0x00}; req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[9]==0xff) return ERR_NOTSUPPORTED; if (entry->Location==0x00) return ERR_INVALIDLOCATION; req[10] = entry->Location / 256; req[11] = entry->Location % 256; s->Phone.Data.Memory=entry; smprintf(s, "Getting phonebook entry\n"); return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory); } static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Memory status received\n"); /* Quess ;-)) */ if (msg.Buffer[10]==0x10) { Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15]; } else { Data->MemoryStatus->MemoryFree = msg.Buffer[18]; } smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree); Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17]; smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed); Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed; smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree); return ERR_NONE; } static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) { unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 0x05}; /* Memory type */ req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES); if (req[5]==0xff) return ERR_NOTSUPPORTED; s->Phone.Data.MemoryStatus=Status; smprintf(s, "Getting memory status\n"); return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus); } static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location) { @@ -433,192 +436,193 @@ static GSM_Error N7110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessag error=N7110_GetSMSFolders(s,&Priv->LastSMSFolders); if (error!=ERR_NONE) return error; } else { N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location); for (i=0;i<Priv->LastSMSFolder.Number;i++) { if (Priv->LastSMSFolder.Location[i]==location) break; } /* Is this last location in this folder ? */ if (i==Priv->LastSMSFolder.Number-1) { findnextfolder=true; } else { location=Priv->LastSMSFolder.Location[i+1]; } } if (findnextfolder) { Priv->LastSMSFolder.Number=0; while (Priv->LastSMSFolder.Number==0) { folderid=folderid+0x08; /* Too high folder number */ if ((folderid/0x08)>Priv->LastSMSFolders.Number) return ERR_EMPTY; /* Get next folder status */ error=N7110_GetSMSFolderStatus(s, folderid); if (error!=ERR_NONE) return error; /* First location from this folder */ location=Priv->LastSMSFolder.Location[0]; } } N7110_SetSMSLocation(s, &sms->SMS[0], folderid, location); return N7110_PrivGetSMSMessage(s, sms); } static int N7110_ReturnBinaryRingtoneLocation(char *model) { if (strcmp(model,"NSE-5") == 0) return 0x72; /* first 0x72 - 7110 */ if (strcmp(model,"NPE-3") == 0) return 0x89; /* first 0x89 - 6210 */ if (strcmp(model,"NHM-3") == 0) return 0x89; /* quess for 6250 */ return 0; } static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) { int tmp,i; GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Ringtone received\n"); switch (msg.Buffer[3]) { case 0x23: tmp=0;i=4; while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) { tmp++; i=i+2; if (i>msg.Length) return ERR_EMPTY; } memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2); smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); /* Looking for end */ i=37; while (true) { if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { i=i+2; break; } if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) { i=i+2; break; } i++; if (i==msg.Length) return ERR_EMPTY; } /* Copying frame */ memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37); Data->Ringtone->NokiaBinary.Length=i-37; return ERR_NONE; case 0x24: smprintf(s, "Invalid location. Too high ?\n"); return ERR_INVALIDLOCATION; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) { unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00}; if (PhoneRingtone) return ERR_NOTSUPPORTED; if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY; switch (Ringtone->Format) { case RING_NOTETONE: /* In the future get binary and convert */ return ERR_NOTSUPPORTED; case RING_NOKIABINARY: req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location; s->Phone.Data.Ringtone=Ringtone; smprintf(s, "Getting binary ringtone\n"); return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone); case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } return ERR_NOTSUPPORTED; } static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { int i; GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110; smprintf(s, "Received info for Picture Images\n"); smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]); smprintf(s, "Locations :"); Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5]; for (i=0;i<Priv->LastPictureImageFolder.Number;i++) { Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2]; smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]); } smprintf(s, "\n"); return ERR_NONE; } static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location) { GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110; GSM_SMSFolders folders; GSM_Error error; int i, j = 0, count = 0; unsigned char req[] = {N6110_FRAME_HEADER, 0x96, 0x00, /* Folder ID */ 0x0f, 0x07}; error=N7110_GetSMSFolders (s, &folders); if (error!=ERR_NONE) return error; for (i=0;i<folders.Number;i++) { req[4] = (i+1) * 0x08; /* SMS folder ID */ error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap); if (error!=ERR_NONE) return error; for (j=0;j<Priv->LastPictureImageFolder.Number;j++) { count++; if (count==Bitmap->Location) break; } if (count==Bitmap->Location) break; } if (count!=Bitmap->Location) return ERR_INVALIDLOCATION; *folder = (i+1) * 0x08; /* SMS Folder ID */ *location = Priv->LastPictureImageFolder.Location[j]; return ERR_NONE; } static GSM_Error N7110_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap) { unsigned char folder; int location; GSM_Error error; unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x00, /* Folder ID */ 0x00, 0x00, /* Location */ 0x00, 0x64}; error = N7110_GetPictureImageLocation(s, Bitmap, &folder, &location); switch (error) { case ERR_NONE: req[4] = folder; req[5] = location / 256; req[6] = location % 256; return GSM_WaitFor (s, req, 9, 0x14, 4, ID_GetBitmap); default: return error; } } static GSM_Error N7110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) { GSM_MemoryEntry pbk; GSM_Error error; unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70}; s->Phone.Data.Bitmap=Bitmap; switch (Bitmap->Type) { case GSM_StartupLogo: smprintf(s, "Getting startup logo\n"); return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15); case GSM_WelcomeNote_Text: smprintf(s, "Getting welcome note\n"); return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02); case GSM_DealerNote_Text: smprintf(s, "Getting dealer note\n"); return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x17); case GSM_CallerGroupLogo: pbk.MemoryType = MEM7110_CG; pbk.Location = Bitmap->Location; smprintf(s, "Getting caller group logo\n"); error=N7110_GetMemory(s,&pbk); if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s,Bitmap); @@ -1554,171 +1558,172 @@ static GSM_Reply_Function N7110ReplyFunctions[] = { {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet }, {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet }, {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet }, {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet }, {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet }, {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet }, {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet }, {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile }, {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile }, {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity }, {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings }, {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI }, {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice }, {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall }, {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall }, {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor }, {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone }, {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware }, {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM }, {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode }, {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth }, {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI }, {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap }, {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap }, {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey }, {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey }, {NULL, "\x00",0x00,0x00,ID_None } }; GSM_Phone_Functions N7110Phone = { "6210|6250|7110|7190", N7110ReplyFunctions, N7110_Initialise, PHONE_Terminate, GSM_DispatchMessage, NOTSUPPORTED, /* ShowStartInfo */ NOKIA_GetManufacturer, DCT3DCT4_GetModel, DCT3DCT4_GetFirmware, DCT3_GetIMEI, DCT3_GetOriginalIMEI, DCT3_GetManufactureMonth, DCT3_GetProductCode, DCT3_GetHardware, DCT3_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N71_92_GetDateTime, N71_92_SetDateTime, N7110_GetAlarm, N7110_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ DCT3_PressKey, DCT3_Reset, N61_71_ResetPhoneSettings, NOTSUPPORTED, /* EnterSecurityCode */ NOTSUPPORTED, /* GetSecurityStatus */ NOTSUPPORTED, /* GetDisplayStatus */ NOTIMPLEMENTED, /* SetAutoNetworkLogin */ N71_92_GetBatteryCharge, N71_92_GetSignalQuality, DCT3_GetNetworkInfo, NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ N7110_GetMemoryStatus, N7110_GetMemory, NOTIMPLEMENTED, /* GetNextMemory */ N7110_SetMemory, NOTIMPLEMENTED, /* AddMemory */ N7110_DeleteMemory, NOTIMPLEMENTED, /* DeleteAllMemory */ N7110_GetSpeedDial, NOTIMPLEMENTED, /* SetSpeedDial */ DCT3_GetSMSC, DCT3_SetSMSC, N7110_GetSMSStatus, N7110_GetSMSMessage, N7110_GetNextSMSMessage, N7110_SetSMS, N7110_AddSMS, N7110_DeleteSMS, DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ N7110_SetIncomingSMS, DCT3_SetIncomingCB, N7110_GetSMSFolders, NOTIMPLEMENTED, /* AddSMSFolder */ NOTIMPLEMENTED, /* DeleteSMSFolder */ DCT3_DialVoice, N7110_AnswerCall, DCT3_CancelCall, NOTIMPLEMENTED, /* HoldCall */ NOTIMPLEMENTED, /* UnholdCall */ NOTIMPLEMENTED, /* ConferenceCall */ NOTIMPLEMENTED, /* SplitCall */ NOTIMPLEMENTED, /* TransferCall */ NOTIMPLEMENTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ N7110_SetCallDivert, N7110_CancelAllDiverts, N7110_SetIncomingCall, N7110_SetIncomingUSSD, DCT3DCT4_SendDTMF, N7110_GetRingtone, N7110_SetRingtone, NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ DCT3_PlayTone, DCT3_GetWAPBookmark, DCT3_SetWAPBookmark, DCT3_DeleteWAPBookmark, DCT3_GetWAPSettings, DCT3_SetWAPSettings, NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ N7110_GetBitmap, N7110_SetBitmap, NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ N7110_GetCalendarStatus, NOTIMPLEMENTED, /* GetCalendar */ N7110_GetNextCalendar, NOTIMPLEMENTED, /* SetCalendar */ N7110_AddCalendar, N71_65_DelCalendar, NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ N7110_GetProfile, N7110_SetProfile, NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ NOTSUPPORTED, /* GetNextFileFolder */ NOTSUPPORTED, /* GetFilePart */ NOTSUPPORTED, /* AddFile */ NOTSUPPORTED, /* GetFileSystemStatus */ NOTSUPPORTED, /* DeleteFile */ NOTSUPPORTED, /* AddFolder */ NOTSUPPORTED, /* GetGPRSAccessPoint */ NOTSUPPORTED /* SetGPRSAccessPoint */ }; #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ |