21 files changed, 1071 insertions, 167 deletions
diff --git a/gammu/emb/common/phone/alcatel/alcatel.c b/gammu/emb/common/phone/alcatel/alcatel.c index f004ad4..3821f13 100644 --- a/gammu/emb/common/phone/alcatel/alcatel.c +++ b/gammu/emb/common/phone/alcatel/alcatel.c @@ -56,96 +56,97 @@ /* We need lot of ATGEN functions, because Alcatel is an AT device. */ extern GSM_Reply_Function ALCATELReplyFunctions[]; extern GSM_Reply_Function ATGENReplyFunctions[]; extern GSM_Error ATGEN_Initialise (GSM_StateMachine *s); extern GSM_Error ATGEN_Terminate (GSM_StateMachine *s); extern GSM_Error ATGEN_GetIMEI (GSM_StateMachine *s); extern GSM_Error ATGEN_GetFirmware (GSM_StateMachine *s); extern GSM_Error ATGEN_GetModel (GSM_StateMachine *s); extern GSM_Error ATGEN_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); extern GSM_Error ATGEN_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); extern GSM_Error ATGEN_GetNextMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, bool start); extern GSM_Error ATGEN_SetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); extern GSM_Error ATGEN_AddMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); extern GSM_Error ATGEN_DeleteMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry); extern GSM_Error ATGEN_GetMemoryStatus (GSM_StateMachine *s, GSM_MemoryStatus *Status); extern GSM_Error ATGEN_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); extern GSM_Error ATGEN_SetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc); extern GSM_Error ATGEN_GetSMSFolders (GSM_StateMachine *s, GSM_SMSFolders *folders); extern GSM_Error ATGEN_GetSMSStatus (GSM_StateMachine *s, GSM_SMSMemoryStatus *status); extern GSM_Error ATGEN_GetSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms); extern GSM_Error ATGEN_GetNextSMS (GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start); extern GSM_Error ATGEN_SendSavedSMS (GSM_StateMachine *s, int Folder, int Location); extern GSM_Error ATGEN_SendSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); extern GSM_Error ATGEN_DeleteSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); extern GSM_Error ATGEN_AddSMS (GSM_StateMachine *s, GSM_SMSMessage *sms); extern GSM_Error ATGEN_GetBatteryCharge (GSM_StateMachine *s, GSM_BatteryCharge *bat); extern GSM_Error ATGEN_GetSignalQuality (GSM_StateMachine *s, GSM_SignalQuality *sig); extern GSM_Error ATGEN_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); extern GSM_Error ATGEN_AnswerCall (GSM_StateMachine *s, int ID, bool all); extern GSM_Error ATGEN_CancelCall (GSM_StateMachine *s, int ID, bool all); extern GSM_Error ATGEN_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time); extern GSM_Error ATGEN_EnterSecurityCode (GSM_StateMachine *s, GSM_SecurityCode Code); extern GSM_Error ATGEN_GetSecurityStatus (GSM_StateMachine *s, GSM_SecurityCodeType *Status); extern GSM_Error ATGEN_ResetPhoneSettings (GSM_StateMachine *s, GSM_ResetSettingsType Type); extern GSM_Error ATGEN_SendDTMF (GSM_StateMachine *s, char *sequence); extern GSM_Error ATGEN_GetSIMIMSI (GSM_StateMachine *s, char *IMSI); extern GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *s); extern GSM_Error ATGEN_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo); extern GSM_Error ATGEN_Reset (GSM_StateMachine *s, bool hard); extern GSM_Error ATGEN_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); extern GSM_Error ATGEN_GetDisplayStatus (GSM_StateMachine *s, GSM_DisplayFeatures *features); extern GSM_Error ATGEN_SetAutoNetworkLogin (GSM_StateMachine *s); extern GSM_Error ATGEN_DeleteAllMemory (GSM_StateMachine *s, GSM_MemoryType type); extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); +extern GSM_Error ATGEN_SetFastSMSSending (GSM_StateMachine *s, bool enable); extern GSM_Error ATGEN_SetIncomingCB (GSM_StateMachine *s, bool enable); extern GSM_Error ATGEN_SetIncomingSMS (GSM_StateMachine *s, bool enable); /** * Alcatel uses some 8-bit characters in contacts, calendar etc.. This table * attempts to decode it, it is probably not complete, here are just chars * that I found... */ unsigned char GSM_AlcatelAlphabet[] = { /* in phone unicode description */ 0x80, 0x00,0x20, /* empty */ 0x81, 0x00,0x20, /* empty */ 0x82, 0x00,0x20, /* empty */ 0x83, 0x00,0x20, /* empty */ 0x84, 0x00,0xe7, /* c cedilla */ 0x85, 0x20,0x26, /* ... */ 0x86, 0x03,0xc0, /* pi */ 0x87, 0x01,0x3e, /* l caron */ 0x88, 0x00,0xc0, /* A grave */ 0x89, 0x00,0xc1, /* A acute */ 0x8a, 0x00,0xc2, /* A circumflex */ 0x8b, 0x00,0xc3, /* A tilde */ 0x8c, 0x00,0xc8, /* E grave */ 0x8d, 0x00,0xca, /* E circumflex */ 0x8e, 0x00,0xcb, /* E diaresis */ 0x8f, 0x00,0xcc, /* I grave */ 0x90, 0x00,0xcd, /* I acute */ 0x91, 0x00,0xd0, /* ETH */ 0x92, 0x00,0xd2, /* O grave */ 0x93, 0x00,0xd3, /* O acute */ 0x94, 0x00,0xd4, /* O circumflex */ 0x95, 0x00,0xd5, /* O tilde */ 0x96, 0x00,0xd9, /* U grave */ 0x97, 0x00,0xda, /* U acute */ 0x98, 0x00,0xe1, /* a acute */ 0x99, 0x00,0xe2, /* a circumflex */ 0x9a, 0x00,0xe3, /* a tilde */ 0x9b, 0x00,0xea, /* e circumflex */ 0x9c, 0x00,0xeb, /* e diaresis */ 0x9d, 0x00,0xed, /* i acute */ 0x9e, 0x00,0xee, /* i circumflex */ 0x9f, 0x00,0xef, /* i diaresis */ 0xa0, 0x00,0xf3, /* o acute */ 0xa1, 0x00,0xf4, /* o circumflex */ 0xa2, 0x00,0xf5, /* o tilde */ 0xa3, 0x00,0xfa, /* u acute */ @@ -499,96 +500,98 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary smprintf(s,"Start session\n"); error=GSM_WaitFor (s, start_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelStart); if (error != ERR_NONE) return error; smprintf(s,"Select type\n"); error=GSM_WaitFor (s, select1_buffer, 4, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect1); if (error != ERR_NONE) return error; error=GSM_WaitFor (s, select2_buffer, 6, 0x02, ALCATEL_TIMEOUT, ID_AlcatelSelect2); if (error != ERR_NONE) return error; error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelSelect3); if (error != ERR_NONE) return error; smprintf(s,"Begin transfer\n"); error=GSM_WaitFor (s, begin_buffer, 8, 0x02, ALCATEL_TIMEOUT, ID_AlcatelBegin1); if (error != ERR_NONE) return error; error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelBegin2); if (error != ERR_NONE) return error; Priv->BinaryState = StateSession; Priv->BinaryType = type; /* Do we want to edit something of same type? */ if ((state == StateEdit) && (type == Priv->BinaryType)) { Priv->BinaryState = StateEdit; Priv->BinaryItem = item; return ERR_NONE; } } return ERR_NONE; } static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) { GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; GSM_Error error; if (Priv->Mode == ModeAT) return ERR_NONE; error = ALCATEL_GoToBinaryState(s, StateAttached, 0, 0); if (error != ERR_NONE) return error; error = s->Protocol.Functions->Terminate(s); if (error != ERR_NONE) return error; dbgprintf ("Changing protocol to AT\n"); s->Protocol.Functions = &ATProtocol; s->Phone.Functions->ReplyFunctions = ATGENReplyFunctions; Priv->Mode = ModeAT; + s->Phone.Data.Priv.ATGEN.PBKCharset = 0; + s->Phone.Data.Priv.ATGEN.PBKMemory = 0; my_sleep(100); /* In case we don't send AT command short after closing binary mode, * phone takes VERY long to react next time. The error code in * intetionally ignored. */ GSM_WaitFor (s, "AT\r", 3, 0x00, 0, ID_IncomingFrame); return ERR_NONE; } static GSM_Error ALCATEL_Initialise(GSM_StateMachine *s) { GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; GSM_Error error; Priv->Mode = ModeAT; Priv->CalendarItems = NULL; Priv->ContactsItems = NULL; Priv->ToDoItems = NULL; Priv->CalendarItemsCount = 0; Priv->ToDoItemsCount = 0; Priv->ContactsItemsCount = 0; Priv->CurrentFields[0] = 0; Priv->CurrentFieldsCount = 0; Priv->CurrentFieldsItem = 0; Priv->CurrentFieldsType = 0; Priv->ProtocolVersion = V_1_0; Priv->CurrentFieldsItem = -1; Priv->CurrentCategoriesCount = 0; Priv->CurrentCategoriesType = 0; s->Protocol.Functions = &ATProtocol; s->Phone.Functions->ReplyFunctions = ATGENReplyFunctions; if (ATGEN_Initialise(s) != ERR_NONE || GSM_WaitFor (s, "AT\r", 3, 0x00, 2, ID_IncomingFrame) != ERR_NONE) { smprintf(s,"AT initialisation failed, trying to stop binary mode...\n"); s->Protocol.Functions = &ALCABUSProtocol; error = s->Protocol.Functions->Terminate(s); s->Protocol.Functions = &ATProtocol; error = ATGEN_Initialise(s); if (error != ERR_NONE) return error; } @@ -3777,215 +3780,224 @@ static GSM_Error ALCATEL_ReplyGeneric(GSM_Protocol_Message msg, GSM_StateMachine * - phone needs PIN code * - we want to close not opened session * For normal users the second case shouldn't occur... */ return ERR_SECURITYERROR; case 0x14: /* Bad data */ case 0x2f: /* Closing session when not opened */ case 0x1f: /* Bad in/out counter in packet/ack */ case 0x0e: /* Openning session when not closed */ case 0x0C: /* Bad id (item/database) */ case 0x11: /* Bad list id */ case 0x2A: /* Nonexistant field/item id */ case 0x35: /* Too long text */ return ERR_BUG; case 0x23: /* Session opened */ case 0x80: /* Transfer started */ return ERR_NONE; case 0x82: /* Transfer canceled */ return ERR_CANCELED; default: smprintf(s, "WARNING: Packet seems to indicate some status by %02X, ignoring!\n", msg.Buffer[8]); return ERR_NONE; } } static GSM_Error ALCATEL_ReplyCommit(GSM_Protocol_Message msg, GSM_StateMachine *s) { s->Phone.Data.Priv.ALCATEL.CommitedRecord = msg.Buffer[12] + (msg.Buffer[11] << 8) + (msg.Buffer[10] << 16) + (msg.Buffer[9] << 24); smprintf(s, "Created record %08x\n", s->Phone.Data.Priv.ALCATEL.CommitedRecord); return ERR_NONE; } static GSM_Error ALCATEL_SetIncomingCB (GSM_StateMachine *s, bool enable) { GSM_Error error; if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; return ATGEN_SetIncomingCB(s, enable); } static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) { GSM_Error error; if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; return ATGEN_SetIncomingSMS(s, enable); } +static GSM_Error ALCATEL_SetFastSMSSending(GSM_StateMachine *s, bool enable) +{ + GSM_Error error; + + if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; + return ATGEN_SetFastSMSSending(s, enable); +} + static GSM_Reply_Function ALCATELReplyFunctions[] = { {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAttach }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDetach }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCommit }, {ALCATEL_ReplyCommit, "\x02",0x00,0x00, ID_AlcatelCommit2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelEnd }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelClose }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelStart }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect1 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelSelect3 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin1 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelBegin2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetIds1 }, {ALCATEL_ReplyGetIds, "\x02",0x00,0x00, ID_AlcatelGetIds2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategories1 }, {ALCATEL_ReplyGetCategories, "\x02",0x00,0x00, ID_AlcatelGetCategories2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetCategoryText1 }, {ALCATEL_ReplyGetCategoryText, "\x02",0x00,0x00, ID_AlcatelGetCategoryText2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelAddCategoryText1 }, {ALCATEL_ReplyAddCategoryText, "\x02",0x00,0x00, ID_AlcatelAddCategoryText2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFields1 }, {ALCATEL_ReplyGetFields, "\x02",0x00,0x00, ID_AlcatelGetFields2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelGetFieldValue1 }, {ALCATEL_ReplyGetFieldValue, "\x02",0x00,0x00, ID_AlcatelGetFieldValue2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteField }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelDeleteItem1 }, {ALCATEL_ReplyDeleteItem, "\x02",0x00,0x00, ID_AlcatelDeleteItem2 }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelCreateField }, {ALCATEL_ReplyGeneric, "\x02",0x00,0x00, ID_AlcatelUpdateField }, {NULL, "\x00",0x00,0x00, ID_None } }; GSM_Phone_Functions ALCATELPhone = { /* AFAIK, any 50[0123] phone should work, but I'm not sure whether all * they were ever really released, if yes add them here also. */ "alcatel|OT501|OT701|OT715|OT535|OT735|BE5|BF5|BH4", ALCATELReplyFunctions, ALCATEL_Initialise, ALCATEL_Terminate, ALCATEL_DispatchMessage, NOTSUPPORTED, /* ShowStartInfo */ ALCATEL_GetManufacturer, ALCATEL_GetModel, ALCATEL_GetFirmware, ALCATEL_GetIMEI, NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ ALCATEL_GetProductCode, NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ ALCATEL_GetSIMIMSI, ALCATEL_GetDateTime, ALCATEL_SetDateTime, ALCATEL_GetAlarm, ALCATEL_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ ALCATEL_PressKey, ALCATEL_Reset, ALCATEL_ResetPhoneSettings, ALCATEL_EnterSecurityCode, ALCATEL_GetSecurityStatus, ALCATEL_GetDisplayStatus, ALCATEL_SetAutoNetworkLogin, ALCATEL_GetBatteryCharge, ALCATEL_GetSignalStrength, ALCATEL_GetNetworkInfo, ALCATEL_GetCategory, ALCATEL_AddCategory, ALCATEL_GetCategoryStatus, ALCATEL_GetMemoryStatus, ALCATEL_GetMemory, ALCATEL_GetNextMemory, ALCATEL_SetMemory, ALCATEL_AddMemory, ALCATEL_DeleteMemory, ALCATEL_DeleteAllMemory, NOTSUPPORTED, /* GetSpeedDial */ NOTSUPPORTED, /* SetSpeedDial */ ALCATEL_GetSMSC, ALCATEL_SetSMSC, ALCATEL_GetSMSStatus, ALCATEL_GetSMS, ALCATEL_GetNextSMS, NOTSUPPORTED, /* SetSMS */ ALCATEL_AddSMS, ALCATEL_DeleteSMS, ALCATEL_SendSMS, ALCATEL_SendSavedSMS, + ALCATEL_SetFastSMSSending, ALCATEL_SetIncomingSMS, ALCATEL_SetIncomingCB, ALCATEL_GetSMSFolders, NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ ALCATEL_DialVoice, ALCATEL_AnswerCall, ALCATEL_CancelCall, NOTSUPPORTED, /* HoldCall */ NOTSUPPORTED, /* UnholdCall */ NOTSUPPORTED, /* ConferenceCall */ NOTSUPPORTED, /* SplitCall */ NOTSUPPORTED, /* TransferCall */ NOTSUPPORTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NONEFUNCTION, /* SetIncomingCall */ NOTSUPPORTED, /* SetIncomingUSSD */ ALCATEL_SendDTMF, NOTSUPPORTED, /* GetRingtone */ NOTSUPPORTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ NOTSUPPORTED, /* GetBitmap */ NOTSUPPORTED, /* SetBitmap */ ALCATEL_GetToDoStatus, ALCATEL_GetToDo, ALCATEL_GetNextToDo, ALCATEL_SetToDo, ALCATEL_AddToDo, ALCATEL_DeleteToDo, ALCATEL_DeleteAllToDo, ALCATEL_GetCalendarStatus, ALCATEL_GetCalendar, ALCATEL_GetNextCalendar, ALCATEL_SetCalendar, ALCATEL_AddCalendar, ALCATEL_DeleteCalendar, ALCATEL_DeleteAllCalendar, NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ NOTSUPPORTED, /* GetNextFileFolder */ NOTSUPPORTED, /* GetFilePart */ NOTSUPPORTED, /* AddFilePart */ NOTSUPPORTED, /* GetFileSystemStatus */ NOTSUPPORTED, /* DeleteFile */ NOTSUPPORTED, /* AddFolder */ NOTSUPPORTED, /* GetGPRSAccessPoint */ NOTSUPPORTED /* SetGPRSAccessPoint */ }; #endif #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/at/atgen.c b/gammu/emb/common/phone/at/atgen.c index 1834f15..ba23eb2 100644 --- a/gammu/emb/common/phone/at/atgen.c +++ b/gammu/emb/common/phone/at/atgen.c @@ -1,93 +1,73 @@ /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ #include "../../gsmstate.h" #ifdef GSM_ENABLE_ATGEN #include <string.h> #include <time.h> #include <ctype.h> #include "../../gsmcomon.h" #include "../../misc/coding/coding.h" #include "../../service/sms/gsmsms.h" #include "../pfunc.h" + #include "atgen.h" +#include "samsung.h" +#include "siemens.h" +#include "sonyeric.h" + #ifdef GSM_ENABLE_ALCATEL -extern GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message msg, GSM_StateMachine *s); +GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *); #endif -extern GSM_Error ATGEN_CMS35ReplyGetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplySetBitmap (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplyGetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplySetRingtone (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplyGetNextCal (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplySetCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar (GSM_Protocol_Message msg, GSM_StateMachine *s); -extern GSM_Error ATGEN_SL45ReplyGetMemory (GSM_Protocol_Message msg, GSM_StateMachine *s); - -extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone); -extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength); -extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap); -extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap); -extern GSM_Error SIEMENS_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start); -extern GSM_Error SIEMENS_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note); -extern GSM_Error SIEMENS_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note); - -extern GSM_Error SONYERIC_GetNextCalendar (GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start); -extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start); -extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status); -extern GSM_Error SONYERIC_AddCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note); -extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo); -extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s); -extern GSM_Error SONYERIC_DelCalendarNote (GSM_StateMachine *s, GSM_CalendarEntry *Note); -extern GSM_Error SONYERIC_GetCalendarStatus (GSM_StateMachine *s, GSM_CalendarStatus *Status); typedef struct { int Number; char Text[60]; } ATErrorCode; static ATErrorCode CMSErrorCodes[] = { /* * Error codes not specified here were either undefined or reserved in my * copy of specifications, if you have newer one, please fill in the gaps. */ /* 0...127 from GSM 04.11 Annex E-2 */ {1, "Unassigned (unallocated) number"}, {8, "Operator determined barring"}, {10, "Call barred"}, {21, "Short message transfer rejected"}, {27, "Destination out of service"}, {28, "Unidentified subscriber"}, {29, "Facility rejected"}, {30, "Unknown subscriber"}, {38, "Network out of order"}, {41, "Temporary failure"}, {42, "Congestion"}, {47, "Resources unavailable, unspecified"}, {50, "Requested facility not subscribed"}, {69, "Requested facility not implemented"}, {81, "Invalid short message transfer reference value"}, {95, "Invalid message, unspecified"}, {96, "Invalid mandatory information"}, {97, "Message type non-existent or not implemented"}, {98, "Message not compatible with short message protocol state"}, {99, "Information element non-existent or not implemented"}, {111, "Protocol error, unspecified"}, {127, "Interworking, unspecified"}, /* 128...255 from GSM 03.40 subclause 9.2.3.22 */ {0x80, "Telematic interworking not supported"}, {0x81, "Short message Type 0 not supported"}, {0x82, "Cannot replace short message"}, {0x8F, "Unspecified TP-PID error"}, {0x90, "Data coding scheme (alphabet) not supported"}, {0x91, "Message class not supported"}, {0x9F, "Unspecified TP-DCS error"}, {0xA0, "Command cannot be actioned"}, {0xA1, "Command unsupported"}, {0xAF, "Unspecified TP-Command error"}, {0xB0, "TPDU not supported"}, {0xC0, "SC busy"}, {0xC1, "No SC subscription"}, @@ -130,402 +110,467 @@ static ATErrorCode CMSErrorCodes[] = { /* > 512 are manufacturer specific according to GSM 07.05 subclause 3.2.5 */ {-1, ""} }; static ATErrorCode CMEErrorCodes[] = { /* CME Error codes from GSM 07.07 section 9.2 */ {0, "phone failure"}, {1, "no connection to phone"}, {2, "phone-adaptor link reserved"}, {3, "operation not allowed"}, {4, "operation not supported"}, {5, "PH-SIM PIN required"}, {10, "SIM not inserted"}, {11, "SIM PIN required"}, {12, "SIM PUK required"}, {13, "SIM failure"}, {14, "SIM busy"}, {15, "SIM wrong"}, {16, "incorrect password"}, {17, "SIM PIN2 required"}, {18, "SIM PUK2 required"}, {20, "memory full"}, {21, "invalid index"}, {22, "not found"}, {23, "memory failure"}, {24, "text string too long"}, {25, "invalid characters in text string"}, {26, "dial string too long"}, {27, "invalid characters in dial string"}, {30, "no network service"}, {31, "network timeout"}, {100, "unknown"}, }; GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->ErrorCode == 0) { smprintf(s, "CME Error occured, but it's type not detected\n"); } else if (Priv->ErrorText == NULL) { smprintf(s, "CME Error %i, no description available\n", Priv->ErrorCode); } else { smprintf(s, "CME Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText); } /* For error codes descriptions see table a bit above */ switch (Priv->ErrorCode) { + case -1: + return ERR_EMPTY; case 3: return ERR_PERMISSION; case 4: return ERR_NOTSUPPORTED; case 5: case 11: case 12: case 16: case 17: case 18: return ERR_SECURITYERROR; case 20: return ERR_FULL; case 21: return ERR_INVALIDLOCATION; case 22: return ERR_EMPTY; case 23: return ERR_MEMORY; case 24: case 25: case 26: case 27: return ERR_INVALIDDATA; default: return ERR_UNKNOWN; } } GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->ErrorCode == 0) { smprintf(s, "CMS Error occured, but it's type not detected\n"); } else if (Priv->ErrorText == NULL) { smprintf(s, "CMS Error %i, no description available\n", Priv->ErrorCode); } else { smprintf(s, "CMS Error %i: \"%s\"\n", Priv->ErrorCode, Priv->ErrorText); } /* For error codes descriptions see table a bit above */ switch (Priv->ErrorCode) { case 304: return ERR_NOTSUPPORTED; case 305: return ERR_BUG; case 311: case 312: case 316: case 317: case 318: return ERR_SECURITYERROR; case 322: return ERR_FULL; case 321: return ERR_INVALIDLOCATION; default: return ERR_UNKNOWN; } } /* FIXME: Function doesn't respect quoting of parameters and thus +FOO: * "ab","cd,ef" will consider as three arguments: "ab" >> "cd >> ef" */ int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output) { int position=0; while (*input!=',' && *input!=0x0d && *input!=0x00) { *output=*input; input ++; output ++; position++; } *output=0; position++; return position; } void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input) { - dt->Year=2000+(*input-'0')*10; input++; + /* Samsung phones report year as %d instead of %02d */ + if (input[2] == '/') { + dt->Year=(*input-'0')*10; + input++; + } else { + dt->Year=0; + } + dt->Year=dt->Year+(*input-'0'); input++; + dt->Year+=2000; input++; dt->Month=(*input-'0')*10; input++; dt->Month=dt->Month+(*input-'0'); input++; input++; dt->Day=(*input-'0')*10; input++; dt->Day=dt->Day+(*input-'0'); input++; input++; dt->Hour=(*input-'0')*10; input++; dt->Hour=dt->Hour+(*input-'0'); input++; input++; dt->Minute=(*input-'0')*10; input++; dt->Minute=dt->Minute+(*input-'0');input++; input++; dt->Second=(*input-'0')*10; input++; dt->Second=dt->Second+(*input-'0');input++; if (input!=NULL) { input++; dt->Timezone=(*input-'0')*10; input++; dt->Timezone=dt->Timezone+(*input-'0');input++; input=input-2; if (*input=='-') dt->Timezone=-dt->Timezone; } } GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Protocol_Message *msg = s->Phone.Data.RequestMsg; int i = 0, j, k; char *err, *line; ATErrorCode *ErrorCodes = NULL; SplitLines(msg->Buffer, msg->Length, &Priv->Lines, "\x0D\x0A", 2, true); /* Find number of lines */ while (Priv->Lines.numbers[i*2+1] != 0) { /* FIXME: handle special chars correctly */ smprintf(s, "%i \"%s\"\n",i+1,GetLineString(msg->Buffer,Priv->Lines,i+1)); i++; } Priv->ReplyState = AT_Reply_Unknown; Priv->ErrorText = NULL; Priv->ErrorCode = 0; line = GetLineString(msg->Buffer,Priv->Lines,i); if (!strcmp(line,"OK")) Priv->ReplyState = AT_Reply_OK; if (!strcmp(line,"> ")) Priv->ReplyState = AT_Reply_SMSEdit; if (!strcmp(line,"CONNECT")) Priv->ReplyState = AT_Reply_Connect; if (!strcmp(line,"ERROR" )) Priv->ReplyState = AT_Reply_Error; if (!strncmp(line,"+CME ERROR:",11)) { Priv->ReplyState = AT_Reply_CMEError; ErrorCodes = CMEErrorCodes; } if (!strncmp(line,"+CMS ERROR:",11)) { Priv->ReplyState = AT_Reply_CMSError; ErrorCodes = CMSErrorCodes; } + + /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */ + if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) { + err = line + 11; + Priv->ErrorCode = atoi(err); + + if (Priv->ErrorCode == -1) { + Priv->ErrorText = "[Samsung] Empty location"; + return GSM_DispatchMessage(s); + } + } + if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) { j = 0; /* One char behind +CM[SE] ERROR */ err = line + 12; while (err[j] && !isalnum(err[j])) j++; if (isdigit(err[j])) { Priv->ErrorCode = atoi(&(err[j])); k = 0; while (ErrorCodes[k].Number != -1) { if (ErrorCodes[k].Number == Priv->ErrorCode) { Priv->ErrorText = (char *)&(ErrorCodes[k].Text); break; } k++; } } else if (isalpha(err[j])) { k = 0; while (ErrorCodes[k].Number != -1) { if (!strncmp(err + j, ErrorCodes[k].Text, strlen(ErrorCodes[k].Text))) { Priv->ErrorCode = ErrorCodes[k].Number; Priv->ErrorText = (char *)&(ErrorCodes[k].Text); break; } k++; } } } return GSM_DispatchMessage(s); } GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (s->Phone.Data.Priv.ATGEN.ReplyState) { case AT_Reply_OK: case AT_Reply_Connect: return ERR_NONE; case AT_Reply_Error: return ERR_UNKNOWN; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); case AT_Reply_CMEError: return ATGEN_HandleCMEError(s); default: break; } return ERR_UNKNOWNRESPONSE; } +GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + unsigned char buffer[2000],buffer2[4000]; + int i = 10; + + /* Ugly hack */ + while (msg.Buffer[i]!=13) i++; + i = i - 6; + memcpy(buffer,msg.Buffer+10,i-11); + buffer[i-11] = 0x00; + + smprintf(s, "USSD reply: \"%s\"\n",buffer); + + if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) { + EncodeUnicode(buffer2,buffer,strlen(buffer)); + s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2); + } + + return ERR_NONE; +} + +GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable) +{ + GSM_Error error; + + if (enable) { + smprintf(s, "Enabling incoming USSD\n"); + error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD); + } else { + smprintf(s, "Disabling incoming USSD\n"); + error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD); + } + if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable; + return error; +} + GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Phone_Data *Data = &s->Phone.Data; if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_NOTSUPPORTED; if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MODEL_LENGTH) { CopyLineString(Data->Model, msg.Buffer, Priv->Lines, 2); /* Sometimes phone adds this before manufacturer (Sagem) */ if (strncmp("+CGMM: ", Data->Model, 7) == 0) { memmove(Data->Model, Data->Model + 7, strlen(Data->Model + 7) + 1); } Data->ModelInfo = GetModelData(NULL,Data->Model,NULL); if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(NULL,NULL,Data->Model); if (Data->ModelInfo->number[0] == 0) Data->ModelInfo = GetModelData(Data->Model,NULL,NULL); if (Data->ModelInfo->number[0] != 0) strcpy(Data->Model,Data->ModelInfo->number); if (strstr(msg.Buffer,"Nokia")) Priv->Manufacturer = AT_Nokia; else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens; else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens; + else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens; else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP; if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20"); else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35"); + else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35"); else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ"); } else { smprintf(s, "WARNING: Model name too long, increase MAX_MODEL_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); } return ERR_NONE; } GSM_Error ATGEN_GetModel(GSM_StateMachine *s) { GSM_Error error; if (s->Phone.Data.Model[0] != 0) return ERR_NONE; smprintf(s, "Getting model\n"); error=GSM_WaitFor (s, "AT+CGMM\r", 8, 0x00, 3, ID_GetModel); if (error==ERR_NONE) { if (s->di.dl==DL_TEXT || s->di.dl==DL_TEXTALL || s->di.dl==DL_TEXTDATE || s->di.dl==DL_TEXTALLDATE) { smprintf(s, "[Connected model - \"%s\"]\n",s->Phone.Data.Model); } } return error; } GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; switch (Priv->ReplyState) { case AT_Reply_OK: smprintf(s, "Manufacturer info received\n"); Priv->Manufacturer = AT_Unknown; if (strlen(GetLineString(msg.Buffer, Priv->Lines, 2)) <= MAX_MANUFACTURER_LENGTH) { CopyLineString(s->Phone.Data.Manufacturer, msg.Buffer, Priv->Lines, 2); } else { smprintf(s, "WARNING: Manufacturer name too long, increase MAX_MANUFACTURER_LENGTH to at least %zd\n", strlen(GetLineString(msg.Buffer, Priv->Lines, 2))); s->Phone.Data.Manufacturer[0] = 0; } /* Sometimes phone adds this before manufacturer (Sagem) */ if (strncmp("+CGMI: ", s->Phone.Data.Manufacturer, 7) == 0) { memmove(s->Phone.Data.Manufacturer, s->Phone.Data.Manufacturer + 7, strlen(s->Phone.Data.Manufacturer + 7) + 1); } if (strstr(msg.Buffer,"Falcom")) { smprintf(s, "Falcom\n"); strcpy(s->Phone.Data.Manufacturer,"Falcom"); Priv->Manufacturer = AT_Falcom; if (strstr(msg.Buffer,"A2D")) { strcpy(s->Phone.Data.Model,"A2D"); s->Phone.Data.ModelInfo = GetModelData(NULL,s->Phone.Data.Model,NULL); smprintf(s, "Model A2D\n"); } } if (strstr(msg.Buffer,"Nokia")) { smprintf(s, "Nokia\n"); strcpy(s->Phone.Data.Manufacturer,"Nokia"); Priv->Manufacturer = AT_Nokia; } if (strstr(msg.Buffer,"SIEMENS")) { smprintf(s, "Siemens\n"); strcpy(s->Phone.Data.Manufacturer,"Siemens"); Priv->Manufacturer = AT_Siemens; } if (strstr(msg.Buffer,"ERICSSON")) { smprintf(s, "Ericsson\n"); strcpy(s->Phone.Data.Manufacturer,"Ericsson"); Priv->Manufacturer = AT_Ericsson; } if (strstr(msg.Buffer,"iPAQ")) { smprintf(s, "iPAQ\n"); strcpy(s->Phone.Data.Manufacturer,"HP"); Priv->Manufacturer = AT_HP; } if (strstr(msg.Buffer,"ALCATEL")) { smprintf(s, "Alcatel\n"); strcpy(s->Phone.Data.Manufacturer,"Alcatel"); Priv->Manufacturer = AT_Alcatel; } if (strstr(msg.Buffer,"SAGEM")) { smprintf(s, "Sagem\n"); strcpy(s->Phone.Data.Manufacturer,"Sagem"); Priv->Manufacturer = AT_Sagem; } + if (strstr(msg.Buffer,"Samsung")) { + smprintf(s, "Samsung\n"); + strcpy(s->Phone.Data.Manufacturer,"Samsung"); + Priv->Manufacturer = AT_Samsung; + } return ERR_NONE; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: break; } return ERR_UNKNOWNRESPONSE; } GSM_Error ATGEN_GetManufacturer(GSM_StateMachine *s) { if (s->Phone.Data.Manufacturer[0] != 0) return ERR_NONE; return GSM_WaitFor (s, "AT+CGMI\r", 8, 0x00, 4, ID_GetManufacturer); } GSM_Error ATGEN_ReplyGetFirmwareCGMR(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; unsigned int i = 0; strcpy(s->Phone.Data.Version,"unknown"); s->Phone.Data.VerNum = 0; if (Priv->ReplyState == AT_Reply_OK) { CopyLineString(s->Phone.Data.Version, msg.Buffer, Priv->Lines, 2); /* Sometimes phone adds this before manufacturer (Sagem) */ if (strncmp("+CGMR: ", s->Phone.Data.Version, 7) == 0) { memmove(s->Phone.Data.Version, s->Phone.Data.Version + 7, strlen(s->Phone.Data.Version + 7) + 1); } } if (Priv->Manufacturer == AT_Ericsson) { while (1) { if (s->Phone.Data.Version[i] == 0x20) { s->Phone.Data.Version[i] = 0x00; break; } if (i == strlen(s->Phone.Data.Version)) break; i++; } } smprintf(s, "Received firmware version: \"%s\"\n",s->Phone.Data.Version); GSM_CreateFirmwareNumber(s); return ERR_NONE; } GSM_Error ATGEN_ReplyGetFirmwareATI(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; @@ -629,106 +674,116 @@ GSM_Error ATGEN_Initialise(GSM_StateMachine *s) if (error != ERR_NONE) return error; smprintf(s, "Enabling CME errors\n"); /* Try numeric errors */ if (GSM_WaitFor (s, "AT+CMEE=1\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { /* Try textual errors */ if (GSM_WaitFor (s, "AT+CMEE=2\r", 10, 0x00, 3, ID_EnableErrorInfo) != ERR_NONE) { smprintf(s, "CME errors could not be enabled, some error types won't be detected.\n"); } } error = ATGEN_GetModel(s); if (error != ERR_NONE) return error; if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_SLOWWRITE)) { s->Protocol.Data.AT.FastWrite = true; } return error; } GSM_Error ATGEN_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) { unsigned char req[50]; if (smsc->Location!=1) return ERR_NOTSUPPORTED; sprintf(req, "AT+CSCA=\"%s\"\r",DecodeUnicodeString(smsc->Number)); smprintf(s, "Setting SMSC\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetSMSC); } GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (s->Phone.Data.Priv.ATGEN.ReplyState) { case AT_Reply_OK: /* Reply here is: * (memories for reading)[, (memories for writing)[, (memories for storing received messages)]] * each memory is in quotes, * Example: ("SM"), ("SM"), ("SM") * * We need to get from this supported memories. For this case * we assume, that just appearence of memory makes it * available for everything. Then we need to find out whether * phone supports writing to memory. This is done by searching * for "), (", which will appear between lists. */ - s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL); + s->Phone.Data.Priv.ATGEN.CanSaveSMS = false; + if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) { + s->Phone.Data.Priv.ATGEN.CanSaveSMS = true; + } + if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE; else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE; + if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE; else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE; - smprintf(s, "Available SMS memories received, ME = %d, SM = %d\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); + + smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); + if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true"); + smprintf(s, "\n"); return ERR_NONE; case AT_Reply_Error: case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); + case AT_Reply_CMEError: + return ATGEN_HandleCMEError(s); default: return ERR_UNKNOWNRESPONSE; } } GSM_Error ATGEN_GetSMSMemories(GSM_StateMachine *s) { smprintf(s, "Getting available SMS memories\n"); return GSM_WaitFor (s, "AT+CPMS=?\r", 10, 0x00, 4, ID_GetSMSMemories); } GSM_Error ATGEN_SetSMSMemory(GSM_StateMachine *s, bool SIM) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; char req[] = "AT+CPMS=\"XX\",\"XX\"\r"; int reqlen = 18; GSM_Error error; if ((SIM && Priv->SIMSMSMemory == 0) || (!SIM && Priv->PhoneSMSMemory == 0)) { /* We silently ignore error here, because when this fails, we can try to setmemory anyway */ ATGEN_GetSMSMemories(s); } /* If phone can not save SMS, don't try to set memory for saving */ if (!Priv->CanSaveSMS) { req[12] = '\r'; reqlen = 13; } if (SIM) { if (Priv->SMSMemory == MEM_SM) return ERR_NONE; if (Priv->SIMSMSMemory == AT_NOTAVAILABLE) return ERR_NOTSUPPORTED; req[9] = 'S'; req[10] = 'M'; req[14] = 'S'; req[15] = 'M'; smprintf(s, "Setting SMS memory type to SM\n"); error=GSM_WaitFor (s, req, reqlen, 0x00, 3, ID_SetMemoryType); if (Priv->SIMSMSMemory == 0 && error == ERR_NONE) { Priv->SIMSMSMemory = AT_AVAILABLE; } if (error == ERR_NOTSUPPORTED) { smprintf(s, "Can't access SIM card?\n"); return ERR_SECURITYERROR; } if (error != ERR_NONE) return error; Priv->SMSMemory = MEM_SM; } else { @@ -813,188 +868,189 @@ GSM_Error ATGEN_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigne } smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n", sms->Folder,sms->Location,*folderid,*location); if (Priv->SIMSMSMemory == AT_AVAILABLE && *folderid == 1) { return ATGEN_SetSMSMemory(s, true); } else { return ATGEN_SetSMSMemory(s, false); } } void ATGEN_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location) { sms->Folder = 0; sms->Location = (folderid - 1) * PHONE_MAXSMSINFOLDER + location; smprintf(s, "ATGEN folder %i & location %i -> SMS folder %i & location %i\n", folderid,location,sms->Folder,sms->Location); } GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_SMSMessage *sms = &s->Phone.Data.GetSMSMessage->SMS[0]; int current = 0, current2, i; unsigned char buffer[300],smsframe[800]; unsigned char firstbyte, TPDCS, TPUDL, TPStatus; GSM_Error error; switch (Priv->ReplyState) { case AT_Reply_OK: if (Priv->Lines.numbers[4] == 0x00) return ERR_EMPTY; s->Phone.Data.GetSMSMessage->Number = 1; s->Phone.Data.GetSMSMessage->SMS[0].Name[0] = 0; s->Phone.Data.GetSMSMessage->SMS[0].Name[1] = 0; switch (Priv->SMSMode) { case SMS_AT_PDU: CopyLineString(buffer, msg.Buffer, Priv->Lines, 2); switch (buffer[7]) { case '0': sms->State = SMS_UnRead; break; case '1': sms->State = SMS_Read; break; case '2': sms->State = SMS_UnSent; break; default : sms->State = SMS_Sent; break;//case '3' } DecodeHexBin (buffer, GetLineString(msg.Buffer,Priv->Lines,3), strlen(GetLineString(msg.Buffer,Priv->Lines,3))); /* Siemens MC35 (only ?) */ if (strstr(msg.Buffer,"+CMGR: 0,,0")!=NULL) return ERR_EMPTY; /* Siemens M20 */ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { - if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL && - buffer[1]!=NUMBER_ALPHANUMERIC) { + /* we check for the most often visible */ + if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN && + buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { /* Seems to be Delivery Report */ smprintf(s, "SMS type - status report (M20 style)\n"); sms->PDU = SMS_Status_Report; sms->Folder = 1; /*INBOX SIM*/ sms->InboxFolder = true; smsframe[12]=buffer[current++]; smsframe[PHONE_SMSStatusReport.TPMR]=buffer[current++]; current2=((buffer[current])+1)/2+1; for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; smsframe[0] = 0; for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); return ERR_NONE; } } /* We use locations from SMS layouts like in ../phone2.c(h) */ for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; smsframe[12]=buffer[current++]; /* See GSM 03.40 section 9.2.3.1 */ switch (smsframe[12] & 0x03) { case 0x00: smprintf(s, "SMS type - deliver\n"); sms->PDU = SMS_Deliver; if (Priv->SMSMemory == MEM_SM) { sms->Folder = 1; /*INBOX SIM*/ } else { sms->Folder = 3; /*INBOX ME*/ } sms->InboxFolder = true; current2=((buffer[current])+1)/2+1; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { - if (buffer[current+1]==NUMBER_ALPHANUMERIC) { + if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { smprintf(s, "Trying to read alphanumeric number\n"); for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; current+=6; for(i=0;i<current2-3;i++) smsframe[PHONE_SMSDeliver.Number+i+4]=buffer[current++]; } else { for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; } } else { for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; } smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSDeliver); return ERR_NONE; case 0x01: smprintf(s, "SMS type - submit\n"); sms->PDU = SMS_Submit; if (Priv->SMSMemory == MEM_SM) { sms->Folder = 2; /*OUTBOX SIM*/ smprintf(s, "Outbox SIM\n"); } else { sms->Folder = 4; /*OUTBOX ME*/ } sms->InboxFolder = false; smsframe[PHONE_SMSSubmit.TPMR] = buffer[current++]; current2=((buffer[current])+1)/2+1; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { - if (buffer[current+1]==NUMBER_ALPHANUMERIC) { + if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) { smprintf(s, "Trying to read alphanumeric number\n"); for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; current+=6; for(i=0;i<current2-3;i++) smsframe[PHONE_SMSSubmit.Number+i+4]=buffer[current++]; } else { for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; } } else { for(i=0;i<current2+1;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; } smsframe[PHONE_SMSSubmit.TPPID] = buffer[current++]; smsframe[PHONE_SMSSubmit.TPDCS] = buffer[current++]; /* See GSM 03.40 9.2.3.3 - TPVP can not exist in frame */ if ((smsframe[12] & 0x18)!=0) current++; //TPVP is ignored now smsframe[PHONE_SMSSubmit.TPUDL] = buffer[current++]; for(i=0;i<smsframe[PHONE_SMSSubmit.TPUDL];i++) smsframe[i+PHONE_SMSSubmit.Text]=buffer[current++]; GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSSubmit); return ERR_NONE; case 0x02: smprintf(s, "SMS type - status report\n"); sms->PDU = SMS_Status_Report; sms->Folder = 1; /*INBOX SIM*/ sms->InboxFolder = true; - smprintf(s, "TPMR is %02x\n",buffer[current]); + smprintf(s, "TPMR is %d\n",buffer[current]); smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++]; current2=((buffer[current])+1)/2+1; for(i=0;i<current2+1;i++) smsframe[PHONE_SMSStatusReport.Number+i]=buffer[current++]; for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.DateTime+i]=buffer[current++]; for(i=0;i<7;i++) smsframe[PHONE_SMSStatusReport.SMSCTime+i]=buffer[current++]; smsframe[PHONE_SMSStatusReport.TPStatus]=buffer[current]; GSM_DecodeSMSFrame(sms,smsframe,PHONE_SMSStatusReport); return ERR_NONE; } break; case SMS_AT_TXT: current = 0; while (msg.Buffer[current]!='"') current++; current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); if (!strcmp(buffer,"\"0\"") || !strcmp(buffer,"\"REC UNREAD\"")) { smprintf(s, "SMS type - deliver\n"); sms->State = SMS_UnRead; sms->PDU = SMS_Deliver; if (Priv->SMSMemory == MEM_SM) { sms->Folder = 1; /*INBOX SIM*/ } else { sms->Folder = 3; /*INBOX ME*/ } sms->InboxFolder = true; } else if (!strcmp(buffer,"\"1\"") || !strcmp(buffer,"\"REC READ\"")) { smprintf(s, "SMS type - deliver\n"); sms->State = SMS_Read; sms->PDU = SMS_Deliver; if (Priv->SMSMemory == MEM_SM) { sms->Folder = 1; /*INBOX SIM*/ } else { sms->Folder = 3; /*INBOX ME*/ } sms->InboxFolder = true; } else if (!strcmp(buffer,"\"2\"") || !strcmp(buffer,"\"STO UNSENT\"")) { smprintf(s, "SMS type - submit\n"); sms->State = SMS_UnSent; sms->PDU = SMS_Submit; if (Priv->SMSMemory == MEM_SM) { sms->Folder = 2; /*OUTBOX SIM*/ } else { sms->Folder = 4; /*OUTBOX ME*/ } sms->InboxFolder = false; } else if (!strcmp(buffer,"\"3\"") || !strcmp(buffer,"\"STO SENT\"")) { smprintf(s, "SMS type - submit\n"); sms->State = SMS_Sent; sms->PDU = SMS_Submit; @@ -1595,107 +1651,107 @@ GSM_Error ATGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) } } s->Protocol.Data.AT.EditMode = true; Replies = s->ReplyNum; s->ReplyNum = 1; smprintf(s,"Waiting for modem prompt\n"); error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_SaveSMSMessage); s->ReplyNum = Replies; if (error == ERR_NONE) { Phone->DispatchError = ERR_TIMEOUT; Phone->RequestID = ID_SaveSMSMessage; smprintf(s, "Saving SMS\n"); error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00); if (error!=ERR_NONE) return error; my_sleep(500); /* CTRL+Z ends entering */ error = s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); if (error!=ERR_NONE) return error; error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); if (error != ERR_TIMEOUT) return error; } else { smprintf(s, "Escaping SMS mode\n"); error2 = s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); if (error2 != ERR_NONE) return error2; return error; } } return Phone->DispatchError; } GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; char *start; if (s->Protocol.Data.AT.EditMode) { if (s->Phone.Data.Priv.ATGEN.ReplyState != AT_Reply_SMSEdit) { return ERR_UNKNOWN; } s->Protocol.Data.AT.EditMode = false; return ERR_NONE; } switch (Priv->ReplyState) { case AT_Reply_OK: smprintf(s, "SMS sent OK\n"); if (s->User.SendSMSStatus!=NULL) { - start = strstr(msg.Buffer, "+CMGW: "); + start = strstr(msg.Buffer, "+CMGS: "); if (start != NULL) { s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7)); } else { - s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); + s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1); } } return ERR_NONE; case AT_Reply_CMSError: smprintf(s, "Error %i\n",Priv->ErrorCode); - if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0); + if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1); return ATGEN_HandleCMSError(s); case AT_Reply_Error: return ERR_UNKNOWN; default: return ERR_UNKNOWNRESPONSE; } } GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms) { GSM_Error error,error2; int current, current2, Replies; unsigned char buffer[1000], hexreq[1000]; GSM_Phone_Data *Phone = &s->Phone.Data; if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit; error = ATGEN_MakeSMSFrame(s, sms, hexreq, ¤t, ¤t2); if (error != ERR_NONE) return error; switch (Phone->Priv.ATGEN.SMSMode) { case SMS_AT_PDU: sprintf(buffer, "AT+CMGS=%i\r",current); break; case SMS_AT_TXT: sprintf(buffer, "AT+CMGS=\"%s\"\r",DecodeUnicodeString(sms->Number)); } s->Protocol.Data.AT.EditMode = true; Replies = s->ReplyNum; s->ReplyNum = 1; smprintf(s,"Waiting for modem prompt\n"); error=GSM_WaitFor (s, buffer, strlen(buffer), 0x00, 3, ID_IncomingFrame); s->ReplyNum = Replies; if (error == ERR_NONE) { smprintf(s, "Sending SMS\n"); error = s->Protocol.Functions->WriteMessage(s, hexreq, current2, 0x00); if (error!=ERR_NONE) return error; my_sleep(500); /* CTRL+Z ends entering */ error=s->Protocol.Functions->WriteMessage(s, "\x1A", 1, 0x00); my_sleep(100); return error; } else { smprintf(s, "Escaping SMS mode\n"); error2=s->Protocol.Functions->WriteMessage(s, "\x1B\r", 2, 0x00); if (error2 != ERR_NONE) return error2; } @@ -1742,96 +1798,109 @@ GSM_Error ATGEN_ReplyGetDateTime_Alarm(GSM_Protocol_Message msg, GSM_StateMachin if (Data->RequestID == ID_GetDateTime) { ATGEN_DecodeDateTime(Data->DateTime, msg.Buffer+current); } else { ATGEN_DecodeDateTime(&(Data->Alarm->DateTime), msg.Buffer+current); } return ERR_NONE; } case AT_Reply_Error: return ERR_NOTSUPPORTED; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: break; } return ERR_UNKNOWNRESPONSE; } GSM_Error ATGEN_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) { s->Phone.Data.DateTime=date_time; smprintf(s, "Getting date & time\n"); return GSM_WaitFor (s, "AT+CCLK?\r", 9, 0x00, 4, ID_GetDateTime); } GSM_Error ATGEN_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time) { char req[128]; sprintf(req, "AT+CCLK=\"%02i/%02i/%02i,%02i:%02i:%02i+00\"\r", date_time->Year-2000,date_time->Month,date_time->Day, date_time->Hour,date_time->Minute,date_time->Second); smprintf(s, "Setting date & time\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetDateTime); } GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) { if (alarm->Location != 1) return ERR_NOTSUPPORTED; alarm->Repeating = true; alarm->Text[0] = 0; alarm->Text[1] = 0; s->Phone.Data.Alarm = alarm; smprintf(s, "Getting alarm\n"); return GSM_WaitFor (s, "AT+CALA?\r", 9, 0x00, 4, ID_GetAlarm); } +/* R320 only takes HH:MM. Do other phones understand full date? */ +GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) +{ + char req[20]; + + if (alarm->Location != 1) return ERR_INVALIDLOCATION; + + sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute); + + smprintf(s, "Setting Alarm\n"); + return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm); +} + GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_SMSC *SMSC = s->Phone.Data.SMSC; int current; int len; unsigned char buffer[100]; switch (s->Phone.Data.Priv.ATGEN.ReplyState) { case AT_Reply_OK: smprintf(s, "SMSC info received\n"); current = 0; while (msg.Buffer[current]!='"') current++; /* SMSC number */ /* FIXME: support for all formats */ current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); /* * Some phones return this as unicode encoded when they are * switched to UCS2 mode, so we try to solve this correctly. */ len = strlen(buffer + 1) - 1; buffer[len + 1] = 0; if ((len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) { /* This is probably unicode encoded number */ DecodeHexUnicode(SMSC->Number,buffer + 1,len); } else { EncodeUnicode(SMSC->Number,buffer + 1,len); } smprintf(s, "Number: \"%s\"\n",DecodeUnicodeString(SMSC->Number)); /* Format of SMSC number */ current+=ATGEN_ExtractOneParameter(msg.Buffer+current, buffer); smprintf(s, "Format %s\n",buffer); /* International number */ if (!strcmp(buffer,"145")) { sprintf(buffer+1,"%s",DecodeUnicodeString(SMSC->Number)); if (strlen(buffer+1)!=0 && buffer[1] != '+') { /* Sony Ericsson issue */ /* International number is without + */ buffer[0] = '+'; EncodeUnicode(SMSC->Number,buffer,strlen(buffer)); } } SMSC->Format = SMS_FORMAT_Text; SMSC->Validity.Format = SMS_Validity_RelativeFormat; SMSC->Validity.Relative = SMS_VALID_Max_Time; @@ -2157,162 +2226,170 @@ GSM_Error ATGEN_ReplyGetCPBRMemoryStatus(GSM_Protocol_Message msg, GSM_StateMach { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_MemoryStatus *MemoryStatus = s->Phone.Data.MemoryStatus; int line=0; char *str; int cur; switch (Priv->ReplyState) { case AT_Reply_OK: smprintf(s, "Memory entries received\n"); /* Walk through lines with +CPBR: */ while (Priv->Lines.numbers[line*2+1]!=0) { str = GetLineString(msg.Buffer,Priv->Lines,line+1); if (strncmp(str, "+CPBR: ", 7) == 0) { MemoryStatus->MemoryUsed++; if (sscanf(str, "+CPBR: %d,", &cur) == 1) { cur -= Priv->FirstMemoryEntry - 1; if (cur == Priv->NextMemoryEntry || Priv->NextMemoryEntry == 0) Priv->NextMemoryEntry = cur + 1; } } line++; } return ERR_NONE; case AT_Reply_Error: return ERR_UNKNOWN; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: return ERR_UNKNOWNRESPONSE; } } GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM_AT_NeededMemoryInfo NeededInfo) { GSM_Error error; char req[20]; int start; int end; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; smprintf(s, "Getting memory information\n"); Priv->MemorySize = 0; Priv->TextLength = 0; Priv->NumberLength = 0; error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus); + if (Priv->Manufacturer == AT_Samsung) + error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus); if (error != ERR_NONE) return error; if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE; smprintf(s, "Getting memory status by reading values\n"); s->Phone.Data.MemoryStatus = Status; Status->MemoryUsed = 0; Status->MemoryFree = 0; start = Priv->FirstMemoryEntry; Priv->NextMemoryEntry = 0; while (1) { end = start + 20; if (end > Priv->MemorySize) end = Priv->MemorySize; sprintf(req, "AT+CPBR=%i,%i\r", start, end); error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemoryStatus); if (error != ERR_NONE) return error; if (NeededInfo == AT_NextEmpty && Priv->NextMemoryEntry != 0 && Priv->NextMemoryEntry != end + 1) return ERR_NONE; if (end == Priv->MemorySize) { Status->MemoryFree = Priv->MemorySize - Status->MemoryUsed; return ERR_NONE; } start = end + 1; } } GSM_Error ATGEN_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) { GSM_Error error; error = ATGEN_SetPBKMemory(s, Status->MemoryType); if (error != ERR_NONE) return error; s->Phone.Data.MemoryStatus=Status; /* in some phones doesn't work or doesn't return memory status inside */ /* Some workaround for buggy mobile, that hangs after "AT+CPBS?" for other * memory than SM. */ if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_BROKENCPBS) || (Status->MemoryType == MEM_SM)) { smprintf(s, "Getting memory status\n"); error=GSM_WaitFor (s, "AT+CPBS?\r", 9, 0x00, 4, ID_GetMemoryStatus); if (error == ERR_NONE) return ERR_NONE; } return ATGEN_GetMemoryInfo(s, Status, AT_Status); } GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; /* Have we already selected something? */ if (Priv->PBKCharset!=0) { /* If we want unicode charset and we have it already or setting of it * failed, we have nothing to do. */ if (PreferUnicode && (Priv->PBKCharset==AT_PBK_UCS2 || Priv->UCS2CharsetFailed)) return ERR_NONE; /* If we don't need unicode charset and we have some (or have unicode * charset when other failed), we have nothing to do. */ if (!PreferUnicode && (Priv->PBKCharset!=AT_PBK_UCS2 || Priv->NonUCS2CharsetFailed)) return ERR_NONE; } error=ATGEN_GetManufacturer(s); if (error != ERR_NONE) return error; + /* Samsung (and Sagem?) phones use only PCCP437? */ + if (Priv->Manufacturer == AT_Samsung) { + Priv->PBKCharset = AT_PBK_PCCP437; + return ERR_NONE; + } + if (PreferUnicode && !Priv->UCS2CharsetFailed) { smprintf(s, "Setting charset to UCS2\n"); error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset); if (error == ERR_NONE) { Priv->PBKCharset = AT_PBK_UCS2; return ERR_NONE; } else { Priv->UCS2CharsetFailed = true; } } smprintf(s, "Setting charset to HEX\n"); error=GSM_WaitFor (s, "AT+CSCS=\"HEX\"\r", 14, 0x00, 3, ID_SetMemoryCharset); /* Falcom replies OK for HEX mode and send everything * in normal format */ if (error == ERR_NONE && Priv->Manufacturer != AT_Falcom) { Priv->PBKCharset = AT_PBK_HEX; return ERR_NONE; } smprintf(s, "Setting charset to GSM\n"); error=GSM_WaitFor (s, "AT+CSCS=\"GSM\"\r", 14, 0x00, 3, ID_SetMemoryCharset); if (error == ERR_NONE) { Priv->PBKCharset = AT_PBK_GSM; return ERR_NONE; } if (!Priv->UCS2CharsetFailed) { Priv->NonUCS2CharsetFailed = true; smprintf(s, "Setting charset to UCS2\n"); error=GSM_WaitFor (s, "AT+CSCS=\"UCS2\"\r", 15, 0x00, 3, ID_SetMemoryCharset); if (error == ERR_NONE) { Priv->PBKCharset = AT_PBK_UCS2; return ERR_NONE; } else { Priv->UCS2CharsetFailed = true; } } return error; } GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_MemoryEntry *Memory = s->Phone.Data.Memory; char *pos; unsigned char buffer[500],buffer2[500]; @@ -2340,97 +2417,127 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) Memory->EntriesNum++; Memory->Entries[0].EntryType = PBK_Number_General; Memory->Entries[0].VoiceTag = 0; Memory->Entries[0].SMSList[0] = 0; len = strlen(buffer + 1) - 1; if (Priv->PBKCharset == AT_PBK_HEX && (len > 10) && (len % 2 == 0) && (strchr(buffer + 1, '+') == NULL)) { /* This is probably hex encoded number */ DecodeHexBin(buffer2, buffer+1, len); DecodeDefault(Memory->Entries[0].Text ,buffer2, strlen(buffer2), false, NULL); } else if (Priv->PBKCharset == AT_PBK_UCS2 && (len > 20) && (len % 4 == 0) && (strchr(buffer + 1, '+') == NULL)) { /* This is probably unicode encoded number */ DecodeHexUnicode(Memory->Entries[0].Text, buffer + 1,len); } else { EncodeUnicode(Memory->Entries[0].Text, buffer + 1, len); } /* Number format */ pos += ATGEN_ExtractOneParameter(pos, buffer); smprintf(s, "Number format: %s\n",buffer); /* International number */ if (!strcmp(buffer,"145")) { sprintf(buffer+1,"%s",DecodeUnicodeString(Memory->Entries[0].Text)); if (strlen(buffer+1)!=0 && buffer[1] != '+') { /* Sony Ericsson issue */ /* International number is without + */ buffer[0] = '+'; EncodeUnicode(Memory->Entries[0].Text,buffer,strlen(buffer)); } } /* Name */ pos += ATGEN_ExtractOneParameter(pos, buffer); smprintf(s, "Name text: %s\n",buffer); Memory->EntriesNum++; Memory->Entries[1].EntryType=PBK_Text_Name; switch (Priv->PBKCharset) { case AT_PBK_HEX: DecodeHexBin(buffer2,buffer+1,strlen(buffer)-2); DecodeDefault(Memory->Entries[1].Text,buffer2,strlen(buffer2),false,NULL); break; case AT_PBK_GSM: DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL); break; case AT_PBK_UCS2: DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1); break; + case AT_PBK_PCCP437: + /* FIXME: correctly decode PCCP437 */ + DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL); + break; + } + + /* Samsung number type */ + if (Priv->Manufacturer == AT_Samsung) { + int type; + + pos += ATGEN_ExtractOneParameter(pos, buffer); + smprintf(s, "Number type: %s\n",buffer); + type = strtoul(buffer, NULL, 0); + switch (type) { + case 0: + Memory->Entries[0].EntryType = PBK_Number_Mobile; + break; + case 1: + Memory->Entries[0].EntryType = PBK_Number_Work; + break; + case 2: + Memory->Entries[0].EntryType = PBK_Number_Home; + break; + case 3: + Memory->Entries[0].EntryType = PBK_Text_Email; + break; + default: + Memory->Entries[0].EntryType = PBK_Number_General; + } } + return ERR_NONE; case AT_Reply_CMEError: return ATGEN_HandleCMEError(s); case AT_Reply_Error: smprintf(s, "Error - too high location ?\n"); return ERR_INVALIDLOCATION; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: break; } return ERR_UNKNOWNRESPONSE; } GSM_Error ATGEN_PrivGetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry, int endlocation) { GSM_Error error; unsigned char req[20]; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (entry->Location==0x00) return ERR_INVALIDLOCATION; if (entry->MemoryType == MEM_ME) { if (Priv->PBKSBNR == 0) { sprintf(req, "AT^SBNR=?\r"); smprintf(s, "Checking availablity of SBNR\n"); error=GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory); switch (error) { case ERR_NONE: Priv->PBKSBNR = AT_SBNR_AVAILABLE; break; case ERR_UNKNOWN: case ERR_NOTSUPPORTED: Priv->PBKSBNR = AT_SBNR_NOTAVAILABLE; break; default: return error; } } if (Priv->PBKSBNR == AT_SBNR_AVAILABLE) { sprintf(req, "AT^SBNR=vcf,%i\r",entry->Location-1); s->Phone.Data.Memory=entry; smprintf(s, "Getting phonebook entry\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetMemory); } } error=ATGEN_GetManufacturer(s); @@ -2517,96 +2624,98 @@ GSM_Error ATGEN_DeleteAllMemory(GSM_StateMachine *s, GSM_MemoryType type) error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_SetMemory); if (error != ERR_NONE) return error; } return ERR_NONE; } GSM_Error ATGEN_ReplyDialVoice(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (s->Phone.Data.Priv.ATGEN.ReplyState) { case AT_Reply_OK: smprintf(s, "Dial voice OK\n"); return ERR_NONE; case AT_Reply_Error: smprintf(s, "Dial voice error\n"); return ERR_UNKNOWN; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: break; } return ERR_UNKNOWNRESPONSE; } GSM_Error ATGEN_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) { char req[39] = "ATDT"; if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED; if (strlen(number) > 32) return (ERR_UNKNOWN); strcat(req, number); strcat(req, ";\r"); smprintf(s, "Making voice call\n"); return GSM_WaitFor (s, req, 4+2+strlen(number), 0x00, 5, ID_DialVoice); } GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (s->Phone.Data.Priv.ATGEN.ReplyState) { case AT_Reply_OK: smprintf(s, "Security code was OK\n"); return ERR_NONE; case AT_Reply_Error: smprintf(s, "Incorrect security code\n"); return ERR_SECURITYERROR; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); + case AT_Reply_CMEError: + return ATGEN_HandleCMEError(s); default: break; } return ERR_UNKNOWNRESPONSE; } GSM_Error ATGEN_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode Code) { unsigned char req[50]; switch (Code.Type) { case SEC_Pin : sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code); break; case SEC_Pin2 : if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Siemens) { sprintf(req, "AT+CPIN2=\"%s\"\r", Code.Code); } else { sprintf(req, "AT+CPIN=\"%s\"\r" , Code.Code); } break; default : return ERR_NOTIMPLEMENTED; } smprintf(s, "Entering security code\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 6, ID_EnterSecurityCode); } GSM_Error ATGEN_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_SecurityCodeType *Status = s->Phone.Data.SecurityStatus; smprintf(s, "Security status received - "); if (strstr(msg.Buffer,"READY")) { *Status = SEC_None; smprintf(s, "nothing to enter\n"); return ERR_NONE; } if (strstr(msg.Buffer,"PH_SIM PIN")) { smprintf(s, "no SIM inside or other error\n"); return ERR_UNKNOWN; } if (strstr(msg.Buffer,"SIM PIN2")) { *Status = SEC_Pin2; smprintf(s, "waiting for PIN2\n"); return ERR_NONE; } if (strstr(msg.Buffer,"SIM PUK2")) { @@ -2879,96 +2988,102 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) if (entry->Location == 0) return ERR_INVALIDLOCATION; error = ATGEN_SetPBKMemory(s, entry->MemoryType); if (error != ERR_NONE) return error; GSM_PhonebookFindDefaultNameNumberGroup(entry, &Name, &Number, &Group); name[0] = 0; if (Name != -1) { len = UnicodeLength(entry->Entries[Name].Text); /* Compare if we would loose some information when not using * unicode */ EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); DecodeDefault(uname, name, len, true, NULL); if (!mywstrncmp(uname, entry->Entries[Name].Text, len)) { /* Get maximal text length */ if (Priv->TextLength == 0) { ATGEN_GetMemoryInfo(s, NULL, AT_Sizes); } /* I char stored in GSM alphabet takes 7 bits, one * unicode 16, if storing in unicode would truncate * text, do not use it, otherwise we will use it */ if ((Priv->TextLength != 0) && ((Priv->TextLength * 7 / 16) <= len)) { PreferUnicode = false; } else { PreferUnicode = true; } } error = ATGEN_SetPBKCharset(s, PreferUnicode); if (error != ERR_NONE) return error; switch (Priv->PBKCharset) { case AT_PBK_HEX: EncodeHexBin(name, DecodeUnicodeString(entry->Entries[Name].Text), UnicodeLength(entry->Entries[Name].Text)); len = strlen(name); break; case AT_PBK_GSM: smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text)); len = UnicodeLength(entry->Entries[Name].Text); EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); break; case AT_PBK_UCS2: EncodeHexUnicode(name, entry->Entries[Name].Text, UnicodeLength(entry->Entries[Name].Text)); len = strlen(name); break; + case AT_PBK_PCCP437: + /* FIXME: correctly decode PCCP437 */ + smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text)); + len = UnicodeLength(entry->Entries[Name].Text); + EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL); + break; } } else { smprintf(s, "WARNING: No usable name found!\n"); len = 0; } if (Number != -1) { GSM_PackSemiOctetNumber(entry->Entries[Number].Text, number, false); NumberType = number[0]; sprintf(number,"%s",DecodeUnicodeString(entry->Entries[Number].Text)); } else { smprintf(s, "WARNING: No usable number found!\n"); number[0] = 0; } if (Priv->FirstMemoryEntry == 0) { error = ATGEN_GetMemoryInfo(s, NULL, AT_First); if (error != ERR_NONE) return error; } /* We can't use here: * sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"%s\"\r", * entry->Location, number, NumberType, name); * because name can contain 0 when using GSM alphabet. */ sprintf(req, "AT+CPBW=%d, \"%s\", %i, \"", entry->Location + Priv->FirstMemoryEntry - 1, number, NumberType); reqlen = strlen(req); if (reqlen + len > REQUEST_SIZE - 2) { smprintf(s, "WARNING: Text truncated to fit in buffer!\n"); len = REQUEST_SIZE - 2 - reqlen; } memcpy(req + reqlen, name, len); reqlen += len; memcpy(req + reqlen, "\"\r", 2); reqlen += 2; smprintf(s, "Writing phonebook entry\n"); return GSM_WaitFor (s, req, reqlen, 0x00, 4, ID_SetMemory); #undef REQUEST_SIZE } GSM_Error ATGEN_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) { if (entry->Location == 0) return ERR_INVALIDLOCATION; return ATGEN_PrivSetMemory(s, entry); } GSM_Error ATGEN_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) @@ -3207,463 +3322,541 @@ GSM_Error ATGEN_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig) return GSM_WaitFor (s, "AT+CSQ\r", 7, 0x00, 4, ID_GetSignalQuality); } /* When use AT+CPIN?, A2D returns it without OK and because of it Gammu parses answer without it. MC35 and other return OK after answer for AT+CPIN?. Here we handle it. Any better idea ? */ GSM_Error ATGEN_ReplyOK(GSM_Protocol_Message msg, GSM_StateMachine *s) { return ERR_NONE; } static GSM_Error ATGEN_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer==AT_Siemens ) return SIEMENS_GetNextCalendar(s,Note,start); if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_GetNextCalendar(s,Note,start); return ERR_NOTSUPPORTED; } GSM_Error ATGEN_Terminate(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; free(Priv->file.Buffer); return ERR_NONE; } GSM_Error ATGEN_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer==AT_Siemens) return SIEMENS_AddCalendarNote(s, Note); if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_AddCalendarNote(s, Note); return ERR_NOTSUPPORTED; } GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer==AT_Siemens) return SIEMENS_DelCalendarNote(s, Note); if (Priv->Manufacturer==AT_Ericsson) return SONYERIC_DelCalendarNote(s, Note); return ERR_NOTSUPPORTED; } + +GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + + if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap); + if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap); + return ERR_NOTSUPPORTED; +} + +GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + + if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap); + if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap); + return ERR_NOTSUPPORTED; +} + +GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + + if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone); + if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone); + return ERR_NOTSUPPORTED; +} + +GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + + if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength); + if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength); + return ERR_NOTSUPPORTED; +} + GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) { GSM_Error error; unsigned char Frame[] = "AT+CKPD=\"?\"\r"; if (Press) { switch (Key) { case GSM_KEY_1 : Frame[9] = '1'; break; case GSM_KEY_2 : Frame[9] = '2'; break; case GSM_KEY_3 : Frame[9] = '3'; break; case GSM_KEY_4 : Frame[9] = '4'; break; case GSM_KEY_5 : Frame[9] = '5'; break; case GSM_KEY_6 : Frame[9] = '6'; break; case GSM_KEY_7 : Frame[9] = '7'; break; case GSM_KEY_8 : Frame[9] = '8'; break; case GSM_KEY_9 : Frame[9] = '9'; break; case GSM_KEY_0 : Frame[9] = '0'; break; case GSM_KEY_HASH : Frame[9] = '#'; break; case GSM_KEY_ASTERISK : Frame[9] = '*'; break; case GSM_KEY_POWER : return ERR_NOTSUPPORTED; case GSM_KEY_GREEN : Frame[9] = 'S'; break; case GSM_KEY_RED : Frame[9] = 'E'; break; case GSM_KEY_INCREASEVOLUME : Frame[9] = 'U'; break; case GSM_KEY_DECREASEVOLUME : Frame[9] = 'D'; break; case GSM_KEY_UP : Frame[9] = '^'; break; case GSM_KEY_DOWN : Frame[9] = 'V'; break; case GSM_KEY_MENU : Frame[9] = 'F'; break; case GSM_KEY_NAMES : Frame[9] = 'C'; break; default : return ERR_NOTSUPPORTED; } smprintf(s, "Pressing key\n"); error = GSM_WaitFor (s, Frame, 12, 0x00, 4, ID_PressKey); if (error != ERR_NONE) return error; /* Strange. My T310 needs it */ return GSM_WaitFor (s, "ATE1\r", 5, 0x00, 4, ID_EnableEcho); } else { return ERR_NONE; } } #ifdef GSM_ENABLE_CELLBROADCAST GSM_Error ATGEN_ReplyIncomingCB(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_CBMessage CB; int i,j; char Buffer[300],Buffer2[300]; smprintf(s, "CB received\n"); return ERR_NONE; DecodeHexBin (Buffer,msg.Buffer+6,msg.Length-6); DumpMessage(stdout, di.dl ,Buffer,msg.Length-6); CB.Channel = Buffer[4]; for (j=0;j<msg.Length;j++) { smprintf(s, "j=%i\n",j); i=GSM_UnpackEightBitsToSeven(0, msg.Buffer[6], msg.Buffer[6], msg.Buffer+j, Buffer2); // i = msg.Buffer[6] - 1; // while (i!=0) { // if (Buffer[i] == 13) i = i - 1; else break; // } DecodeDefault(CB.Text, Buffer2, msg.Buffer[6], false, NULL); smprintf(s, "Channel %i, text \"%s\"\n",CB.Channel,DecodeUnicodeString(CB.Text)); } if (s->Phone.Data.EnableIncomingCB && s->User.IncomingCB!=NULL) { s->User.IncomingCB(s->CurrentConfig->Device,CB); } return ERR_NONE; } #endif GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable) { #ifdef GSM_ENABLE_CELLBROADCAST if (s->Phone.Data.EnableIncomingCB!=enable) { s->Phone.Data.EnableIncomingCB = enable; if (enable) { smprintf(s, "Enabling incoming CB\n"); return GSM_WaitFor(s, "AT+CNMI=3,,2\r", 13, 0x00, 4, ID_SetIncomingCB); } else { smprintf(s, "Disabling incoming CB\n"); return GSM_WaitFor(s, "AT+CNMI=3,,0\r", 13, 0x00, 4, ID_SetIncomingCB); } } return ERR_NONE; #else return ERR_SOURCENOTAVAILABLE; #endif } +GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable) +{ + if (enable) { + smprintf(s, "Enabling fast SMS sending\n"); + return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending); + } else { + smprintf(s, "Disabling fast SMS sending\n"); + return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending); + } +} + GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Incoming SMS\n"); return ERR_NONE; } GSM_Error ATGEN_IncomingSMSDeliver(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; GSM_SMSMessage sms; int current = 0, current2, i=0; unsigned char buffer[300],smsframe[800]; smprintf(s, "Incoming SMS received (Deliver)\n"); if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) { sms.State = SMS_UnRead; sms.InboxFolder = true; sms.PDU = SMS_Deliver; /* T310 with larger SMS goes crazy and mix this incoming * frame with normal answers. PDU is always last frame * We find its' number and parse it */ while (Data->Priv.ATGEN.Lines.numbers[i*2+1] != 0) { /* FIXME: handle special chars correctly */ i++; } DecodeHexBin (buffer, GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i), strlen(GetLineString(msg.Buffer,Data->Priv.ATGEN.Lines,i))); /* We use locations from SMS layouts like in ../phone2.c(h) */ for(i=0;i<buffer[0]+1;i++) smsframe[i]=buffer[current++]; smsframe[12]=buffer[current++]; current2=((buffer[current])+1)/2+1; for(i=0;i<current2+1;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; smsframe[PHONE_SMSDeliver.TPPID] = buffer[current++]; smsframe[PHONE_SMSDeliver.TPDCS] = buffer[current++]; for(i=0;i<7;i++) smsframe[PHONE_SMSDeliver.DateTime+i]=buffer[current++]; smsframe[PHONE_SMSDeliver.TPUDL] = buffer[current++]; for(i=0;i<smsframe[PHONE_SMSDeliver.TPUDL];i++) smsframe[i+PHONE_SMSDeliver.Text]=buffer[current++]; GSM_DecodeSMSFrame(&sms,smsframe,PHONE_SMSDeliver); s->User.IncomingSMS(s->CurrentConfig->Device,sms); } return ERR_NONE; } /* I don't have phone able to do it and can't fill it */ GSM_Error ATGEN_IncomingSMSReport(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Incoming SMS received (Report)\n"); return ERR_NONE; } GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable) { /* Nokia returns OK, but doesn't return anything */ if (s->Phone.Data.Priv.ATGEN.Manufacturer == AT_Nokia) return ERR_NOTSUPPORTED; if (s->Phone.Data.EnableIncomingSMS!=enable) { s->Phone.Data.EnableIncomingSMS = enable; if (enable) { smprintf(s, "Enabling incoming SMS\n"); /* Delivery reports */ GSM_WaitFor(s, "AT+CNMI=3,,,1\r", 14, 0x00, 4, ID_SetIncomingSMS); /* SMS deliver */ return GSM_WaitFor(s, "AT+CNMI=3,3\r", 12, 0x00, 4, ID_SetIncomingSMS); } else { smprintf(s, "Disabling incoming SMS\n"); return GSM_WaitFor(s, "AT+CNMI=3,0\r", 12, 0x00, 4, ID_SetIncomingSMS); } } return ERR_NONE; } +GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) +{ + if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale); + return ERR_NOTSUPPORTED; +} + +GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale) +{ + if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale); + return ERR_NOTSUPPORTED; +} + GSM_Reply_Function ATGENReplyFunctions[] = { {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_EnableEcho }, {ATGEN_GenericReply, "AT+CMEE=" ,0x00,0x00,ID_EnableErrorInfo }, {ATGEN_GenericReply, "AT+CKPD=" ,0x00,0x00,ID_PressKey }, {ATGEN_ReplyGetSIMIMSI, "AT+CIMI" ,0x00,0x00,ID_GetSIMIMSI }, {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX }, +{ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale }, +{ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale }, +{ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale }, +{ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale }, + #ifdef GSM_ENABLE_CELLBROADCAST {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingCB }, #endif {ATGEN_IncomingBattery, "_OBS:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyGetBatteryCharge, "AT+CBC" ,0x00,0x00,ID_GetBatteryCharge }, {ATGEN_ReplyGetModel, "AT+CGMM" ,0x00,0x00,ID_GetModel }, {ATGEN_ReplyGetManufacturer, "AT+CGMI" ,0x00,0x00,ID_GetManufacturer }, {ATGEN_ReplyGetFirmwareCGMR, "AT+CGMR" ,0x00,0x00,ID_GetFirmware }, {ATGEN_ReplyGetFirmwareATI, "ATI" ,0x00,0x00,ID_GetFirmware }, {ATGEN_ReplyGetIMEI, "AT+CGSN" ,0x00,0x00,ID_GetIMEI }, {ATGEN_ReplySendSMS, "AT+CMGS" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplySendSMS, "AT+CMSS" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReply, "AT+CNMI" ,0x00,0x00,ID_SetIncomingSMS }, {ATGEN_GenericReply, "AT+CMGF" ,0x00,0x00,ID_GetSMSMode }, {ATGEN_GenericReply, "AT+CSDH" ,0x00,0x00,ID_GetSMSMode }, {ATGEN_ReplyGetSMSMessage, "AT+CMGR" ,0x00,0x00,ID_GetSMSMessage }, {ATGEN_GenericReply, "AT+CPMS" ,0x00,0x00,ID_SetMemoryType }, {ATGEN_ReplyGetSMSStatus, "AT+CPMS" ,0x00,0x00,ID_GetSMSStatus }, {ATGEN_ReplyGetSMSMemories, "AT+CPMS=?" ,0x00,0x00,ID_GetSMSMemories }, {ATGEN_ReplyAddSMSMessage, "AT+CMGW" ,0x00,0x00,ID_SaveSMSMessage }, {ATGEN_GenericReply, "AT+CSMP" ,0x00,0x00,ID_SetSMSParameters }, {ATGEN_GenericReply, "AT+CSCA" ,0x00,0x00,ID_SetSMSC }, {ATGEN_ReplyGetSMSC, "AT+CSCA?" ,0x00,0x00,ID_GetSMSC }, {ATGEN_ReplyDeleteSMSMessage, "AT+CMGD" ,0x00,0x00,ID_DeleteSMSMessage }, {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters }, {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters }, +{ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending }, {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_IncomingSMSReport, "+CDS:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_IncomingSMSCInfo, "^SCN:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime }, {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime }, +{ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm }, {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm }, {ATGEN_ReplyGetNetworkLAC_CID, "AT+CREG?" ,0x00,0x00,ID_GetNetworkInfo }, {ATGEN_GenericReply, "AT+CREG=2" ,0x00,0x00,ID_GetNetworkInfo }, {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_GetNetworkInfo }, {ATGEN_GenericReply, "AT+COPS=" ,0x00,0x00,ID_SetAutoNetworkLogin}, {ATGEN_ReplyGetNetworkCode, "AT+COPS" ,0x00,0x00,ID_GetNetworkInfo }, {ATGEN_ReplyGetSignalQuality, "AT+CSQ" ,0x00,0x00,ID_GetSignalQuality }, {ATGEN_IncomingNetworkLevel, "_OSIGQ:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_IncomingGPRS, "+CGREG:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyGetNetworkLAC_CID, "+CREG:" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyGetPBKMemories, "AT+CPBS=?" ,0x00,0x00,ID_SetMemoryType }, {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType }, {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus }, +// /* Samsung phones reply +CPBR: after OK --claudio*/ {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus }, +{ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus }, {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus }, {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset }, {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory }, {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory }, -{ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, +{SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory }, -{ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, -{ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, +{SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, +{SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, -{ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, -{ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, +{SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, +{SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, -{ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, -{ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, -{ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote }, +{SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, +{SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, +{SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_DeleteCalendarNote }, {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode }, {ATGEN_ReplyEnterSecurityCode, "AT+CPIN2=" ,0x00,0x00,ID_EnterSecurityCode }, {ATGEN_ReplyGetSecurityStatus, "AT+CPIN?" ,0x00,0x00,ID_GetSecurityStatus }, {ATGEN_ReplyOK, "OK" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReply, "AT+VTS" ,0x00,0x00,ID_SendDTMF }, {ATGEN_ReplyCancelCall, "AT+CHUP" ,0x00,0x00,ID_CancelCall }, {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice }, {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall }, +{ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD }, +{ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyIncomingCallInfo, "+COLP" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyIncomingCallInfo, "RING" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyIncomingCallInfo, "NO CARRIER" ,0x00,0x00,ID_IncomingFrame }, {ATGEN_ReplyReset, "AT^SRESET" ,0x00,0x00,ID_Reset }, {ATGEN_ReplyReset, "AT+CFUN=1,1" ,0x00,0x00,ID_Reset }, {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings }, +{SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap }, +{SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap }, + +{SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone }, +{SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone }, + #ifdef GSM_ENABLE_ALCATEL /* Why do I give Alcatel specific things here? It's simple, Alcatel needs * some AT commands to start it's binary mode, so this needs to be in AT * related stuff. * * XXX: AT+IFC could later move outside this ifdef, because it is not Alcatel * specific and it's part of ETSI specifications */ {ATGEN_GenericReply, "AT+IFC" ,0x00,0x00,ID_SetFlowControl }, {ALCATEL_ProtocolVersionReply, "AT+CPROT=?" ,0x00,0x00,ID_AlcatelProtocol }, {ATGEN_GenericReply, "AT+CPROT" ,0x00,0x00,ID_AlcatelConnect }, #endif {NULL, "\x00" ,0x00,0x00,ID_None } }; GSM_Phone_Functions ATGENPhone = { - "A2D|iPAQ|at|M20|S25|MC35|C35i|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210", + "A2D|iPAQ|at|M20|S25|MC35|TC35|C35i|S300|5110|5130|5190|5210|6110|6130|6150|6190|6210|6250|6310|6310i|6510|7110|8210|8250|8290|8310|8390|8850|8855|8890|8910|9110|9210", ATGENReplyFunctions, ATGEN_Initialise, ATGEN_Terminate, ATGEN_DispatchMessage, NOTSUPPORTED, /* ShowStartInfo */ ATGEN_GetManufacturer, ATGEN_GetModel, ATGEN_GetFirmware, ATGEN_GetIMEI, NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ NOTSUPPORTED, /* GetProductCode */ NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ ATGEN_GetSIMIMSI, ATGEN_GetDateTime, ATGEN_SetDateTime, ATGEN_GetAlarm, - NOTIMPLEMENTED, /* SetAlarm */ - NOTSUPPORTED, /* GetLocale */ - NOTSUPPORTED, /* SetLocale */ + ATGEN_SetAlarm, + ATGEN_GetLocale, + ATGEN_SetLocale, ATGEN_PressKey, ATGEN_Reset, ATGEN_ResetPhoneSettings, ATGEN_EnterSecurityCode, ATGEN_GetSecurityStatus, ATGEN_GetDisplayStatus, ATGEN_SetAutoNetworkLogin, ATGEN_GetBatteryCharge, ATGEN_GetSignalQuality, ATGEN_GetNetworkInfo, NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ ATGEN_GetMemoryStatus, ATGEN_GetMemory, ATGEN_GetNextMemory, ATGEN_SetMemory, ATGEN_AddMemory, ATGEN_DeleteMemory, ATGEN_DeleteAllMemory, NOTSUPPORTED, /* GetSpeedDial */ NOTSUPPORTED, /* SetSpeedDial */ ATGEN_GetSMSC, ATGEN_SetSMSC, ATGEN_GetSMSStatus, ATGEN_GetSMS, ATGEN_GetNextSMS, NOTSUPPORTED, /* SetSMS */ ATGEN_AddSMS, ATGEN_DeleteSMS, ATGEN_SendSMS, ATGEN_SendSavedSMS, + ATGEN_SetFastSMSSending, ATGEN_SetIncomingSMS, ATGEN_SetIncomingCB, ATGEN_GetSMSFolders, NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ ATGEN_DialVoice, ATGEN_AnswerCall, ATGEN_CancelCall, NOTSUPPORTED, /* HoldCall */ NOTSUPPORTED, /* UnholdCall */ NOTSUPPORTED, /* ConferenceCall */ NOTSUPPORTED, /* SplitCall */ NOTSUPPORTED, /* TransferCall */ NOTSUPPORTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NONEFUNCTION, /* SetIncomingCall */ - NOTSUPPORTED, /* SetIncomingUSSD */ + ATGEN_SetIncomingUSSD, ATGEN_SendDTMF, ATGEN_GetRingtone, ATGEN_SetRingtone, NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ ATGEN_GetBitmap, /* GetBitmap */ ATGEN_SetBitmap, /* SetBitmap */ SONYERIC_GetToDoStatus, NOTSUPPORTED, /* GetToDo */ SONYERIC_GetNextToDo, NOTSUPPORTED, /* SetToDo */ SONYERIC_AddToDo, NOTSUPPORTED, /* DeleteToDo */ SONYERIC_DeleteAllToDo, SONYERIC_GetCalendarStatus, NOTIMPLEMENTED, /* GetCalendar */ ATGEN_GetNextCalendar, NOTIMPLEMENTED, /* SetCalendar */ ATGEN_AddCalendarNote, ATGEN_DelCalendarNote, NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* 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: */ diff --git a/gammu/emb/common/phone/at/atgen.h b/gammu/emb/common/phone/at/atgen.h index 0e08ee4..bb5c559 100644 --- a/gammu/emb/common/phone/at/atgen.h +++ b/gammu/emb/common/phone/at/atgen.h @@ -1,110 +1,116 @@ /* (c) 2002-2004 by Marcin Wiacek and Michal Cihar */ #ifndef atgen_h #define atgen_h #include "../../gsmcomon.h" #include "../../gsmstate.h" #include "../../service/sms/gsmsms.h" #ifndef GSM_USED_AT # define GSM_USED_AT #endif #ifndef GSM_USED_BLUEAT # define GSM_USED_BLUEAT #endif #ifndef GSM_USED_IRDAAT # define GSM_USED_IRDAAT #endif #define MAX_VCALENDAR_LOCATION 50 typedef enum { SMS_AT_PDU = 1, SMS_AT_TXT } GSM_AT_SMS_Modes; typedef enum { AT_Reply_OK = 1, AT_Reply_Connect, AT_Reply_Error, AT_Reply_Unknown, AT_Reply_CMSError, AT_Reply_CMEError, AT_Reply_SMSEdit } GSM_AT_Reply_State; typedef enum { AT_Nokia = 1, AT_Alcatel, AT_Siemens, AT_HP, AT_Falcom, AT_Ericsson, AT_Sagem, + AT_Samsung, AT_Unknown } GSM_AT_Manufacturer; typedef enum { AT_PBK_HEX = 1, AT_PBK_GSM, - AT_PBK_UCS2 + AT_PBK_UCS2, + AT_PBK_PCCP437 } GSM_AT_PBK_Charset; typedef enum { AT_AVAILABLE = 1, AT_NOTAVAILABLE } GSM_AT_SMSMemory; typedef enum { AT_SBNR_AVAILABLE = 1, AT_SBNR_NOTAVAILABLE } GSM_AT_SBNR; typedef enum { AT_Status, AT_NextEmpty, AT_Total, AT_First, AT_Sizes } GSM_AT_NeededMemoryInfo; #define AT_PBK_MAX_MEMORIES 200 typedef struct { GSM_AT_Manufacturer Manufacturer; /* Who is manufacturer */ GSM_Lines Lines; /* Allow to simply get each line in response */ GSM_AT_Reply_State ReplyState; /* What response type - error, OK, etc. */ int ErrorCode; /* Error codes from responses */ char *ErrorText; /* Error description */ GSM_MemoryType PBKMemory; /* Last read PBK memory */ char PBKMemories[AT_PBK_MAX_MEMORIES + 1]; /* Supported by phone PBK memories */ int NextMemoryEntry; /* Next empty memory entry */ int FirstMemoryEntry; /* First memory entry to be read */ GSM_AT_PBK_Charset PBKCharset; /* Last read PBK charset */ bool UCS2CharsetFailed; /* Whether setting of UCS2 charset has already failed */ bool NonUCS2CharsetFailed; /* Whether setting of non-UCS2 charset has already failed */ GSM_AT_SBNR PBKSBNR; int NumberLength; int TextLength; int MemorySize; GSM_SMSMemoryStatus LastSMSStatus; int LastSMSRead; int FirstCalendarPos; bool CanSaveSMS; GSM_AT_SMSMemory PhoneSMSMemory; /* Is phone SMS memory available ? */ GSM_AT_SMSMemory SIMSMSMemory; /* Is SIM SMS memory available ? */ GSM_MemoryType SMSMemory; /* Last read SMS memory */ GSM_AT_SMS_Modes SMSMode; /* PDU or TEXT mode for SMS ? */ bool OBEX; GSM_File file; } GSM_Phone_ATGENData; +GSM_Error ATGEN_HandleCMSError (GSM_StateMachine *); +GSM_Error ATGEN_HandleCMEError (GSM_StateMachine *); +GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *); + #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/at/samsung.c b/gammu/emb/common/phone/at/samsung.c new file mode 100644 index 0000000..55a42e5 --- a/dev/null +++ b/gammu/emb/common/phone/at/samsung.c @@ -0,0 +1,447 @@ +/* Samsung-specific functions + * Copyright (C) 2004 Claudio Matsuoka <cmatsuoka@gmail.com> + * Tested with S300 only! + */ + +#include "../../gsmstate.h" + +#ifdef GSM_ENABLE_ATGEN + +#include <string.h> +#include <time.h> +#include <ctype.h> + +#include "../../misc/coding/coding.h" +#include "../../gsmcomon.h" +#include "../../service/sms/gsmsms.h" +#include "../pfunc.h" + +#include "atgen.h" +#include "samsung.h" + +/* Binary frame size */ +#define BLKSZ 1024 + +struct ModelRes { + char *model; + int width; + int height; +}; + +static struct ModelRes modres[] = { + { "S100", 128, 128 }, + { "S200", 128, 113 }, + { "S300", 128, 97 }, + { "S500", 128, 128 }, + { "T100", 128, 128 }, + { "E700", 128, 128 }, + { NULL, 0, 0 } +}; + +/* + * CRC functions from the Granch SBNI12 Linux driver by + * Denis I. Timofeev <timofeev@granch.ru> + */ +static unsigned int crc32tab[] = { + 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37, + 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E, + 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605, + 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C, + 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53, + 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A, + 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661, + 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278, + 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF, + 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6, + 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD, + 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4, + 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B, + 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82, + 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9, + 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0, + 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7, + 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE, + 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795, + 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C, + 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3, + 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA, + 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1, + 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8, + 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F, + 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76, + 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D, + 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344, + 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B, + 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12, + 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739, + 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320, + 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17, + 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E, + 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525, + 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C, + 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73, + 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A, + 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541, + 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158, + 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF, + 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6, + 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED, + 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4, + 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB, + 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2, + 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589, + 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190, + 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87, + 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E, + 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5, + 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC, + 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3, + 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA, + 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1, + 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8, + 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F, + 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856, + 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D, + 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064, + 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B, + 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832, + 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419, + 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000 +}; + +static unsigned int GetCRC(char *data, int size) +{ + unsigned int crc = 0; + + while (size--) + crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF); + + return crc; +} + +/* + * Frame transfer + */ + +static GSM_Error WaitFor(GSM_StateMachine *s, char *t, int ttl) +{ + char readbuf[100]; + int n; + unsigned int sec; + GSM_DateTime Date; + + GSM_GetCurrentDateTime (&Date); + sec = Date.Second; + + n = s->Device.Functions->ReadDevice(s, readbuf, 80); + readbuf[n] = 0; + while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.Second) { + my_sleep(5000); + n = s->Device.Functions->ReadDevice(s, readbuf, 80); + readbuf[n] = 0; + GSM_GetCurrentDateTime (&Date); + } + + return (sec + ttl) >= Date.Second ? ERR_NONE : ERR_TIMEOUT; +} + +static GSM_Error SetSamsungFrame(GSM_StateMachine *s, unsigned char *buff, int size, GSM_Phone_RequestID id) +{ + GSM_Phone_Data *Phone = &s->Phone.Data; + GSM_Error error; + int i, count; + + count = size / BLKSZ; + + for (i = 0; i < count; i++) { + error = WaitFor(s, ">", 4); + if (error!=ERR_NONE) return error; + + error = s->Protocol.Functions->WriteMessage(s, + buff + i * BLKSZ, BLKSZ, 0x00); + if (error!=ERR_NONE) return error; + } + + error = WaitFor(s, ">", 4); + if (error!=ERR_NONE) return error; + error = s->Protocol.Functions->WriteMessage(s, + buff + i * BLKSZ, size%BLKSZ, 0x00); + if (error!=ERR_NONE) return error; + + error = GSM_WaitFor(s, "", 0, 0x00, 4, id); + if (error!=ERR_NONE) return error; + + return Phone->DispatchError; +} + +/* Answer format for binary data transfer + * + * SDNDCRC = 0xa : RECEIVECRC = 0xcbf53a1c : BINSIZE = 5 + * CRCERR + */ +static GSM_Error ReplySetSamsungFrame(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + unsigned long txcrc, rxcrc; + int binsize; + char *pos; + + /* Parse SDNDCRC */ + pos = strchr(msg.Buffer, '='); + if (!pos) return ERR_UNKNOWN; + pos++; + txcrc = strtoul(pos, NULL, 0); + smprintf(s, "Sent CRC : 0x%lx\n", txcrc); + + /* Parse RECEIVECRC */ + pos = strchr(pos, '='); + if (!pos) return ERR_UNKNOWN; + pos++; + rxcrc = strtoul(pos, NULL, 0); + smprintf(s, "Reveived CRC : 0x%lx\n", rxcrc); + + /* Parse BINSIZE */ + pos = strchr(pos, '='); + if (!pos) return ERR_UNKNOWN; + pos++; + binsize = strtoul(pos, NULL, 0); + smprintf(s, "Binary size : %d\n", binsize); + + return txcrc == rxcrc ? ERR_NONE : ERR_WRONGCRC; +} + +/* + * Bitmaps + */ + +GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + unsigned char buffer[32]; + char *pos; + int location, count; + + switch (Priv->ReplyState) { + case AT_Reply_OK: + smprintf(s, "Bitmap info received\n"); + /* Parse +IMGR:location,name,0,0,0,0 */ + + /* Parse location */ + pos = strchr(msg.Buffer, ':'); + if (!pos) return ERR_UNKNOWN; + pos++; + location = atoi(pos); + smprintf(s, "Location : %d\n", location); + + /* Parse name */ + pos = strchr(pos, '"'); + if (!pos) return ERR_UNKNOWN; + pos++; + for (count = 0; count < 31; count++) { + if (pos[count] == '"') + break; + buffer[count] = pos[count]; + } + buffer[count] = 0; + smprintf(s, "Name : %s\n", buffer); + s->Phone.Data.Bitmap->Name = malloc((strlen(buffer) + 1) * 2); + if (s->Phone.Data.Bitmap->Name == NULL) + return ERR_MOREMEMORY; + EncodeUnicode(s->Phone.Data.Bitmap->Name, buffer, strlen(buffer)); + + s->Phone.Data.Bitmap->Location = location; + + return ERR_NONE; + case AT_Reply_Error: + return ERR_UNKNOWN; + case AT_Reply_CMSError: + return ATGEN_HandleCMSError(s); + case AT_Reply_CMEError: + return ATGEN_HandleCMEError(s); + default: + return ERR_UNKNOWNRESPONSE; + } +} + +GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + smprintf(s, "Bitmap sent\n"); + return ReplySetSamsungFrame(msg, s); +} + +GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +{ + unsigned char req[100]; + + s->Phone.Data.Bitmap=Bitmap; + smprintf(s, "Getting bitmap\n"); + sprintf(req, "AT+IMGR=%d\r", Bitmap->Location-1); + return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); +} + +GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +{ + unsigned char req[100]; + unsigned long crc; + GSM_Error error; + char name[50], *dot, *model; + GSM_Phone_Data *Data = &s->Phone.Data; + int i; + + s->Phone.Data.Bitmap = Bitmap; + smprintf(s, "Setting bitmap\n"); + + if (Bitmap->Type != GSM_PictureBinary) { + smprintf(s, "Invalid picture type\n"); + return ERR_INVALIDDATA; + } + + if (Bitmap->BinaryPic.Type != PICTURE_GIF) { + smprintf(s, "Invalid binary picture type\n"); + return ERR_INVALIDDATA; + } + + /* Check if picture size matches phone model */ + model = GetModelData(NULL,Data->Model,NULL)->model; + smprintf(s, "Checking picture size for %s\n", model); + for (i = 0; modres[i].model; i++) { + if (!strcmp(model, modres[i].model)) { + if (Bitmap->BitmapWidth != modres[i].width || + Bitmap->BitmapHeight != modres[i].height) { + smprintf(s, "Model %s must use %d x %d picture size\n", + modres[i].model, modres[i].width, + modres[i].height); + return ERR_INVALIDDATA; + } + break; + } + } + if (modres[i].model == NULL) { + smprintf(s, "Model \"%s\" is not supported.\n", Data->Model); + return ERR_NOTSUPPORTED; + } + + crc = GetCRC(Bitmap->BinaryPic.Buffer, Bitmap->BinaryPic.Length); + + /* Remove extension from file name */ + strncpy(name, DecodeUnicodeString(Bitmap->Name), 50); + if ((dot = strrchr(name, '.')) != NULL) + *dot = 0; + + sprintf(req, "AT+IMGW=0,\"%s\",2,0,0,0,0,100,%d,%u\r", name, + Bitmap->BinaryPic.Length, (unsigned int)crc); + + error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00); + if (error!=ERR_NONE) return error; + + return SetSamsungFrame(s, Bitmap->BinaryPic.Buffer, + Bitmap->BinaryPic.Length, ID_SetBitmap); +} + +/* + * Ringtones + */ + +GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; + unsigned char buffer[32]; + char *pos; + int location, length, count; + + switch (Priv->ReplyState) { + case AT_Reply_OK: + smprintf(s, "Ringtone info received\n"); + /* Parse +MELR:location,name,size */ + + /* Parse location */ + pos = strchr(msg.Buffer, ':'); + if (!pos) return ERR_UNKNOWN; + pos++; + location = atoi(pos); + smprintf(s, "Location : %d\n", location); + + /* Parse name */ + pos = strchr(pos, '"'); + if (!pos) return ERR_UNKNOWN; + pos++; + /* Ringtone.Name size is 20 chars */ + for (count = 0; count < 19; count++) { + if (pos[count] == '"') + break; + buffer[count] = pos[count]; + } + buffer[count] = 0; + smprintf(s, "Name : %s\n", buffer); + EncodeUnicode(s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); + + /* Parse ringtone length */ + pos = strchr(pos, ','); + if (!pos) return ERR_UNKNOWN; + pos++; + length = atoi(pos); + smprintf(s, "Length : %d\n", length); + + /* S300 ringtones are always MMF */ + s->Phone.Data.Ringtone->Format = RING_MMF; + s->Phone.Data.Ringtone->Location = location; + s->Phone.Data.Ringtone->BinaryTone.Length = length; + + return ERR_NONE; + case AT_Reply_Error: + return ERR_UNKNOWN; + case AT_Reply_CMSError: + return ATGEN_HandleCMSError(s); + case AT_Reply_CMEError: + return ATGEN_HandleCMEError(s); + default: + return ERR_UNKNOWNRESPONSE; + } +} + +GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) +{ + unsigned char req[100]; + + s->Phone.Data.Ringtone = Ringtone; + smprintf(s, "Getting ringtone\n"); + sprintf(req, "AT+MELR=%d\r", Ringtone->Location-1); + return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); +} + +GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + smprintf(s, "Ringtone sent\n"); + return ReplySetSamsungFrame(msg, s); +} + +GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) +{ + unsigned char req[100]; + unsigned long crc; + GSM_Error error; + char name[50], *dot; + + s->Phone.Data.Ringtone = Ringtone; + smprintf(s, "Setting ringtone\n"); + + if (Ringtone->Format != RING_MMF) { + smprintf(s, "Not MMF ringtone\n"); + return ERR_INVALIDDATA; + } + + /* Remove extension from file name */ + strncpy(name, DecodeUnicodeString(Ringtone->Name), 50); + if ((dot = strrchr(name, '.')) != NULL) *dot = 0; + + crc = GetCRC(Ringtone->BinaryTone.Buffer, Ringtone->BinaryTone.Length); + sprintf(req, "AT+MELW=0,\"%s\",4,%d,%u\r", name, + Ringtone->BinaryTone.Length, (unsigned int)crc); + + error = s->Protocol.Functions->WriteMessage(s, req, strlen(req), 0x00); + if (error!=ERR_NONE) return error; + + return SetSamsungFrame(s, Ringtone->BinaryTone.Buffer, + Ringtone->BinaryTone.Length, ID_SetRingtone); +} + +#endif diff --git a/gammu/emb/common/phone/at/samsung.h b/gammu/emb/common/phone/at/samsung.h new file mode 100644 index 0000000..3b2947c --- a/dev/null +++ b/gammu/emb/common/phone/at/samsung.h @@ -0,0 +1,16 @@ +#ifndef samsung_h +#define samsung_h + +#include "../../gsmstate.h" + +GSM_Error SAMSUNG_ReplyGetRingtone (GSM_Protocol_Message, GSM_StateMachine *); +GSM_Error SAMSUNG_ReplySetRingtone (GSM_Protocol_Message, GSM_StateMachine *); +GSM_Error SAMSUNG_ReplyGetBitmap (GSM_Protocol_Message, GSM_StateMachine *); +GSM_Error SAMSUNG_ReplySetBitmap (GSM_Protocol_Message, GSM_StateMachine *); +GSM_Error SAMSUNG_GetRingtone (GSM_StateMachine *, GSM_Ringtone *, bool); +GSM_Error SAMSUNG_SetRingtone (GSM_StateMachine *, GSM_Ringtone *, int *); +GSM_Error SAMSUNG_GetBitmap (GSM_StateMachine *, GSM_Bitmap *); +GSM_Error SAMSUNG_SetBitmap (GSM_StateMachine *, GSM_Bitmap *); +GSM_Error SAMSUNG_GetCallLogs (GSM_StateMachine *, GSM_MemoryEntry *, int); + +#endif diff --git a/gammu/emb/common/phone/at/siemens.c b/gammu/emb/common/phone/at/siemens.c index ab7dd2c..7f66cf8 100644 --- a/gammu/emb/common/phone/at/siemens.c +++ b/gammu/emb/common/phone/at/siemens.c @@ -1,320 +1,316 @@ /* (c) 2002-2003 by Walek */ #include "../../gsmstate.h" #ifdef GSM_ENABLE_ATGEN #include <string.h> #include <time.h> #include <ctype.h> #include "../../misc/coding/coding.h" #include "../../gsmcomon.h" #include "../../service/sms/gsmsms.h" #include "../pfunc.h" -extern GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s); +#include "atgen.h" +#include "siemens.h" -GSM_Error ATGEN_CMS35ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function) -{ - if (s->Protocol.Data.AT.EditMode) { - s->Protocol.Data.AT.EditMode = false; - return ERR_NONE; - } - dbgprintf ("Written %s",function); - if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){ - dbgprintf (" - OK\n"); - return ERR_NONE; - } else { - dbgprintf (" - error\n"); - return ERR_UNKNOWN; - } -} -GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, +static GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *templ, unsigned char *buffer, int *len) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; int i=2, pos=0, length=0; unsigned char buf[512]; if (strstr(GetLineString(msg.Buffer,Priv->Lines,2),"OK")) return ERR_EMPTY; if (!strstr(GetLineString(msg.Buffer,Priv->Lines,2),templ)) return ERR_UNKNOWN; while (1) { if (Priv->Lines.numbers[i*2+1]==0) break; if ((!strstr(GetLineString(msg.Buffer,Priv->Lines,i+1),templ)) && (strstr(GetLineString(msg.Buffer,Priv->Lines,i),templ))){ length = strlen(GetLineString(msg.Buffer,Priv->Lines,i+1)); DecodeHexBin(buf, GetLineString(msg.Buffer,Priv->Lines,i+1),length); length = length/2; memcpy (buffer+pos,buf,length); pos+=length; } i++; } *len = pos; return ERR_NONE; } -GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, +static GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ, int Location, GSM_Phone_RequestID RequestID, int len) { GSM_Phone_Data *Phone = &s->Phone.Data; GSM_Error error; unsigned char req[20],req1[512],hexreq[2096]; int MaxFrame,CurrentFrame,size,sz,pos=0; EncodeHexBin(hexreq,buff,len); size = len * 2; MaxFrame = size / 352; if (size % 352) MaxFrame++; for (CurrentFrame=0;CurrentFrame<MaxFrame;CurrentFrame++) { pos=CurrentFrame*352; if (pos+352 < size) sz = 352; else sz = size - pos; sprintf(req, "AT^SBNW=\"%s\",%i,%i,%i\r",templ,Location,CurrentFrame+1,MaxFrame); s->Protocol.Data.AT.EditMode = true; error = GSM_WaitFor (s, req, strlen(req), 0x00, 3, RequestID); s->Phone.Data.DispatchError=ERR_TIMEOUT; s->Phone.Data.RequestID=RequestID; if (error!=ERR_NONE) return error; memcpy (req1,hexreq+pos,sz); error = s->Protocol.Functions->WriteMessage(s, req1, sz, 0x00); if (error!=ERR_NONE) return error; error = s->Protocol.Functions->WriteMessage(s,"\x1A", 1, 0x00); if (error!=ERR_NONE) return error; error = GSM_WaitForOnce(s, NULL, 0x00, 0x00, 4); if (error == ERR_TIMEOUT) return error; } return Phone->DispatchError; } -GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) { unsigned char buffer[4096]; int length; GSM_Error error; error = GetSiemensFrame(msg,s,"bmp",buffer,&length); if (error!=ERR_NONE) return error; dbgprintf ("Operator logo received lenght=%i\n",length); error = BMP2Bitmap (buffer,NULL,s->Phone.Data.Bitmap); if (error==ERR_NONE) return error; else return ERR_UNKNOWN; } -GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplySetFunction (GSM_Protocol_Message msg, GSM_StateMachine *s,char *function) { - return ATGEN_CMS35ReplySetFunction (msg, s, "Operator Logo");
+ if (s->Protocol.Data.AT.EditMode) { + s->Protocol.Data.AT.EditMode = false; + return ERR_NONE; + } + dbgprintf ("Written %s",function); + if (s->Phone.Data.Priv.ATGEN.ReplyState == AT_Reply_OK){ + dbgprintf (" - OK\n"); + return ERR_NONE; + } else { + dbgprintf (" - error\n"); + return ERR_UNKNOWN; + } } -GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +GSM_Error SIEMENS_ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + return SIEMENS_ReplySetFunction (msg, s, "Operator Logo");
+} + +GSM_Error SIEMENS_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) { unsigned char req[32]; - if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; if (Bitmap->Location-1 < 0) Bitmap->Location++; s->Phone.Data.Bitmap=Bitmap; sprintf(req, "AT^SBNR=\"bmp\",%i\r", Bitmap->Location-1); smprintf(s, "Getting Bitmap\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetBitmap); } -GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) +GSM_Error SIEMENS_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) { unsigned char buffer[4096]; int length; GSM_Error error; - if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; if (Bitmap->Type!=GSM_OperatorLogo) return ERR_NOTSUPPORTED; error = Bitmap2BMP (buffer,NULL,Bitmap); if (error!=ERR_NONE) return error; length = 0x100 * buffer[3] + buffer[2]; buffer[58]=0xff; buffer[59]=0xff; buffer[60]=0xff; if (Bitmap->Location-1 < 0) Bitmap->Location++; s->Phone.Data.Bitmap=Bitmap; return SetSiemensFrame(s, buffer,"bmp",Bitmap->Location-1, ID_SetBitmap,length); } -GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) { unsigned char buffer[32]; int length; GSM_Error error; error = GetSiemensFrame(msg,s,"mid",s->Phone.Data.Ringtone->NokiaBinary.Frame,&length); if (error!=ERR_NONE) return error; dbgprintf ("Midi ringtone received\n"); s->Phone.Data.Ringtone->Format = RING_MIDI; s->Phone.Data.Ringtone->NokiaBinary.Length = length; sprintf(buffer,"Individual"); EncodeUnicode (s->Phone.Data.Ringtone->Name,buffer,strlen(buffer)); return ERR_NONE; } -GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) +GSM_Error SIEMENS_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) { unsigned char req[32]; - if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; - s->Phone.Data.Ringtone=Ringtone; sprintf(req, "AT^SBNR=\"mid\",%i\r", Ringtone->Location-1); smprintf(s, "Getting RingTone\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetRingtone); } -GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s) { - return ATGEN_CMS35ReplySetFunction (msg, s, "Ringtone"); + return SIEMENS_ReplySetFunction (msg, s, "Ringtone"); } -GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) +GSM_Error SIEMENS_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength) { GSM_Phone_Data *Phone = &s->Phone.Data; - if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; - if (Ringtone->Location==255) Ringtone->Location=1; if (Ringtone->Location-1 > 1) return ERR_INVALIDLOCATION; s->Phone.Data.Ringtone = Ringtone; Phone->Ringtone = Ringtone; return SetSiemensFrame(s, Ringtone->NokiaBinary.Frame,"mid",Ringtone->Location-1, ID_SetRingtone,Ringtone->NokiaBinary.Length); } -GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; GSM_CalendarEntry *Calendar = Data->Cal; GSM_ToDoEntry ToDo; GSM_Error error; unsigned char buffer[354]; int len, pos=0; if (Data->Priv.ATGEN.ReplyState != AT_Reply_OK) return ERR_UNKNOWN; error = GetSiemensFrame(msg,s,"vcs",buffer,&len); if (error!=ERR_NONE) return error; error=GSM_DecodeVCALENDAR_VTODO(buffer,&pos,Calendar,&ToDo,Siemens_VCalendar,0); return error; } GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; unsigned char req[32]; int Location; if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; if (start) Note->Location=Priv->FirstCalendarPos; s->Phone.Data.Cal = Note; Note->EntriesNum = 0; smprintf(s, "Getting VCALENDAR\n"); Location = Note->Location; while (1){ Location++; sprintf(req, "AT^SBNR=\"vcs\",%i\r",Location); error = GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_GetCalendarNote); if ((error!=ERR_NONE) && (error!=ERR_EMPTY)) return ERR_INVALIDLOCATION; Note->Location = Location; Priv->FirstCalendarPos = Location; if (Location > MAX_VCALENDAR_LOCATION) return ERR_EMPTY; if (error==ERR_NONE) return error; } return error; } -GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyAddCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s) { - return ATGEN_CMS35ReplySetFunction (msg, s, "Calendar Note"); + return SIEMENS_ReplySetFunction (msg, s, "Calendar Note"); } -GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyDelCalendarNote(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; if (Data->Cal->Location > MAX_VCALENDAR_LOCATION) return ERR_UNKNOWN; if (Data->Priv.ATGEN.ReplyState== AT_Reply_OK) { smprintf(s, "Calendar note deleted\n"); return ERR_NONE; } else { smprintf(s, "Can't delete calendar note\n"); return ERR_UNKNOWN; } } GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { unsigned char req[32]; if (s->Phone.Data.Priv.ATGEN.Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; s->Phone.Data.Cal = Note; sprintf(req, "AT^SBNW=\"vcs\",%i,0\r",Note->Location); smprintf(s, "Deleting calendar note\n"); return GSM_WaitFor (s, req, strlen(req), 0x00, 4, ID_DeleteCalendarNote); } GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; unsigned char req[500]; int size=0; if (Priv->Manufacturer!=AT_Siemens) return ERR_NOTSUPPORTED; // if (Note->Location==0x00) return ERR_INVALIDLOCATION; s->Phone.Data.Cal = Note; error=GSM_EncodeVCALENDAR(req,&size,Note,true,Siemens_VCalendar); return SetSiemensFrame (s,req,"vcs",Note->Location,ID_SetCalendarNote,size); } /* (c) by Timo Teras */ -GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) +GSM_Error SIEMENS_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) { #ifndef ENABLE_LGPL GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_MemoryEntry *Memory = s->Phone.Data.Memory; unsigned char buffer[500],buffer2[500]; switch (Priv->ReplyState) { case AT_Reply_OK: smprintf(s, "Phonebook entry received\n"); CopyLineString(buffer, msg.Buffer, Priv->Lines, 3); DecodeHexBin(buffer2,buffer,strlen(buffer)); Memory->EntriesNum = 0; DecodeVCARD21Text(buffer2, Memory); if (Memory->EntriesNum == 0) return ERR_EMPTY; return ERR_NONE; case AT_Reply_Error: smprintf(s, "Error - too high location ?\n"); return ERR_INVALIDLOCATION; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); default: break; } return ERR_UNKNOWNRESPONSE; #else return ERR_NOTIMPLEMENTED; #endif } #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/at/sonyeric.c b/gammu/emb/common/phone/at/sonyeric.c index 4b2670a..8eeb39b 100644 --- a/gammu/emb/common/phone/at/sonyeric.c +++ b/gammu/emb/common/phone/at/sonyeric.c @@ -1,72 +1,70 @@ /* (c) 2003 by Marcin Wiacek */ #include "../../gsmstate.h" #ifdef GSM_ENABLE_ATGEN #include <string.h> #include <time.h> #include <ctype.h> #include "../../gsmcomon.h" #include "../../misc/coding/coding.h" -extern GSM_Reply_Function ATGENReplyFunctions[]; -extern GSM_Error ATGEN_DispatchMessage (GSM_StateMachine *s); +#include "atgen.h" +#include "sonyeric.h" #ifdef GSM_ENABLE_OBEXGEN -extern GSM_Reply_Function OBEXGENReplyFunctions[]; -extern GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File); -extern GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos); -extern GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s); +#include "../obex/obexgen.h" -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +extern GSM_Reply_Function OBEXGENReplyFunctions[]; +extern GSM_Reply_Function ATGENReplyFunctions[]; static GSM_Error SONYERIC_SetOBEXMode(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; if (Priv->OBEX) return ERR_NONE; dbgprintf ("Changing to OBEX\n"); error=GSM_WaitFor (s, "AT*EOBEX\r", 9, 0x00, 4, ID_SetOBEX); if (error != ERR_NONE) return error; error = s->Protocol.Functions->Terminate(s); if (error != ERR_NONE) return error; s->Protocol.Functions = &OBEXProtocol; error = s->Protocol.Functions->Initialise(s); if (error != ERR_NONE) { s->Protocol.Functions = &ATProtocol; return error; } strcpy(s->CurrentConfig->Model,"seobex"); s->Phone.Data.Priv.OBEXGEN.Service = 0; s->Phone.Functions->DispatchMessage = GSM_DispatchMessage; s->Phone.Functions->ReplyFunctions = OBEXGENReplyFunctions; Priv->OBEX = true; return ERR_NONE; } static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s) { GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; GSM_Error error; if (!Priv->OBEX) return ERR_NONE; dbgprintf ("Changing to AT\n"); error = OBEXGEN_Disconnect(s); if (error != ERR_NONE) return error; error = s->Protocol.Functions->Terminate(s); if (error != ERR_NONE) return error; s->Protocol.Functions = &ATProtocol; error = s->Protocol.Functions->Initialise(s); if (error != ERR_NONE) { @@ -81,331 +79,442 @@ static GSM_Error SONYERIC_SetATMode(GSM_StateMachine *s) } static GSM_Error SONYERIC_GetFile(GSM_StateMachine *s, GSM_File *File, unsigned char *FileName) { GSM_Error error; strcpy(File->ID_FullName,FileName); File->Used = 0; if (File->Buffer != NULL) free(File->Buffer); File->Buffer = NULL; error = SONYERIC_SetOBEXMode(s); if (error != ERR_NONE) return error; error = ERR_NONE; while (error == ERR_NONE) error = OBEXGEN_GetFilePart(s,File); if (error != ERR_EMPTY) return error; return SONYERIC_SetATMode(s); } static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, unsigned char *Buffer, int Length) { GSM_Error error; GSM_File File; int Pos = 0; error = SONYERIC_SetOBEXMode(s); if (error != ERR_NONE) return error; strcpy(File.ID_FullName,FileName); EncodeUnicode(File.Name,FileName,strlen(FileName)); File.Used = Length; File.Buffer = malloc(Length); memcpy(File.Buffer,Buffer,Length); error = ERR_NONE; while (error == ERR_NONE) error = OBEXGEN_AddFilePart(s,&File,&Pos); free(File.Buffer); if (error != ERR_EMPTY) return error; return SONYERIC_SetATMode(s); } #endif GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; GSM_ToDoEntry ToDo; int Pos, num, Loc; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (start) { error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; Note->Location = 1; } else { Note->Location++; } smprintf(s, "Getting calendar note %i\n",Note->Location); Loc = Note->Location; Pos = 0; num = 0; while (1) { error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, Note, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); if (error == ERR_EMPTY) break; if (error != ERR_NONE) return error; if (Note->EntriesNum != 0) { num++; if (num == Loc) return ERR_NONE; } } return ERR_EMPTY; #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; GSM_CalendarEntry Calendar; int Pos, num, Loc; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; if (start) { error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; ToDo->Location = 1; } else { ToDo->Location++; } smprintf(s,"Getting ToDo %i\n",ToDo->Location); Loc = ToDo->Location; Pos = 0; num = 0; while (1) { error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); if (error == ERR_EMPTY) break; if (error != ERR_NONE) return error; if (ToDo->EntriesNum != 0) { num++; if (num == Loc) return ERR_NONE; } } return ERR_EMPTY; #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; GSM_ToDoEntry ToDo; GSM_CalendarEntry Calendar; int Pos; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; smprintf(s,"Getting ToDo status\n"); error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; status->Used = 0; Pos = 0; while (1) { error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); if (error == ERR_EMPTY) break; if (error != ERR_NONE) return error; if (ToDo.EntriesNum != 0) status->Used++; } return ERR_NONE; #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN unsigned char req[5000]; int size=0; smprintf(s,"Adding calendar note\n"); GSM_EncodeVCALENDAR(req,&size,Note,true,SonyEricsson_VCalendar); return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; unsigned char req[5000]; int size=0; if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; smprintf(s,"Adding ToDo\n"); GSM_EncodeVTODO(req,&size,ToDo,true,SonyEricsson_VToDo); return SONYERIC_SetFile(s, "telecom/cal/luid/.vcs", req, size); #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; int Pos,Level = 0,Used; unsigned char *Buf; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; unsigned char Line[2000]; if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; smprintf(s,"Deleting all ToDo\n"); error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; Pos = 0; Buf = NULL; Used = 0; while (1) { MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); if (strlen(Line) == 0) break; dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); switch (Level) { case 0: if (strstr(Line,"BEGIN:VTODO")) { Level = 2; break; } Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); strcpy(Buf+Used,Line); Used=Used+strlen(Line)+3; Buf[Used-3] = 13; Buf[Used-2] = 10; Buf[Used-1] = 0x00; break; case 2: /* ToDo note */ if (strstr(Line,"END:VTODO")) { Level = 0; } break; } } error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); // if (Buf != NULL) free(Buf); return error; #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; int Pos,Level = 0,Loc=0,Used; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; unsigned char Line[2000]; unsigned char *Buf; smprintf(s, "Deleting calendar note %i\n",Note->Location); error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; Pos = 0; Buf = NULL; Used = 0; while (1) { MyGetLine(Priv->file.Buffer, &Pos, Line, Priv->file.Used); if (strlen(Line) == 0) break; dbgprintf("Line is %s,%i,%i\n",Line,Priv->file.Used,Pos); switch (Level) { case 0: if (strstr(Line,"BEGIN:VEVENT")) { Loc++; if (Loc == Note->Location) { Level = 1; break; } } Buf=(unsigned char *)realloc(Buf,Used+strlen(Line)+3); strcpy(Buf+Used,Line); Used=Used+strlen(Line)+3; Buf[Used-3] = 13; Buf[Used-2] = 10; Buf[Used-1] = 0x00; break; case 1: /* Calendar note */ if (strstr(Line,"END:VEVENT")) { Level = 0; } break; } } DumpMessage(s->di.df, s->di.dl, Buf, Used); error = SONYERIC_SetFile(s, "telecom/cal.vcs", Buf, Used); if (Buf != NULL) free(Buf); return error; #else return ERR_SOURCENOTAVAILABLE; #endif } GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) { -#if defined(GSM_ENABLE_BLUEOBEX) || defined(GSM_ENABLE_IRDAOBEX) +#ifdef GSM_ENABLE_OBEXGEN GSM_Error error; GSM_ToDoEntry ToDo; GSM_CalendarEntry Calendar; int Pos; GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN; if (Priv->Manufacturer!=AT_Ericsson) return ERR_NOTSUPPORTED; smprintf(s, "Getting calendar status\n"); error = SONYERIC_GetFile(s, &Priv->file, "telecom/cal.vcs"); if (error != ERR_NONE) return error; Status->Used = 0; Pos = 0; while (1) { error = GSM_DecodeVCALENDAR_VTODO(Priv->file.Buffer, &Pos, &Calendar, &ToDo, SonyEricsson_VCalendar, SonyEricsson_VToDo); if (error == ERR_EMPTY) break; if (error != ERR_NONE) return error; if (Calendar.EntriesNum != 0) Status->Used++; } return ERR_NONE; #else return ERR_SOURCENOTAVAILABLE; #endif } -#endif +GSM_Error ERICSSON_ReplyGetDateLocale(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ /* Author: Peter Ondraska, based on code by Marcin Wiacek and Michal Cihar + License: Whatever the current maintainer of gammulib chooses, as long as there + is an easy way to obtain the source under GPL, otherwise the author's parts + of this function are GPL 2.0. + */ + GSM_Locale *locale = s->Phone.Data.Locale; + char format; + + switch (s->Phone.Data.Priv.ATGEN.ReplyState) { + case AT_Reply_OK: + smprintf(s, "Date settings received\n"); + format=atoi(msg.Buffer); + switch (format) { + case 0: locale->DateFormat = GSM_Date_OFF; + locale->DateSeparator = 0; + break; + case 1: locale->DateFormat = GSM_Date_DDMMMYY; + locale->DateSeparator = '-'; + break; + case 2: locale->DateFormat = GSM_Date_DDMMYY; + locale->DateSeparator = '-'; + break; + case 3: locale->DateFormat = GSM_Date_MMDDYY; + locale->DateSeparator = '/'; + break; + case 4: locale->DateFormat = GSM_Date_DDMMYY; + locale->DateSeparator = '/'; + break; + case 5: locale->DateFormat = GSM_Date_DDMMYY; + locale->DateSeparator = '.'; + break; + case 6: locale->DateFormat = GSM_Date_YYMMDD; + locale->DateSeparator = 0; + break; + case 7: locale->DateFormat = GSM_Date_YYMMDD; + locale->DateSeparator = '-'; + break; + default:return ERR_UNKNOWNRESPONSE; + } + default: + return ERR_NOTSUPPORTED; + } +} + +GSM_Error ERICSSON_ReplyGetTimeLocale(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ /* Author: Peter Ondraska + License: Whatever the current maintainer of gammulib chooses, as long as there + is an easy way to obtain the source under GPL, otherwise the author's parts + of this function are GPL 2.0. + */ + char format; + + switch (s->Phone.Data.Priv.ATGEN.ReplyState) { + case AT_Reply_OK: + smprintf(s, "Time settings received\n"); + format=atoi(msg.Buffer); + switch (format) { + case 1: + case 2: s->Phone.Data.Locale->AMPMTime=(format==2); + return ERR_NONE; + default:return ERR_UNKNOWNRESPONSE; + } + default: return ERR_NOTSUPPORTED; + } +} + +GSM_Error ERICSSON_GetLocale(GSM_StateMachine *s, GSM_Locale *locale) +{ + GSM_Error error; + + s->Phone.Data.Locale = locale; + + smprintf(s, "Getting date format\n"); + error=GSM_WaitFor (s, "AT+ESDF?\r", 9, 0x00, 3, ID_GetLocale); + if (error!=ERR_NONE) return error; + + smprintf(s, "Getting time format\n"); + return GSM_WaitFor (s, "AT+ESTF?\r", 9, 0x00, 3, ID_GetLocale); +} + + +GSM_Error ERICSSON_SetLocale(GSM_StateMachine *s, GSM_Locale *locale) +{ /* Author: Peter Ondraska + License: Whatever the current maintainer of gammulib chooses, as long as there + is an easy way to obtain the source under GPL, otherwise the author's parts + of this function are GPL 2.0. + */ + /* this is not yet supported by gammu.c */ + int format=0; + char req[12]; + + if (locale->DateFormat==GSM_Date_OFF) { format=0; } else + if ((locale->DateFormat==GSM_Date_DDMMMYY)&&(locale->DateSeparator=='-')) { format=1; } else + if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='-')) { format=2; } else + if ((locale->DateFormat==GSM_Date_MMDDYY)&&(locale->DateSeparator=='/')) { format=3; } else + if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='/')) { format=4; } else + if ((locale->DateFormat==GSM_Date_DDMMYY)&&(locale->DateSeparator=='.')) { format=5; } else + if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator==0)) { format=6; } else + if ((locale->DateFormat==GSM_Date_YYMMDD)&&(locale->DateSeparator=='-')) { format=7; } + else { return ERR_NOTSUPPORTED; } /* ERR_WRONGINPUT */ + + sprintf(req,"AT+ESDF=%i\r",format); + smprintf(s, "Setting date format\n"); + return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); + + if (locale->AMPMTime) { format=2; } else { format=1; } + sprintf(req,"AT+ESTF=%i\r",format); + smprintf(s, "Setting time format\n"); + return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetLocale); +} + #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c index beef33c..17cd0a4 100644 --- a/gammu/emb/common/phone/nokia/dct3/dct3func.c +++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c @@ -1,51 +1,54 @@ /* (c) 2001-2004 by Marcin Wiacek */ -/* based on some work from Markus Plail, Pavel Janik, others and Gnokii */ /* resetting DCT4 phones settings (c) by Walek */ +/* based on some Markus Plail, Pavel Janik & others 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 <string.h> /* memcpy only */ #include <stdio.h> #include <ctype.h> #include "../../../gsmstate.h" #include "../../../misc/coding/coding.h" #include "../../../service/sms/gsmsms.h" #include "../../pfunc.h" #include "../nfunc.h" #include "dct3func.h" #ifdef GSM_ENABLE_NOKIA_DCT3 GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) { GSM_Error error; /* We have to enable WAP frames in phone */ error=DCT3DCT4_EnableWAPFunctions(s); if (error!=ERR_NONE) return error; return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); } GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) { GSM_Error error; /* We have to enable WAP frames in phone */ error=DCT3DCT4_EnableWAPFunctions(s); if (error!=ERR_NONE) return error; return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); } GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; switch (msg.Buffer[2]) { case 0x46: smprintf(s, "Pressing key OK\n"); if (Data->PressKey) return ERR_NONE; break; case 0x47: smprintf(s, "Releasing key OK\n"); if (!Data->PressKey) return ERR_NONE; @@ -349,163 +352,164 @@ GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigne return GSM_WaitFor (s, req, 14, msgtype, 4, ID_SetDateTime); } GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Alarm: "); if (msg.Buffer[4]==0x01) { smprintf(s, "set OK\n"); return ERR_NONE; } smprintf(s, "error setting\n"); return ERR_UNKNOWN; } GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype) { unsigned char req[] = {N6110_FRAME_HEADER, 0x6b, 0x01, 0x20, 0x03, 0x02, /* Unknown. Not for enabling/disabling */ 0x00, /* Hour */ 0x00, /* Minute */ 0x00}; /* Unknown. Not seconds */ if (alarm->Location != 1) return ERR_NOTSUPPORTED; req[8] = alarm->DateTime.Hour; req[9] = alarm->DateTime.Minute; smprintf(s, "Setting alarm\n"); return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm); } GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) { int i; GSM_Phone_Data *Data = &s->Phone.Data; switch (msg.Buffer[3]) { case 0x34: smprintf(s, "SMSC received\n"); Data->SMSC->Format = SMS_FORMAT_Text; switch (msg.Buffer[6]) { case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager; break; case 0x32: Data->SMSC->Format = SMS_FORMAT_Email; break; } Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; Data->SMSC->Validity.Relative = msg.Buffer[8]; + if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time; i=33; while (msg.Buffer[i]!=0) {i++;} i=i-33; if (i>GSM_MAX_SMSC_NAME_LENGTH) { smprintf(s, "Too long name\n"); return ERR_UNKNOWNRESPONSE; } EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false); smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); return ERR_NONE; case 0x35: smprintf(s, "Getting SMSC failed\n"); return ERR_INVALIDLOCATION; } return ERR_UNKNOWNRESPONSE; } GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) { unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64, 0x00}; /* Location */ if (smsc->Location==0x00) return ERR_INVALIDLOCATION; req[5]=smsc->Location; s->Phone.Data.SMSC=smsc; smprintf(s, "Getting SMSC\n"); return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); } GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { int count; GSM_Phone_Data *Data = &s->Phone.Data; #ifdef DEBUG GSM_NetworkInfo NetInfo; char name[100]; smprintf(s, "Network info received\n"); smprintf(s, " Status : "); switch (msg.Buffer[8]) { case 0x01: smprintf(s, "home network"); break; case 0x02: smprintf(s, "roaming network"); break; case 0x03: smprintf(s, "requesting network"); break; case 0x04: smprintf(s, "not registered in the network"); break; default : smprintf(s, "unknown"); } smprintf(s, "\n"); smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); if (msg.Buffer[8]<0x03) { sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); smprintf(s, "CID : %s\n", NetInfo.CID); sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); smprintf(s, "LAC : %s\n", NetInfo.LAC); - smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); + smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); smprintf(s, "Network name for Gammu : %s ", DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); if (msg.Length>18) { if (msg.Buffer[18]==0x00) { /* In 6210 name is in "normal" Unicode */ memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); name[msg.Buffer[17]*2] =0x00; name[msg.Buffer[17]*2+1]=0x00; smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); } else { /* In 9210 first 0x00 is cut from Unicode string */ name[0] = 0; memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2); name[msg.Buffer[17]*2+1]=0x00; name[msg.Buffer[17]*2+2]=0x00; smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); } } } #endif if (Data->RequestID==ID_GetNetworkInfo) { Data->NetworkInfo->NetworkName[0] = 0x00; Data->NetworkInfo->NetworkName[1] = 0x00; Data->NetworkInfo->State = 0; switch (msg.Buffer[8]) { case 0x01: Data->NetworkInfo->State = GSM_HomeNetwork; break; case 0x02: Data->NetworkInfo->State = GSM_RoamingNetwork; break; case 0x03: Data->NetworkInfo->State = GSM_RequestingNetwork; break; case 0x04: Data->NetworkInfo->State = GSM_NoNetwork; break; } if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { if (msg.Buffer[18]==0x00) { /* In 6210 name is in "normal" Unicode */ memcpy(Data->NetworkInfo->NetworkName,msg.Buffer+18,msg.Buffer[17]*2); Data->NetworkInfo->NetworkName[msg.Buffer[17]*2] = 0x00; Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1] = 0x00; } else { /* In 9210 first 0x00 is cut from Unicode string */ Data->NetworkInfo->NetworkName[0] = 0; memcpy(Data->NetworkInfo->NetworkName+1,msg.Buffer+18,msg.Buffer[17]*2); Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+1]=0x00; Data->NetworkInfo->NetworkName[msg.Buffer[17]*2+2]=0x00; } NOKIA_DecodeNetworkCode(msg.Buffer+14,Data->NetworkInfo->NetworkCode); sprintf(Data->NetworkInfo->CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); sprintf(Data->NetworkInfo->LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); @@ -1163,101 +1167,101 @@ GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *setting SetReq2[pos++] = 0x02; SetReq2[pos++] = 0x00; /* SMS */ if (loc2 != -1) { /* Service number */ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Service, false); /* Server number */ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc2].Server, false); } else pos += 2; memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); pos += 8; smprintf(s, "Writing WAP settings part 2 (SMS bearer)\n"); error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); if (error != ERR_NONE) return error; } /* USSD */ if (phone3 != -1) { pos = 4; memset(SetReq2 + pos, 0, 200 - pos); SetReq2[pos++] = phone3; SetReq2[pos++] = 0x02; SetReq2[pos++] = 0x02; /* USSD */ if (loc3 != -1) { if (!settings->Settings[loc3].IsIP) SetReq2[pos] = 0x01; } pos++; if (loc3 != -1) { /* Service number or IP address */ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false); /* Code number */ pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false); } else pos+=2; memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); pos += 8; smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n"); error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); if (error != ERR_NONE) return error; } error = DCT3DCT4_SetActiveConnectSet(s, settings); if (error != ERR_NONE) return error; return DCT3DCT4_DisableConnectionFunctions(s); } GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x02: smprintf(s, "SMS sent OK\n"); - if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); + if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]); return ERR_NONE; case 0x03: smprintf(s, "Error %i\n",msg.Buffer[6]); - if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0); + if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1); return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) { int length; GSM_Error error; unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00}; error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true); if (error != ERR_NONE) return error; smprintf(s, "Sending sms\n"); return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02); } GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x00: smprintf(s, "Netmonitor correctly set\n"); break; default: smprintf(s, "Menu %i\n",msg.Buffer[3]); smprintf(s, "%s\n",msg.Buffer+4); strcpy(s->Phone.Data.Netmonitor,msg.Buffer+4); break; } return ERR_NONE; } GSM_Error DCT3_Netmonitor(GSM_StateMachine *s, int testnumber, char *value) { GSM_Error error; unsigned char req[] = {0x00, 0x01, 0x7e, 0x00}; /* Test number */ value[0] = 0; error=DCT3_EnableSecurity (s, 0x01); if (error != ERR_NONE) return error; req[3] = testnumber; smprintf(s, "Getting netmonitor test\n"); s->Phone.Data.Netmonitor = value; diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.h b/gammu/emb/common/phone/nokia/dct3/dct3func.h index 66b67ec..18b2026 100644 --- a/gammu/emb/common/phone/nokia/dct3/dct3func.h +++ b/gammu/emb/common/phone/nokia/dct3/dct3func.h @@ -1,53 +1,55 @@ /* (c) 2002-2003 by Marcin Wiacek */ #ifndef phone_nokia_dct3_h #define phone_nokia_dct3_h +#include "../ncommon.h" + GSM_Error DCT3_ReplyPressKey (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyPlayTone (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyEnableSecurity (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetIMEI (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySIMLogin (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySIMLogout (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySetDateTime (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySetAlarm (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyDialCommand (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetWAPBookmark (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetNetworkInfo (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySendSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySetSMSC (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyGetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplySetWAPSettings (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyNetmonitor (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyDeleteSMSMessage (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error N71_92_ReplyGetSignalQuality (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error N71_92_ReplyGetBatteryCharge (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error N71_92_ReplyPhoneSetting (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error N61_91_ReplySetOpLogo (GSM_Protocol_Message msg, GSM_StateMachine *s); #ifdef GSM_ENABLE_CELLBROADCAST GSM_Error DCT3_ReplySetIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s); GSM_Error DCT3_ReplyIncomingCB (GSM_Protocol_Message msg, GSM_StateMachine *s); #endif GSM_Error DCT3_DeleteWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); GSM_Error DCT3_GetWAPBookmark (GSM_StateMachine *s, GSM_WAPBookmark *bookmark); GSM_Error DCT3_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, bool Press); GSM_Error DCT3_PlayTone (GSM_StateMachine *s, int Herz, unsigned char Volume, bool start); GSM_Error DCT3_EnableSecurity (GSM_StateMachine *s, unsigned char status ); GSM_Error DCT3_GetIMEI (GSM_StateMachine *s); GSM_Error DCT3_GetSMSC (GSM_StateMachine *s, GSM_SMSC *smsc ); GSM_Error DCT3_GetNetworkInfo (GSM_StateMachine *s, GSM_NetworkInfo *netinfo ); GSM_Error DCT3_DialVoice (GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber); GSM_Error DCT3_Reset (GSM_StateMachine *s, bool hard ); GSM_Error DCT3_CancelCall (GSM_StateMachine *s, int ID, bool all); GSM_Error DCT3_AnswerAllCalls (GSM_StateMachine *s); GSM_Error DCT3_SendSMSMessage (GSM_StateMachine *s, GSM_SMSMessage *sms ); GSM_Error DCT3_GetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype); GSM_Error DCT3_GetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype ); GSM_Error DCT3_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msgtype); GSM_Error DCT3_SetDateTime (GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype ); GSM_Error DCT3_SetIncomingCB (GSM_StateMachine *s, bool enable ); diff --git a/gammu/emb/common/phone/nokia/dct3/n6110.c b/gammu/emb/common/phone/nokia/dct3/n6110.c index 263d12b..dac6c12 100644 --- a/gammu/emb/common/phone/nokia/dct3/n6110.c +++ b/gammu/emb/common/phone/nokia/dct3/n6110.c @@ -1,52 +1,54 @@ /* (c) 2001-2004 by Marcin Wiacek */ -/* based on some work from Markus Plail and Gnokii */ -/* Authentication function (c) 1999 or earlier by Pavel Janik */ /* 5210 calendar IDs by Frederick Ros */ +/* based on some Markus Plail, Pavel Janik & others 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_NOKIA6110 #include <string.h> #include "../../../../cfg/config.h" #include "../../../misc/coding/coding.h" #include "../../../service/sms/gsmsms.h" #include "../../../gsmcomon.h" #include "../../pfunc.h" #include "../nfunc.h" #include "n6110.h" #include "dct3func.h" static unsigned char N6110_MEMORY_TYPES[] = { MEM_ME, 0x02, MEM_SM, 0x03, MEM_ON, 0x05, MEM_DC, 0x07, MEM_RC, 0x08, MEM_MC, 0x09, MEM_VM, 0x0b, 0x00, 0x00 }; static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message msg, GSM_StateMachine *s) { N6110_Language lang = N6110_Auto; if (msg.Buffer[3] == 0x15) return ERR_NONE; smprintf(s, "Phone language is %02x\n",msg.Buffer[6]); switch (msg.Buffer[6]) { case 0x21: lang = N6110_Europe; break; //Polish } s->Phone.Data.Priv.N6110.PhoneLanguage = lang; return ERR_NONE; } static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s) { unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01, 0x00, /* Profile location */ 0x00}; /* Feature number */ s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto; @@ -82,96 +84,97 @@ static struct N6110_Lang_Char N6110_Lang_Table[] = { {N6110_Europe,0x93,0x01,0x44},//Latin small letter n with acute {N6110_Europe,0x9A,0x00,0xF3},//Latin small letter o with acute {N6110_Europe,0xB2,0x20,0xAC},//euro {N6110_Europe,0xB5,0x01,0x5A},//Latin capital letter s with acute {N6110_Europe,0xB6,0x01,0x5B},//Latin small letter s with acute {N6110_Europe,0xE7,0x01,0x79},//Latin capital letter z with acute {N6110_Europe,0xEE,0x01,0x7A},//Latin small letter z with acute {N6110_Europe,0xF4,0x01,0x7C},//Latin small letter z with dot above {N6110_Europe,0xF0,0x01,0x7B},//Latin capital letter z with dot above {0,0,0,0} }; static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len) { int i_len = 0, o_len, i; wchar_t wc; GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; bool found; for (o_len = 0; i_len < len; o_len++) { found = false; if (Priv->PhoneLanguage != N6110_Auto) { i = 0; while(1) { if (N6110_Lang_Table[i].Lang == 0) break; if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage && N6110_Lang_Table[i].Phone == src[i_len]) { dest[o_len*2] = N6110_Lang_Table[i].Unicode1; dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2; i_len++; found = true; break; } i++; } } if (!found) { i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc); dest[o_len*2] = (wc >> 8) & 0xff; dest[(o_len*2)+1] = wc & 0xff; } } dest[o_len*2] = 0; dest[(o_len*2)+1] = 0; } #ifndef ENABLE_LGPL +/* Pavel Janik */ /* This function provides Nokia authentication protocol. * Nokia authentication protocol is used in the communication between Nokia * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software, * commercially sold by Nokia Corp. * The authentication scheme is based on the token send by the phone to the * software. The software does it's magic (see the function * N6110_GetNokiaAuthentication) and returns the result back to the phone. * If the result is correct the phone responds with the message "Accessory * connected!" displayed on the LCD. Otherwise it will display "Accessory not * supported" and some functions will not be available for use (?). * The specification of the protocol is not publicly available, no comment. */ static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse) { int i, j, CRC=0; unsigned char Temp[16]; /* This is our temporary working area. */ /* Here we put FAC (Final Assembly Code) and serial number into our area. */ Temp[0] = Imei[6]; Temp[1] = Imei[7]; Temp[2] = Imei[8]; Temp[3] = Imei[9]; Temp[4] = Imei[10]; Temp[5] = Imei[11]; Temp[6] = Imei[12]; Temp[7] = Imei[13]; /* And now the TAC (Type Approval Code). */ Temp[8] = Imei[2]; Temp[9] = Imei[3]; Temp[10] = Imei[4]; Temp[11] = Imei[5]; /* And now we pack magic bytes from the phone. */ Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1]; Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3]; for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1; switch (Temp[15] & 0x03) { case 1: case 2: j = Temp[13] & 0x07; for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12]; break; default: j = Temp[14] & 0x07; for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12]; } for (i=0; i<=15; i++) CRC ^= Temp[i]; for (i=0; i<=15; i++) { switch (Temp[15 - i] & 0x06) { case 0: j = Temp[i] | CRC; break; case 2: case 4: j = Temp[i] ^ CRC; break; case 6: j = Temp[i] & CRC; break; } @@ -779,96 +782,97 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, 0x00,0x78}; unsigned char reqBin[1000] = {0x00,0x01,0xa0,0x00,0x00,0x0c,0x01,0x2c}; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NORING)) return ERR_NOTSUPPORTED; if (Ringtone->Location == 0) return ERR_INVALIDLOCATION; switch (Ringtone->Format) { case RING_NOTETONE: if (Ringtone->Location==255) { /* Only 6110, 6130 and 6150 support it */ if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 || strcmp(s->Phone.Data.Model,"NSM-1") == 0) { req[0] = 0x0c; req[1] = 0x01; UDHHeader.Type = UDH_NokiaRingtone; GSM_EncodeUDHHeader(&UDHHeader); /* We copy UDH now */ memcpy(req+2,UDHHeader.Text,UDHHeader.Length); *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+2+UDHHeader.Length, &size); error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12); if (error!=ERR_NONE) return error; my_sleep(1000); /* We have to make something (not important, what) now */ /* no answer from phone*/ return DCT3_GetNetworkInfo(s,&NetInfo); } else { return ERR_NOTSUPPORTED; } } *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+7, &size); req[4] = Ringtone->Location - 1; smprintf(s, "Setting ringtone\n"); return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone); case RING_NOKIABINARY: error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name)); current += UnicodeLength(Ringtone->Name); reqBin[current++] = 0x00; reqBin[current++] = 0x00; reqBin[current++] = 0x00;/*xxx*/ memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length); current=current+Ringtone->NokiaBinary.Length; reqBin[3]=Ringtone->Location-1; if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10; smprintf(s, "Setting binary ringtone\n"); return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone); case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } return ERR_NOTSUPPORTED; } static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) { int count=5; GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Operator logo received\n"); NOKIA_DecodeNetworkCode(msg.Buffer+count,Data->Bitmap->NetworkCode); count = count + 3; smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode); smprintf(s, "Network name for Gammu : %s ", DecodeUnicodeString(GSM_GetNetworkName(Data->Bitmap->NetworkCode))); smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(Data->Bitmap->NetworkCode))); count = count + 3; /* We ignore size */ Data->Bitmap->BitmapWidth = msg.Buffer[count++]; Data->Bitmap->BitmapHeight = msg.Buffer[count++]; count++; PHONE_DecodeBitmap(GSM_NokiaOperatorLogo,msg.Buffer+count,Data->Bitmap); return ERR_NONE; } static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message msg, GSM_StateMachine *s) { int i, count = 5; GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Startup logo & notes received\n"); for (i=0;i<msg.Buffer[4];i++) { switch (msg.Buffer[count++]) { case 0x01: smprintf(s, "Startup logo\n"); if (Data->Bitmap->Type == GSM_StartupLogo) { Data->Bitmap->BitmapHeight = msg.Buffer[count++]; Data->Bitmap->BitmapWidth = msg.Buffer[count++]; PHONE_DecodeBitmap(GSM_NokiaStartupLogo, msg.Buffer + count, Data->Bitmap); } else { count = count + 2; } count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0); break; case 0x02: smprintf(s, "Welcome note\n"); if (Data->Bitmap->Type == GSM_WelcomeNote_Text) { @@ -1479,133 +1483,135 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi int i,end,start; smprintf(s, "Ringtone received\n"); switch (msg.Buffer[4]) { case 0x00: switch (Data->Ringtone->Format) { case RING_NOTETONE: memcpy(buffer,msg.Buffer,msg.Length); i=7; if (buffer[9]==0x4a && buffer[10]==0x3a) i=8; buffer[i]=0x02; error=GSM_DecodeNokiaRTTLRingtone(Data->Ringtone, buffer+i, msg.Length-i); if (error!=ERR_NONE) return ERR_EMPTY; return ERR_NONE; case RING_NOKIABINARY: i=8; while (msg.Buffer[i]!=0) { i++; if (i>msg.Length) return ERR_EMPTY; } EncodeUnicode(Data->Ringtone->Name,msg.Buffer+8,i-8); smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name)); /* Looking for start && end */ end=0;start=0;i=0; while (true) { if (start!=0) { if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) { end=i+2; break; } if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) { end=i+2; break; } } else { if (msg.Buffer[i]==0x02 && msg.Buffer[i+1]==0xfc && msg.Buffer[i+2]==0x09) { start = i; } } i++; if (i==msg.Length-3) return ERR_EMPTY; } /* Copying frame */ memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+start,end-start); Data->Ringtone->NokiaBinary.Length=end-start; #ifdef DEBUG if (di.dl == DL_TEXTALL || di.dl == DL_TEXTALLDATE) DumpMessage(di.df, di.dl, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length); #endif return ERR_NONE; case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format); break; default: smprintf(s, "Invalid location. Too high ?\n"); return ERR_INVALIDLOCATION; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) { GSM_Error error; unsigned char req[] = {0x00, 0x01, 0x9e, 0x00}; /* location */ if (PhoneRingtone) return ERR_NOTSUPPORTED; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_NORING)) return ERR_NOTSUPPORTED; if (Ringtone->Location == 0) return ERR_INVALIDLOCATION; if (Ringtone->Format == 0x00) { if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) { Ringtone->Format = RING_NOTETONE; } else { Ringtone->Format = RING_NOKIABINARY; } } switch (Ringtone->Format) { case RING_NOTETONE: if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; break; case RING_NOKIABINARY: if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; break; case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } error=DCT3_EnableSecurity (s, 0x01); if (error!=ERR_NONE) return error; req[3]=Ringtone->Location-1; s->Phone.Data.Ringtone=Ringtone; smprintf(s, "Getting (binary) ringtone\n"); return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone); } static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { *s->Phone.Data.SecurityStatus = msg.Buffer[4]; #ifdef DEBUG smprintf(s, "Security code status\n"); switch(msg.Buffer[4]) { case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break; case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break; case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break; case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break; case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break; case SEC_None : smprintf(s, "nothing to enter.\n"); break; default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } #endif return ERR_NONE; } static GSM_Error N6110_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) { unsigned char req[4] = {N6110_FRAME_HEADER, 0x07}; s->Phone.Data.SecurityStatus=Status; smprintf(s, "Getting security code status\n"); return GSM_WaitFor (s, req, 4, 0x08, 2, ID_GetSecurityStatus); } static GSM_Error N6110_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x0b: smprintf(s, "Security code OK\n"); return ERR_NONE; case 0x0c: @@ -2398,98 +2404,98 @@ static GSM_Error N6110_ReplyGetNextCalendar(GSM_Protocol_Message msg, GSM_StateM } } return ERR_NONE; case 0x93: smprintf(s, "Can't get calendar note - too high location?\n"); return ERR_INVALIDLOCATION; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) { int Text, Time, Alarm, Phone, Recurrance, EndTime, Location; GSM_Error error; GSM_DateTime date_time; GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110; unsigned char req[] = {N6110_FRAME_HEADER, 0x66, 0x00}; /* Location */ if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOCALENDAR)) return ERR_NOTSUPPORTED; if (start) { Priv->LastCalendarPos = 1; } else { Priv->LastCalendarPos++; } Note->Location = Priv->LastCalendarPos; req[4] = Priv->LastCalendarPos; s->Phone.Data.Cal=Note; smprintf(s, "Getting calendar note\n"); error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote); GSM_CalendarFindDefaultTextTimeAlarmPhoneRecurrance(Note, &Text, &Time, &Alarm, &Phone, &Recurrance, &EndTime, &Location); /* 2090 year is set for example in 3310 */ if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) { error=N6110_GetDateTime(s, &date_time); if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year; } return error; } GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { unsigned char buffer[2000],buffer2[4000]; int tmp; - tmp=GSM_UnpackEightBitsToSeven(0, 82, 82, msg.Buffer+8, buffer); - msg.Buffer[tmp] = 0; + tmp=GSM_UnpackEightBitsToSeven(0, msg.Buffer[7], 82, msg.Buffer+8, buffer); + buffer[tmp] = 0; smprintf(s, "USSD reply: \"%s\"\n",buffer); if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) { EncodeUnicode(buffer2,buffer,strlen(buffer)); s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2); } return ERR_NONE; } GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, bool all) { GSM_Error error; unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01, 0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8, 0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15, 0x63, 0x80}; if (!all) { smprintf(s, "Answering call part 1\n"); error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall); if (error != ERR_NONE) return error; return DCT3DCT4_AnswerCall(s,ID); } return DCT3_AnswerAllCalls(s); } static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) { unsigned int pos = 4; unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 0x0c}; /* Length of number */ if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber); req[pos++] = strlen(number); memcpy(req+pos,number,strlen(number)); pos += strlen(number); req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ req[pos++] = 0x01; req[pos++] = 0x01; req[pos++] = 0x05; req[pos++] = 0x81; switch (ShowNumber) { case GSM_CALL_HideNumber: req[pos++] = 0x02; @@ -2762,123 +2768,124 @@ GSM_Phone_Functions N6110Phone = { NOKIA_GetManufacturer, DCT3DCT4_GetModel, DCT3DCT4_GetFirmware, DCT3_GetIMEI, DCT3_GetOriginalIMEI, DCT3_GetManufactureMonth, DCT3_GetProductCode, DCT3_GetHardware, DCT3_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N6110_GetDateTime, N6110_SetDateTime, N6110_GetAlarm, N6110_SetAlarm, NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ DCT3_PressKey, DCT3_Reset, N61_71_ResetPhoneSettings, N6110_EnterSecurityCode, N6110_GetSecurityStatus, N6110_GetDisplayStatus, NOTIMPLEMENTED, /* SetAutoNetworkLogin */ N6110_GetBatteryCharge, N6110_GetSignalQuality, DCT3_GetNetworkInfo, NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ N6110_GetMemoryStatus, N6110_GetMemory, NOTIMPLEMENTED, /* GetNextMemory */ N6110_SetMemory, NOTIMPLEMENTED, /* AddMemory */ N6110_DeleteMemory, NOTIMPLEMENTED, /* DeleteAllMemory */ N6110_GetSpeedDial, NOTIMPLEMENTED, /* SetSpeedDial */ DCT3_GetSMSC, DCT3_SetSMSC, DCT3_GetSMSStatus, N6110_GetSMSMessage, N6110_GetNextSMSMessage, N6110_SetSMS, N6110_AddSMS, N6110_DeleteSMSMessage, DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOKIA_SetIncomingSMS, DCT3_SetIncomingCB, PHONE_GetSMSFolders, NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ N6110_DialVoice, N6110_AnswerCall, DCT3_CancelCall, N6110_HoldCall, N6110_UnholdCall, N6110_ConferenceCall, N6110_SplitCall, N6110_TransferCall, N6110_SwitchCall, DCT3DCT4_GetCallDivert, DCT3DCT4_SetCallDivert, DCT3DCT4_CancelAllDiverts, NOKIA_SetIncomingCall, NOKIA_SetIncomingUSSD, DCT3DCT4_SendDTMF, N6110_GetRingtone, N6110_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 */ N6110_GetBitmap, N6110_SetBitmap, NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ NOTIMPLEMENTED, /* GetCalendarStatus */ NOTIMPLEMENTED, /* GetCalendar */ N6110_GetNextCalendarNote, NOTIMPLEMENTED, /* SetCalendar */ N6110_AddCalendarNote, N6110_DeleteCalendarNote, NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ N6110_GetProfile, N6110_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: */ 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,50 +1,53 @@ /* (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}; @@ -481,96 +484,97 @@ static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi 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]; @@ -1602,123 +1606,124 @@ GSM_Phone_Functions N7110Phone = { 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: */ diff --git a/gammu/emb/common/phone/nokia/dct3/n9210.c b/gammu/emb/common/phone/nokia/dct3/n9210.c index e82d530..ff71ad3 100644 --- a/gammu/emb/common/phone/nokia/dct3/n9210.c +++ b/gammu/emb/common/phone/nokia/dct3/n9210.c @@ -274,123 +274,124 @@ GSM_Phone_Functions N9210Phone = { 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, NOTIMPLEMENTED, /* GetAlarm */ NOTIMPLEMENTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ NOTIMPLEMENTED, /* PressKey */ NOTIMPLEMENTED, /* Reset */ NOTIMPLEMENTED, /* ResetPhoneSettings */ NOTSUPPORTED, /* EnterSecurityCode */ NOTSUPPORTED, /* GetSecurityStatus */ NOTSUPPORTED, /* GetDisplayStatus */ NOTIMPLEMENTED, /* SetAutoNetworkLogin */ N71_92_GetBatteryCharge, N71_92_GetSignalQuality, DCT3_GetNetworkInfo, NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ NOTIMPLEMENTED, /* GetMemoryStatus */ NOTIMPLEMENTED, /* GetMemory */ NOTIMPLEMENTED, /* GetNextMemory */ NOTIMPLEMENTED, /* SetMemory */ NOTIMPLEMENTED, /* AddMemory */ NOTIMPLEMENTED, /* DeleteMemory */ NOTIMPLEMENTED, /* DeleteAllMemory */ NOTIMPLEMENTED, /* GetSpeedDial */ NOTIMPLEMENTED, /* SetSpeedDial */ DCT3_GetSMSC, DCT3_SetSMSC, /* FIXME: test it */ NOTIMPLEMENTED, /* GetSMSStatus */ NOTIMPLEMENTED, /* GetSMS */ NOTIMPLEMENTED, /* GetNextSMS */ NOTIMPLEMENTED, /* SetSMS */ NOTIMPLEMENTED, /* AddSMS */ NOTIMPLEMENTED, /* DeleteSMS */ DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ N9210_SetIncomingSMS, DCT3_SetIncomingCB, NOTIMPLEMENTED, /* GetSMSFolders */ NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ DCT3_DialVoice, N9210_AnswerCall, DCT3_CancelCall, NOTSUPPORTED, /* HoldCall */ NOTSUPPORTED, /* UnholdCall */ NOTSUPPORTED, /* ConferenceCall */ NOTSUPPORTED, /* SplitCall */ NOTSUPPORTED, /* TransferCall */ NOTSUPPORTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NOTSUPPORTED, /* SetIncomingCall */ NOTIMPLEMENTED, /* SetIncomingUSSD */ NOTSUPPORTED, /* SendDTMF */ NOTIMPLEMENTED, /* GetRingtone */ NOTIMPLEMENTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTIMPLEMENTED, /* GetWAPBookmark */ NOTIMPLEMENTED, /* SetWAPBookmark */ NOTIMPLEMENTED, /* DeleteWAPBookmark */ NOTIMPLEMENTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ N9210_GetBitmap, N9210_SetBitmap, NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ NOTSUPPORTED, /* GetCalendarStatus */ NOTSUPPORTED, /* GetCalendar */ NOTSUPPORTED, /* GetNextCalendar */ NOTSUPPORTED, /* SetCalendar */ NOTSUPPORTED, /* AddCalendar */ NOTSUPPORTED, /* DeleteCalendar */ NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTIMPLEMENTED, /* GetProfile */ NOTSUPPORTED, /* 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: */ diff --git a/gammu/emb/common/phone/nokia/dct4/n3320.c b/gammu/emb/common/phone/nokia/dct4/n3320.c index 51e6f18..9b1d6cd 100644 --- a/gammu/emb/common/phone/nokia/dct4/n3320.c +++ b/gammu/emb/common/phone/nokia/dct4/n3320.c @@ -149,123 +149,124 @@ GSM_Phone_Functions N3320Phone = { NOKIA_GetManufacturer, DCT3DCT4_GetModel, DCT3DCT4_GetFirmware, NOTSUPPORTED, /* GetIMEI */ NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ NOTSUPPORTED, /* GetProductCode */ NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ N3320_GetDateTime, NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ NOTSUPPORTED, /* PressKey */ NOTSUPPORTED, /* Reset */ NOTSUPPORTED, /* ResetPhoneSettings */ NOTSUPPORTED, /* EnterSecurityCode */ NOTSUPPORTED, /* GetSecurityStatus */ NOTSUPPORTED, /* GetDisplayStatus */ NOTSUPPORTED, /* SetAutoNetworkLogin */ NOTSUPPORTED, /* GetBatteryCharge */ NOTSUPPORTED, /* GetSignalQuality */ NOTSUPPORTED, /* GetNetworkInfo */ NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ N3320_GetMemoryStatus, N3320_GetMemory, NOTSUPPORTED, /* GetNextMemory */ NOTSUPPORTED, /* SetMemory */ NOTSUPPORTED, /* AddMemory */ NOTSUPPORTED, /* DeleteMemory */ NOTIMPLEMENTED, /* DeleteAllMemory */ NOTSUPPORTED, /* GetSpeedDial */ NOTSUPPORTED, /* SetSpeedDial */ NOTSUPPORTED, /* GetSMSC */ NOTSUPPORTED, /* SetSMSC */ NOTSUPPORTED, /* GetSMSStatus */ NOTSUPPORTED, /* GetSMS */ NOTSUPPORTED, /* GetNextSMS */ NOTSUPPORTED, /* SetSMS */ NOTSUPPORTED, /* AddSMS */ NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMS */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ NOTIMPLEMENTED, /* DialVoice */ NOTIMPLEMENTED, /* AnswerCall */ NOTIMPLEMENTED, /* CancelCall */ NOTIMPLEMENTED, /* HoldCall */ NOTIMPLEMENTED, /* UnholdCall */ NOTIMPLEMENTED, /* ConferenceCall */ NOTIMPLEMENTED, /* SplitCall */ NOTIMPLEMENTED, /* TransferCall */ NOTIMPLEMENTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NOTIMPLEMENTED, /* SetIncomingCall */ NOTIMPLEMENTED, /* SetIncomingUSSD */ NOTSUPPORTED, /* SendDTMF */ NOTSUPPORTED, /* GetRingtone */ NOTSUPPORTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTIMPLEMENTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ NOTSUPPORTED, /* GetBitmap */ NOTSUPPORTED, /* SetBitmap */ NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ N3320_GetCalendarStatus, NOTIMPLEMENTED, /* GetCalendar */ N3320_GetNextCalendar, NOTIMPLEMENTED, /* SetCalendar */ NOTSUPPORTED, /* AddCalendar */ NOTSUPPORTED, /* DeleteCalendar */ NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ NOTSUPPORTED, /* GetNextFileFolder */ NOTSUPPORTED, /* GetFilePart */ NOTIMPLEMENTED, /* AddFilePart */ NOTSUPPORTED, /* GetFileSystemStatus */ NOTIMPLEMENTED, /* DeleteFile */ NOTIMPLEMENTED, /* 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: */ diff --git a/gammu/emb/common/phone/nokia/dct4/n3650.c b/gammu/emb/common/phone/nokia/dct4/n3650.c index 2da55bf..d4746a7 100644 --- a/gammu/emb/common/phone/nokia/dct4/n3650.c +++ b/gammu/emb/common/phone/nokia/dct4/n3650.c @@ -270,123 +270,124 @@ GSM_Phone_Functions N3650Phone = { NOKIA_GetManufacturer, DCT3DCT4_GetModel, DCT3DCT4_GetFirmware, DCT4_GetIMEI, NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ DCT4_GetProductCode, DCT4_GetHardware, NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ NOTSUPPORTED, /* GetDateTime */ NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ NOTSUPPORTED, /* PressKey */ DCT4_Reset, NOTSUPPORTED, /* ResetPhoneSettings */ NOTSUPPORTED, /* EnterSecurityCode */ NOTSUPPORTED, /* GetSecurityStatus */ NOTSUPPORTED, /* GetDisplayStatus */ NOTSUPPORTED, /* SetAutoNetworkLogin */ NOTSUPPORTED, /* GetBatteryCharge */ NOTSUPPORTED, /* GetSignalQuality */ NOTSUPPORTED, /* GetNetworkInfo */ NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ NOTSUPPORTED, /* GetMemoryStatus */ NOTSUPPORTED, /* GetMemory */ NOTSUPPORTED, /* GetNextMemory */ NOTSUPPORTED, /* SetMemory */ NOTSUPPORTED, /* AddMemory */ NOTSUPPORTED, /* DeleteMemory */ NOTIMPLEMENTED, /* DeleteAllMemory */ NOTSUPPORTED, /* GetSpeedDial */ NOTSUPPORTED, /* SetSpeedDial */ NOTSUPPORTED, /* GetSMSC */ NOTSUPPORTED, /* SetSMSC */ NOTSUPPORTED, /* GetSMSStatus */ NOTSUPPORTED, /* GetSMS */ NOTSUPPORTED, /* GetNextSMS */ NOTSUPPORTED, /* SetSMS */ NOTSUPPORTED, /* AddSMS */ NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMS */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ NOTIMPLEMENTED, /* DialVoice */ NOTIMPLEMENTED, /* AnswerCall */ NOTIMPLEMENTED, /* CancelCall */ NOTIMPLEMENTED, /* HoldCall */ NOTIMPLEMENTED, /* UnholdCall */ NOTIMPLEMENTED, /* ConferenceCall */ NOTIMPLEMENTED, /* SplitCall */ NOTIMPLEMENTED, /* TransferCall */ NOTIMPLEMENTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NOTIMPLEMENTED, /* SetIncomingCall */ NOTIMPLEMENTED, /* SetIncomingUSSD */ NOTSUPPORTED, /* SendDTMF */ NOTSUPPORTED, /* GetRingtone */ NOTSUPPORTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTIMPLEMENTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ NOTSUPPORTED, /* GetBitmap */ NOTSUPPORTED, /* SetBitmap */ NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ NOTIMPLEMENTED, /* GetCalendarStatus */ NOTIMPLEMENTED, /* GetCalendar */ NOTSUPPORTED, /* GetNextCalendar */ NOTIMPLEMENTED, /* SetCalendar */ NOTSUPPORTED, /* AddCalendar */ NOTSUPPORTED, /* DeleteCalendar */ NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ N3650_GetNextFileFolder, N3650_GetFilePart, NOTIMPLEMENTED, /* AddFilePart */ NOTSUPPORTED, /* GetFileSystemStatus */ NOTIMPLEMENTED, /* DeleteFile */ NOTIMPLEMENTED, /* 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: */ diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.c b/gammu/emb/common/phone/nokia/dct4/n6510.c index 67fe492..2208def 100644 --- a/gammu/emb/common/phone/nokia/dct4/n6510.c +++ b/gammu/emb/common/phone/nokia/dct4/n6510.c @@ -1,50 +1,53 @@ /* (c) 2002-2004 by Marcin Wiacek */ -/* based on some work from Markus Plail, Pawel Kot and Gnokii */ +/* based on some Markus Plail, Pawel Kot 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 + */ /* function for making CRC for filesystem (c) 2003 by Michael Schroeder */ #include "../../../gsmstate.h" #ifdef GSM_ENABLE_NOKIA6510 #include <string.h> #include <time.h> #include "../../../misc/coding/coding.h" #include "../../../gsmcomon.h" #include "../../../service/gsmlogo.h" #include "../nfunc.h" #include "../nfuncold.h" #include "../../pfunc.h" #include "dct4func.h" #include "n6510.h" static GSM_Error N6510_Initialise (GSM_StateMachine *s) { s->Phone.Data.Priv.N6510.CalendarIconsNum = 0; /* Enables various things like incoming SMS, call info, etc. */ return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17\x39", 7); } static GSM_Error N6510_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) { 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, s->Phone.Data.Memory, s->Phone.Data.Bitmap, s->Phone.Data.SpeedDial, msg.Buffer+22, msg.Length-22,false); } return ERR_UNKNOWN; } static GSM_Error N6510_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry) { unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01, 0xfe, 0x10, /* memory type */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* location */ 0x00, 0x00, 0x01}; req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[9]==0xff) return ERR_NOTSUPPORTED; @@ -74,96 +77,98 @@ static GSM_Error N6510_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateM Data->MemoryStatus->MemoryUsed = msg.Buffer[20]*256 + msg.Buffer[21]; 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 N6510_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status) { unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02, 0x00, /* memory type */ 0x55, 0x55, 0x55, 0x00}; 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, 10, 0x03, 4, ID_GetMemoryStatus); } static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) { int i, current, j; GSM_Phone_Data *Data = &s->Phone.Data; switch (msg.Buffer[4]) { case 0x00: smprintf(s, "SMSC received\n"); break; case 0x02: smprintf(s, "SMSC empty\n"); return ERR_INVALIDLOCATION; default: smprintf(s, "Unknown SMSC state: %02x\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } memset(Data->SMSC,0,sizeof(GSM_SMSC)); Data->SMSC->Location = msg.Buffer[8]; Data->SMSC->Format = SMS_FORMAT_Text; switch (msg.Buffer[10]) { case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager; break; case 0x32: Data->SMSC->Format = SMS_FORMAT_Email; break; } Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; Data->SMSC->Validity.Relative = msg.Buffer[12]; + if (msg.Buffer[12] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time; + current = 14; for (i=0;i<msg.Buffer[13];i++) { switch (msg.Buffer[current]) { case 0x81: j=current+4; while (msg.Buffer[j]!=0) {j++;} j=j-33; if (j>GSM_MAX_SMSC_NAME_LENGTH) { smprintf(s, "Too long name\n"); return ERR_UNKNOWNRESPONSE; } CopyUnicodeString(Data->SMSC->Name,msg.Buffer+current+4); smprintf(s, " Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); break; case 0x82: switch (msg.Buffer[current+2]) { case 0x01: GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+current+4,true); smprintf(s, " Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); break; case 0x02: GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+current+4,false); smprintf(s, " Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); break; default: smprintf(s, "Unknown SMSC number: %02x\n",msg.Buffer[current+2]); return ERR_UNKNOWNRESPONSE; } break; default: smprintf(s, "Unknown SMSC block: %02x\n",msg.Buffer[current]); return ERR_UNKNOWNRESPONSE; } current = current + msg.Buffer[current+1]; } return ERR_NONE; } static GSM_Error N6510_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) { unsigned char req[] = {N6110_FRAME_HEADER, 0x14, 0x01, /* location */ 0x00}; if (smsc->Location==0x00) return ERR_INVALIDLOCATION; req[4]=smsc->Location; @@ -940,101 +945,101 @@ static GSM_Error N6510_ReplyGetSignalQuality(GSM_Protocol_Message msg, GSM_State { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Network level received: %i\n",msg.Buffer[8]); Data->SignalQuality->SignalStrength = -1; Data->SignalQuality->SignalPercent = ((int)msg.Buffer[8]); Data->SignalQuality->BitErrorRate = -1; return ERR_NONE; } static GSM_Error N6510_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig) { unsigned char req[] = {N6110_FRAME_HEADER, 0x0B, 0x00, 0x02, 0x00, 0x00, 0x00}; s->Phone.Data.SignalQuality = sig; smprintf(s, "Getting network level\n"); return GSM_WaitFor (s, req, 9, 0x0a, 4, ID_GetSignalQuality); } static GSM_Error N6510_ReplyGetBatteryCharge(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Battery level received: %i\n",msg.Buffer[9]*100/7); Data->BatteryCharge->BatteryPercent = ((int)(msg.Buffer[9]*100/7)); Data->BatteryCharge->ChargeState = 0; return ERR_NONE; } static GSM_Error N6510_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat) { unsigned char req[] = {N6110_FRAME_HEADER, 0x0A, 0x02, 0x00}; s->Phone.Data.BatteryCharge = bat; smprintf(s, "Getting battery level\n"); return GSM_WaitFor (s, req, 6, 0x17, 4, ID_GetBatteryCharge); } static GSM_Error N6510_ReplyGetWAPBookmark(GSM_Protocol_Message msg, GSM_StateMachine *s) { return DCT3DCT4_ReplyGetWAPBookmark (msg, s, true); } static GSM_Error N6510_ReplyGetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Operator logo received\n"); + if (msg.Length == 18) return ERR_EMPTY; NOKIA_DecodeNetworkCode(msg.Buffer+12,Data->Bitmap->NetworkCode); smprintf(s, "Network code %s\n",Data->Bitmap->NetworkCode); Data->Bitmap->BitmapWidth = msg.Buffer[20]; Data->Bitmap->BitmapHeight = msg.Buffer[21]; - if (msg.Length == 18) return ERR_EMPTY; PHONE_DecodeBitmap(GSM_Nokia6510OperatorLogo,msg.Buffer+26,Data->Bitmap); return ERR_NONE; } GSM_Error N6510_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Phonebook entry deleted\n"); return ERR_NONE; } GSM_Error N6510_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) { unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x55, 0x01, 0x04, 0x55, 0x00, 0x10, 0xFF, 0x02, 0x00, 0x01, /* location */ 0x00, 0x00, 0x00, 0x00, 0x05, /* memory type */ 0x55, 0x55, 0x55}; req[12] = entry->Location / 256; req[13] = entry->Location % 256; req[18] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[18]==0xff) return ERR_NOTSUPPORTED; smprintf(s, "Deleting phonebook entry\n"); return GSM_WaitFor (s, req, 22, 0x03, 4, ID_SetMemory); } static GSM_Error N6510_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) { int count = 22, blocks; unsigned char req[500] = { N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x10, 0x02, 0x00, /* memory type */ 0x00, 0x00, /* location */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; if (entry->Location == 0) return ERR_NOTSUPPORTED; req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES); if (req[11]==0xff) return ERR_NOTSUPPORTED; req[12] = entry->Location / 256; req[13] = entry->Location % 256; count = count + N71_65_EncodePhonebookFrame(s, req+22, *entry, &blocks, true, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS)); req[21] = blocks; @@ -1720,97 +1725,98 @@ static GSM_Error N6510_ReplyGetSyncMLSettings(GSM_Protocol_Message msg, GSM_Stat smprintf(s, "SyncML settings received OK\n"); CopyUnicodeString(Sett->User,msg.Buffer+18); CopyUnicodeString(Sett->Password,msg.Buffer+86); CopyUnicodeString(Sett->PhonebookDataBase,msg.Buffer+130); CopyUnicodeString(Sett->CalendarDataBase,msg.Buffer+234); CopyUnicodeString(Sett->Server,msg.Buffer+338); Sett->SyncPhonebook = false; Sett->SyncCalendar = false; if ((msg.Buffer[598] & 0x02)==0x02) Sett->SyncCalendar = true; if ((msg.Buffer[598] & 0x01)==0x01) Sett->SyncPhonebook = true; return ERR_NONE; } static GSM_Error N6510_ReplyGetSyncMLName(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_SyncMLSettings *Sett = s->Phone.Data.SyncMLSettings; smprintf(s, "SyncML names received OK\n"); CopyUnicodeString(Sett->Name,msg.Buffer+18); return ERR_NONE; } static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings *settings) { GSM_Error error; // unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x05, // 0x00, 0x00, 0x00, 0x31, 0x00, // 0x06, 0x00, 0x00, 0x00, 0xDE, 0x00, 0x00}; // unsigned char GetActive[] = {N6110_FRAME_HEADER, 0x05, // 0x00, 0x00, 0x00, 0x31, 0x00, // 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}; unsigned char req[] = {N6110_FRAME_HEADER, 0x05, 0x00, 0x00, 0x00, 0x31, 0x00, 0x01, //location 0x00, 0x00, 0x02, 0x46, 0x00, 0x00}; settings->Connection.Location = settings->Location; error = N6510_GetConnectionSettings(s, &settings->Connection, N6510_SYNCML_SETTINGS); if (error != ERR_NONE) return error; settings->Active = settings->Connection.Active; settings->Name[0] = 0; settings->Name[1] = 0; -// s->Phone.Data.SyncMLSettings = settings; + s->Phone.Data.SyncMLSettings = settings; + // smprintf(s, "Getting SyncML settings name\n"); // error = GSM_WaitFor (s, NameReq, 16, 0x43, 4, ID_GetSyncMLName); // if (error != ERR_NONE) return error; req[9] = settings->Location - 1; smprintf(s, "Getting additional SyncML settings\n"); return GSM_WaitFor (s, req, 16, 0x43, 4, ID_GetSyncMLSettings); } static GSM_Error N6510_ReplyGetChatSettings(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_ChatSettings *Sett = s->Phone.Data.ChatSettings; int i; Sett->Name[0] = 0; Sett->Name[1] = 0; Sett->HomePage[0] = 0; Sett->HomePage[1] = 0; Sett->User[0] = 0; Sett->User[1] = 0; Sett->Password[0] = 0; Sett->Password[1] = 0; switch(msg.Buffer[3]) { case 0x3B: smprintf(s, "Chat settings received OK\n"); memcpy(Sett->Name,msg.Buffer+20,msg.Buffer[12]*2); Sett->Name[msg.Buffer[12]*2] = 0; Sett->Name[msg.Buffer[12]*2+1] = 0; memcpy(Sett->HomePage,msg.Buffer+20+msg.Buffer[12]*2,msg.Buffer[15]*2); Sett->HomePage[msg.Buffer[15]*2] = 0; Sett->HomePage[msg.Buffer[15]*2+1] = 0; i = msg.Buffer[12]*2 + msg.Buffer[15]*2 + 29; memcpy(Sett->User,msg.Buffer+i+3,msg.Buffer[i]*2); Sett->User[msg.Buffer[i]*2] = 0; Sett->User[msg.Buffer[i]*2+1] = 0; memcpy(Sett->Password,msg.Buffer+i+3+msg.Buffer[i]*2,msg.Buffer[i+1]*2); Sett->Password[msg.Buffer[i+1]*2] = 0; Sett->Password[msg.Buffer[i+1]*2+1] = 0; return ERR_NONE; case 0x3C: smprintf(s, "Empty chat settings received\n"); return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_GetChatSettings(GSM_StateMachine *s, GSM_ChatSettings *settings) @@ -2238,97 +2244,97 @@ static GSM_Error N6510_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *st static GSM_Error N6510_ReplyDeleteSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x05: smprintf(s, "SMS deleted OK\n"); return ERR_NONE; case 0x06: switch (msg.Buffer[4]) { case 0x02: smprintf(s, "Invalid location\n"); return ERR_INVALIDLOCATION; default: smprintf(s, "Unknown error: %02x\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) { unsigned char folderid; int location; unsigned char req[] = {N6110_FRAME_HEADER, 0x04, 0x01, /* 0x01=SM, 0x02=ME */ 0x00, /* FolderID */ 0x00, 0x02, /* Location */ 0x0F, 0x55}; N6510_GetSMSLocation(s, sms, &folderid, &location); switch (folderid) { case 0x01: req[5] = 0x02; break; /* INBOX SIM */ case 0x02: req[5] = 0x03; break; /* OUTBOX SIM */ default : req[5] = folderid - 1; req[4] = 0x02; break; /* ME folders */ } req[6]=location / 256; req[7]=location; smprintf(s, "Deleting sms\n"); return GSM_WaitFor (s, req, 10, 0x14, 4, ID_DeleteSMSMessage); } static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[8]) { case 0x00: - smprintf(s, "SMS sent OK, TPMR for sent sms is %02x\n",msg.Buffer[10]); + smprintf(s, "SMS sent OK, TPMR for sent sms is %d\n",msg.Buffer[10]); if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[10]); return ERR_NONE; default: smprintf(s, "SMS not sent OK, error code probably %i\n",msg.Buffer[8]); if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[8],msg.Buffer[10]); return ERR_NONE; } } static GSM_Error N6510_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) { int length = 11; GSM_Error error; GSM_SMSMessageLayout Layout; unsigned char req [300] = { N6110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x55, 0x55}; if (sms->PDU == SMS_Deliver) sms->PDU = SMS_Submit; memset(req+9,0x00,sizeof(req) - 9); error=N6510_EncodeSMSFrame(s, sms, req + 9, &Layout, &length); if (error != ERR_NONE) return error; smprintf(s, "Sending sms\n"); return s->Protocol.Functions->WriteMessage(s, req, length + 9, 0x02); } static GSM_Error N6510_ReplyGetSecurityStatus(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_Phone_Data *Data = &s->Phone.Data; smprintf(s, "Security Code status received: "); switch (msg.Buffer[4]) { case 0x01 : smprintf(s, "waiting for Security Code.\n"); *Data->SecurityStatus = SEC_SecurityCode; break; case 0x07 : case 0x02 : smprintf(s, "waiting for PIN.\n"); *Data->SecurityStatus = SEC_Pin; break; case 0x03 : smprintf(s, "waiting for PUK.\n"); *Data->SecurityStatus = SEC_Puk; break; case 0x05 : smprintf(s, "PIN ok, SIM ok\n"); *Data->SecurityStatus = SEC_None; break; case 0x06 : smprintf(s, "No input status\n"); *Data->SecurityStatus = SEC_None; break; case 0x16 : smprintf(s, "No SIM card\n"); *Data->SecurityStatus = SEC_None; break; case 0x1A : smprintf(s, "SIM card rejected!\n"); *Data->SecurityStatus = SEC_None; break; default : smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]); return ERR_UNKNOWNRESPONSE; } return ERR_NONE; } static GSM_Error N6510_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status) { @@ -2725,96 +2731,97 @@ static GSM_Error N6510_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi msg.Buffer[msg.Buffer[7]*2+12] == 'h' && msg.Buffer[msg.Buffer[7]*2+13] == 'd') { smprintf(s,"MIDI\n"); tmp = msg.Buffer[7]*2+10; i = msg.Length - 2; /* ?????? */ Data->Ringtone->Format = RING_MIDI; } else { /* Looking for end */ i=8+msg.Buffer[7]*2+3; tmp = i; while (true) { if (msg.Buffer[i]==0x07 && 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+tmp,i-tmp); Data->Ringtone->NokiaBinary.Length=i-tmp; return ERR_NONE; } static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone) { GSM_AllRingtonesInfo Info; GSM_Error error; unsigned char req2[6] = {N7110_FRAME_HEADER, 0x12, 0x00, 0xe7}; /* Location */ 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: s->Phone.Data.Ringtone = Ringtone; Info.Number = 0; error=N6510_PrivGetRingtonesInfo(s, &Info, PhoneRingtone); if (error != ERR_NONE) return error; if (Ringtone->Location > Info.Number) return ERR_INVALIDLOCATION; req2[4] = Info.Ringtone[Ringtone->Location-1].ID / 256; req2[5] = Info.Ringtone[Ringtone->Location-1].ID % 256; smprintf(s, "Getting binary ringtone\n"); return GSM_WaitFor (s, req2, 6, 0x1f, 4, ID_GetRingtone); case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } return ERR_NOTSUPPORTED; } static GSM_Error N6510_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, bool start) { GSM_Error error; unsigned char reqStart[] = { 0x00,0x06,0x01,0x00,0x07,0x00 }; unsigned char reqPlay[] = { 0x00,0x06,0x01,0x14,0x05,0x04, 0x00,0x00,0x00,0x03,0x03,0x08, 0x00,0x00,0x00,0x01,0x00,0x00, 0x03,0x08,0x01,0x00, 0x07,0xd0, /*Frequency */ 0x00,0x00,0x03,0x08,0x02,0x00,0x00, 0x05, /*Volume */ 0x00,0x00}; unsigned char reqOff[] = { 0x00,0x06,0x01,0x14,0x05,0x05, 0x00,0x00,0x00,0x01,0x03,0x08, 0x05,0x00,0x00,0x08,0x00,0x00}; // unsigned char reqOff2[] = { // 0x00,0x06,0x01,0x14,0x05,0x04, // 0x00,0x00,0x00,0x01,0x03,0x08, // 0x00,0x00,0x00,0x00,0x00,0x00}; if (start) { smprintf(s, "Enabling sound - part 1\n"); error=GSM_WaitFor (s, reqStart, 6, 0x0b, 4, ID_PlayTone); if (error!=ERR_NONE) return error; smprintf(s, "Enabling sound - part 2 (disabling sound command)\n"); error=GSM_WaitFor (s, reqOff, 18, 0x0b, 4, ID_PlayTone); if (error!=ERR_NONE) return error; } /* For Herz==255*255 we have silent */ if (Herz!=255*255) { reqPlay[23] = Herz%256; reqPlay[22] = Herz/256; reqPlay[31] = Volume; smprintf(s, "Playing sound\n"); return GSM_WaitFor (s, reqPlay, 34, 0x0b, 4, ID_PlayTone); } else { reqPlay[23] = 0; reqPlay[22] = 0; reqPlay[31] = 0; @@ -2941,96 +2948,99 @@ static GSM_Error N6510_ReplyGetProfile(GSM_Protocol_Message msg, GSM_StateMachin case 0x05: /* SMS tone */ j = Data->Profile->FeaturesNumber; NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); if (j == Data->Profile->FeaturesNumber) { Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_MessageTone; Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = PROFILE_MESSAGE_PERSONAL; Data->Profile->FeaturesNumber++; Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_MessageToneID; Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = blockstart[7]; Data->Profile->FeaturesNumber++; } break; case 0x08: /* Caller groups */ NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,true); break; case 0x0c : CopyUnicodeString(Data->Profile->Name,blockstart + 7); smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name)); Data->Profile->DefaultName = false; break; default: NOKIA_FindFeatureValue(s, Profile71_65,blockstart[1],blockstart[7],Data,false); } blockstart = blockstart + blockstart[0]; } return ERR_NONE; case 0x06: Data->Profile->Active = false; if (Data->Profile->Location == msg.Buffer[5]) Data->Profile->Active = true; return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile) { unsigned char req[150] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x0C, 0x01}; unsigned char reqActive[] = {N6110_FRAME_HEADER, 0x05}; int i, length = 7; GSM_Error error; /* For now !!! */ if (!strcmp(s->Phone.Data.ModelInfo->model,"3510")) { if (s->Phone.Data.VerNum>3.37) return ERR_NOTSUPPORTED; } if (!strcmp(s->Phone.Data.ModelInfo->model,"6230")) { return ERR_NOTSUPPORTED; } + if (!strcmp(s->Phone.Data.ModelInfo->model,"5140")) { + return ERR_NOTSUPPORTED; + } if (Profile->Location>5) return ERR_INVALIDLOCATION; for (i = 0; i < 0x0a; i++) { req[length++] = 0x04; req[length++] = Profile->Location; req[length++] = i; req[length++] = 0x01; } req[length++] = 0x04; req[length++] = Profile->Location; req[length++] = 0x0c; req[length++] = 0x01; req[length++] = 0x04; Profile->CarKitProfile = false; Profile->HeadSetProfile = false; Profile->FeaturesNumber = 0; s->Phone.Data.Profile=Profile; smprintf(s, "Getting profile\n"); error = GSM_WaitFor (s, req, length, 0x39, 4, ID_GetProfile); if (error != ERR_NONE) return error; smprintf(s, "Checking, which profile is active\n"); return GSM_WaitFor (s, reqActive, 4, 0x39, 4, ID_GetProfile); } static GSM_Error N6510_ReplySetProfile(GSM_Protocol_Message msg, GSM_StateMachine *s) { unsigned char *blockstart; int i; smprintf(s, "Response to profile writing received!\n"); blockstart = msg.Buffer + 6; for (i = 0; i < msg.Buffer[5]; i++) { switch (blockstart[2]) { case 0x00: smprintf(s, "keypad tone level"); break; case 0x02: smprintf(s, "call alert"); break; case 0x03: smprintf(s, "ringtone"); break; case 0x04: smprintf(s, "ringtone volume"); break; case 0x05: smprintf(s, "SMS tone"); break; case 0x06: smprintf(s, "vibration"); break; case 0x07: smprintf(s, "warning tone level"); break; @@ -3070,194 +3080,224 @@ static GSM_Error N6510_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile) Value = Profile->FeatureValue[i]; found = true; break; default: found=NOKIA_FindPhoneFeatureValue( s, Profile71_65, Profile->FeatureID[i],Profile->FeatureValue[i], &ID,&Value); } if (found) { req[length] = 0x09; req[length + 1] = ID; req[length + 2] = Profile->Location; memcpy(req + length + 4, "\x00\x00\x01", 3); req[length + 8] = 0x03; req[length + 3] = req[length + 7] = Value; blocks++; length += 9; } } smprintf(s, "Setting profile\n"); return GSM_WaitFor (s, req, length, 0x39, 4, ID_SetProfile); } static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_SMSMessage sms; #ifdef DEBUG smprintf(s, "SMS message received\n"); N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); #endif if (s->Phone.Data.EnableIncomingSMS && s->User.IncomingSMS!=NULL) { sms.State = SMS_UnRead; sms.InboxFolder = true; N6510_DecodeSMSFrame(s, &sms, msg.Buffer+10); s->User.IncomingSMS(s->CurrentConfig->Device,sms); } return ERR_NONE; } static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber) { + unsigned int pos2 = 15; unsigned int pos = 4; + unsigned char req2[100] = {N6110_FRAME_HEADER,0x01, + 0x00,0x02,0x07,0x04, + 0x01, // 1 - voice, 2 - data + 0x00,0x03, + 0x18, // length of rest + 1 + 0x00,0x00,0x00}; unsigned char req[100] = {N6110_FRAME_HEADER,0x01, 0x0c}; /* Number length */ + GSM_Error error; + + /* USSD not supported */ + if (number[0] == '*') return ERR_NOTSUPPORTED; + if (number[0] == '#') return ERR_NOTSUPPORTED; req[pos++] = strlen(number); EncodeUnicode(req+pos,number,strlen(number)); pos += strlen(number)*2; req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */ req[pos++] = 0x01; req[pos++] = 0x05; req[pos++] = 0x00; req[pos++] = 0x02; req[pos++] = 0x00; req[pos++] = 0x00; switch (ShowNumber) { case GSM_CALL_HideNumber: req[pos++] = 0x02; break; case GSM_CALL_ShowNumber: req[pos++] = 0x03; break; case GSM_CALL_DefaultNumberPresence: req[pos++] = 0x01; break; } + smprintf(s, "Making voice call\n"); + error = GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice); + if (error != ERR_NOTSUPPORTED) return error; + + if (ShowNumber != GSM_CALL_DefaultNumberPresence) return ERR_NOTSUPPORTED; + + req2[11] = strlen(number)*2+6; + req2[pos2++] = strlen(number); + EncodeUnicode(req2+pos2,number,strlen(number)); + pos2 += strlen(number)*2; smprintf(s, "Making voice call\n"); - return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice); + error = GSM_WaitFor (s, req2, pos2, 0x01, 4, ID_DialVoice); + if (error == ERR_NOTSUPPORTED) return ERR_NONE; + return error; } /* method 3 */ static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last) { int i=0,j=0; while (Last->Location[j] != 0x00) j++; if (j >= GSM_MAXCALENDARTODONOTES) { smprintf(s, "Increase GSM_MAXCALENDARTODONOTES\n"); return ERR_UNKNOWN; } if (j == 0) { Last->Number=msg.Buffer[8]*256+msg.Buffer[9]; smprintf(s, "Number of Entries: %i\n",Last->Number); } smprintf(s, "Locations: "); while (14+(i*4) <= msg.Length) { Last->Location[j++]=msg.Buffer[12+i*4]*256+msg.Buffer[13+i*4]; smprintf(s, "%i ",Last->Location[j-1]); i++; } smprintf(s, "\nNumber of Entries in frame: %i\n",i); Last->Location[j] = 0; smprintf(s, "\n"); if (i == 1 && msg.Buffer[12+0*4]*256+msg.Buffer[13+0*4] == 0) return ERR_EMPTY; if (i == 0) return ERR_EMPTY; return ERR_NONE; } /* method 3 */ -static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, bool Calendar) +static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLocations *Last, char Type) { - GSM_Error error; + GSM_Error error = ERR_UNKNOWN; int i; unsigned char req[] = {N6110_FRAME_HEADER, 0x9E, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, /* First location */ - 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style */ + 0x00}; /* 0 = calendar, 1 = ToDo in 6610 style, 2 = Notes */ Last->Location[0] = 0x00; Last->Number = 0; - if (Calendar) { + req[10] = Type; + if (Type == 0) { smprintf(s, "Getting locations for calendar method 3\n"); error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); - } else { - req[10] = 0x01; + } else if (Type == 1) { smprintf(s, "Getting locations for ToDo method 2\n"); error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); + } else if (Type == 2) { + smprintf(s, "Getting locations for Notes\n"); + error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote); } if (error != ERR_NONE && error != ERR_EMPTY) return error; while (1) { i=0; while (Last->Location[i] != 0x00) i++; smprintf(s, "i = %i %i\n",i,Last->Number); if (i == Last->Number) break; if (i != Last->Number && error == ERR_EMPTY) { smprintf(s, "Phone doesn't support some notes with this method. Workaround\n"); Last->Number = i; break; } req[8] = Last->Location[i-1] / 256; req[9] = Last->Location[i-1] % 256; - if (Calendar) { + if (Type == 0) { smprintf(s, "Getting locations for calendar method 3\n"); error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetCalendarNotesInfo); - } else { + } else if (Type == 1) { smprintf(s, "Getting locations for todo method 2\n"); error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetToDo); + } else if (Type == 2) { + smprintf(s, "Getting locations for Notes\n"); + error = GSM_WaitFor (s, req, 11, 0x13, 4, ID_GetNote); } if (error != ERR_NONE && error != ERR_EMPTY) return error; } return ERR_NONE; } /* method 3 */ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_CalendarEntry *entry = s->Phone.Data.Cal; GSM_DateTime Date; unsigned long diff; int i; bool found = false; GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; smprintf(s, "Calendar note received method 3\n"); smprintf(s,"Note type %02i: ",msg.Buffer[27]); switch(msg.Buffer[27]) { case 0x00: smprintf(s,"Reminder\n"); entry->Type = GSM_CAL_REMINDER; break; case 0x01: smprintf(s,"Meeting\n"); entry->Type = GSM_CAL_MEETING; break; case 0x02: smprintf(s,"Call\n"); entry->Type = GSM_CAL_CALL; break; case 0x04: smprintf(s,"Birthday\n"); entry->Type = GSM_CAL_BIRTHDAY; break; case 0x08: smprintf(s,"Memo\n"); entry->Type = GSM_CAL_MEMO; break; default : smprintf(s,"unknown\n"); } smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n", msg.Buffer[28]*256+msg.Buffer[29], msg.Buffer[30],msg.Buffer[31],msg.Buffer[32], msg.Buffer[33]); Date.Year = msg.Buffer[28]*256+msg.Buffer[29]; if (entry->Type == GSM_CAL_BIRTHDAY) { Date.Year = entry->Entries[0].Date.Year; smprintf(s,"%i\n",Date.Year); } Date.Month = msg.Buffer[30]; Date.Day = msg.Buffer[31]; Date.Hour = msg.Buffer[32]; Date.Minute = msg.Buffer[33]; /* Garbage seen with 3510i 3.51 */ if (Date.Month == 0 && Date.Day == 0 && Date.Hour == 0 && Date.Minute == 0) return ERR_EMPTY; Date.Second = 0; entry->Entries[0].EntryType = CAL_START_DATETIME; memcpy(&entry->Entries[0].Date,&Date,sizeof(GSM_DateTime)); entry->EntriesNum++; @@ -3305,241 +3345,247 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) entry->Entries[entry->EntriesNum].Date.Year, entry->Entries[entry->EntriesNum].Date.Hour, entry->Entries[entry->EntriesNum].Date.Minute,entry->Entries[entry->EntriesNum].Date.Second); entry->Entries[entry->EntriesNum].EntryType = CAL_ALARM_DATETIME; if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 && msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00) { entry->Entries[entry->EntriesNum].EntryType = CAL_SILENT_ALARM_DATETIME; smprintf(s, "Alarm type : Silent\n"); } entry->EntriesNum++; } N71_65_GetCalendarRecurrance(s, msg.Buffer+40, entry); if (entry->Type == GSM_CAL_BIRTHDAY) { if (msg.Buffer[42] == 0xff && msg.Buffer[43] == 0xff) { entry->Entries[0].Date.Year = 0; } else { entry->Entries[0].Date.Year = msg.Buffer[42]*256+msg.Buffer[43]; } } memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+54, msg.Buffer[51]*2); entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2] = 0; entry->Entries[entry->EntriesNum].Text[msg.Buffer[51]*2+1] = 0; entry->Entries[entry->EntriesNum].EntryType = CAL_TEXT; entry->EntriesNum++; smprintf(s, "Note text: \"%s\"\n",DecodeUnicodeString(entry->Entries[entry->EntriesNum-1].Text)); if (entry->Type == GSM_CAL_CALL) { memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2); entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0; entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0; entry->Entries[entry->EntriesNum].EntryType = CAL_PHONE; entry->EntriesNum++; } if (entry->Type == GSM_CAL_MEETING) { memcpy(entry->Entries[entry->EntriesNum].Text, msg.Buffer+(54+msg.Buffer[51]*2), msg.Buffer[52]*2); entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2] = 0; entry->Entries[entry->EntriesNum].Text[msg.Buffer[52]*2+1] = 0; entry->Entries[entry->EntriesNum].EntryType = CAL_LOCATION; entry->EntriesNum++; } return ERR_NONE; } +static GSM_Error N6510_PrivGetGenericCalendar3(GSM_StateMachine *s, int Location, GSM_Phone_RequestID ID) +{ + unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00, + 0x00,0x99, /* Location */ + 0xff,0xff,0xff,0xff}; + + req[8] = Location / 256; + req[9] = Location % 256; + + return GSM_WaitFor (s, req, 14, 0x13, 4, ID); +} + static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, int *LastCalendarYear) { GSM_Error error; GSM_DateTime date_time; - unsigned char req[] = {N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00, - 0x00,0x99, /* Location */ - 0xff,0xff,0xff,0xff,0x01}; if (start) { /* We have to get current year. It's NOT written in frame for * Birthday */ error=s->Phone.Functions->GetDateTime(s,&date_time); switch (error) { case ERR_EMPTY: case ERR_NOTIMPLEMENTED: GSM_GetCurrentDateTime(&date_time); break; case ERR_NONE: break; default: return error; } *LastCalendarYear = date_time.Year; } Note->EntriesNum = 0; Note->Entries[0].Date.Year = *LastCalendarYear; - req[8] = Note->Location / 256; - req[9] = Note->Location % 256; - s->Phone.Data.Cal=Note; smprintf(s, "Getting calendar note method 3\n"); - return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetCalendarNote); + return N6510_PrivGetGenericCalendar3(s, Note->Location, ID_GetCalendarNote); } /* method 3 */ GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start, GSM_NOKIACalToDoLocations *LastCalendar, int *LastCalendarYear, int *LastCalendarPos) { GSM_Error error; bool start2; if (start) { - error=N6510_GetCalendarInfo3(s,LastCalendar,true); + error=N6510_GetCalendarInfo3(s,LastCalendar,0); if (error!=ERR_NONE) return error; if (LastCalendar->Number == 0) return ERR_EMPTY; *LastCalendarPos = 0; } else { (*LastCalendarPos)++; } error = ERR_EMPTY; start2 = start; while (error == ERR_EMPTY) { if (*LastCalendarPos >= LastCalendar->Number) return ERR_EMPTY; Note->Location = LastCalendar->Location[*LastCalendarPos]; error=N6510_PrivGetCalendar3(s, Note, start2, LastCalendarYear); if (error == ERR_EMPTY) (*LastCalendarPos)++; start2 = false; } return error; } static GSM_Error N6510_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x3B: /* Old method 1 for accessing calendar */ return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar); case 0x9F: smprintf(s, "Info with calendar notes locations received method 3\n"); return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastCalendar); } return ERR_UNKNOWNRESPONSE; } /* method 3 */ GSM_Error N6510_ReplyGetCalendarNotePos3(GSM_Protocol_Message msg, GSM_StateMachine *s,int *FirstCalendarPos) { smprintf(s, "First calendar location: %i\n",msg.Buffer[8]*256+msg.Buffer[9]); *FirstCalendarPos = msg.Buffer[8]*256+msg.Buffer[9]; return ERR_NONE; } /* method 3 */ static GSM_Error N6510_GetCalendarNotePos3(GSM_StateMachine *s) { unsigned char req[] = {N6110_FRAME_HEADER, 0x95, 0x00}; smprintf(s, "Getting first free calendar note location\n"); return GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNotePos); } static GSM_Error N6510_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x32: /* Old method 1 for accessing calendar */ return N71_65_ReplyGetCalendarNotePos1(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos); case 0x96: return N6510_ReplyGetCalendarNotePos3(msg, s,&s->Phone.Data.Priv.N6510.FirstCalendarPos); } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntry *Entry, unsigned char *ID) { int i,j,LastCalendarYear; GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; GSM_CalendarEntry Note; GSM_NOKIACalToDoLocations LastCalendar1,LastCalendar2; GSM_Error error; bool found; for(i=0;i<Priv->CalendarIconsNum;i++) { if (Priv->CalendarIconsTypes[i] == Entry->Type) { *ID = Priv->CalendarIcons[i]; return ERR_NONE; } } smprintf(s, "Starting finding note ID\n"); - error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); + error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0); memcpy(&LastCalendar1,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); if (error != ERR_NONE) return error; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL35) || IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL65) || IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { error=N71_65_AddCalendar2(s,Entry); } else { if (Entry->Type == GSM_CAL_MEETING) { error=N71_65_AddCalendar1(s, Entry, &s->Phone.Data.Priv.N6510.FirstCalendarPos); } else { error=N71_65_AddCalendar2(s,Entry); } } if (error != ERR_NONE) return error; - error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,true); + error=N6510_GetCalendarInfo3(s, &Priv->LastCalendar,0); memcpy(&LastCalendar2,&Priv->LastCalendar,sizeof(GSM_NOKIACalToDoLocations)); if (error != ERR_NONE) return error; smprintf(s,"Number of entries: %i %i\n",LastCalendar1.Number,LastCalendar2.Number); for(i=0;i<LastCalendar2.Number;i++) { found = true; for(j=0;j<LastCalendar1.Number;j++) { if (LastCalendar1.Location[j] == LastCalendar2.Location[i]) { found = false; break; } } if (found) { Note.Location = LastCalendar2.Location[i]; error=N6510_PrivGetCalendar3(s, &Note, true, &LastCalendarYear); if (error != ERR_NONE) return error; error=N71_65_DelCalendar(s, &Note); if (error != ERR_NONE) return error; smprintf(s, "Ending finding note ID\n"); for(j=0;j<Priv->CalendarIconsNum;j++) { if (Priv->CalendarIconsTypes[j] == Entry->Type) { *ID = Priv->CalendarIcons[j]; return ERR_NONE; } } return ERR_UNKNOWN; } } return ERR_UNKNOWN; } /* method 3 */ static GSM_Error N6510_ReplyAddCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Calendar note added\n"); return ERR_NONE; } /* method 3 */ GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int *FirstCalendarPos) { GSM_CalendarNoteType NoteType, OldNoteType; time_t t_time1,t_time2; @@ -3692,97 +3738,97 @@ GSM_Error N6510_AddCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, int * req[count++] = 0x00; smprintf(s, "Writing calendar note method 3\n"); return GSM_WaitFor (s, req, count, 0x13, 4, ID_SetCalendarNote); } static GSM_Error N6510_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start) { #ifdef GSM_FORCE_DCT4_CALENDAR_6210 /* Method 1. Some features missed. Not working with some notes in 3510 */ return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); #endif if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { /* Method 1. Some features missed. Not working with some notes in 3510 */ return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); /* Method 2. In known phones texts of notes cut to 50 chars. Some features missed */ // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); } else { /* Method 3. All DCT4 features supported. Not supported by 8910 */ return N6510_GetNextCalendar3(s,Note,start,&s->Phone.Data.Priv.N6510.LastCalendar,&s->Phone.Data.Priv.N6510.LastCalendarYear,&s->Phone.Data.Priv.N6510.LastCalendarPos); } } static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status) { GSM_Error error; #ifdef GSM_FORCE_DCT4_CALENDAR_6210 /* Method 1 */ error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); if (error!=ERR_NONE) return error; Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; return ERR_NONE; #endif if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { /* Method 1 */ error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N6510.LastCalendar); if (error!=ERR_NONE) return error; Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; return ERR_NONE; /* Method 2 */ // return ERR_NOTSUPPORTED; } else { /* Method 3 */ - error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,true); + error=N6510_GetCalendarInfo3(s,&s->Phone.Data.Priv.N6510.LastCalendar,0); if (error!=ERR_NONE) return error; Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number; return ERR_NONE; } } static GSM_Error N6510_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note) { #ifdef GSM_FORCE_DCT4_CALENDAR_6210 return N71_65_AddCalendar2(s,Note); #endif if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_CAL62)) { return N71_65_AddCalendar2(s,Note); // return N71_65_AddCalendar1(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); } else { /* Method 3. All DCT4 features supported. Not supported by 8910 */ return N6510_AddCalendar3(s, Note, &s->Phone.Data.Priv.N6510.FirstCalendarPos); } } static GSM_Error N6510_ReplyLogIntoNetwork(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Probably phone says: I log into network\n"); return ERR_NONE; } void N6510_EncodeFMFrequency(double freq, unsigned char *buff) { double freq0; unsigned char buffer[20]; unsigned int i,freq2; sprintf(buffer,"%.3f",freq); for (i=0;i<strlen(buffer);i++) { if (buffer[i] == ',' || buffer[i] == '.') buffer[i] = ' '; } StringToDouble(buffer, &freq0); freq2 = (unsigned int)freq0; dbgprintf("Frequency: %s %i\n",buffer,freq2); freq2 = freq2 - 0xffff; buff[0] = freq2 / 0x100; buff[1] = freq2 % 0x100; } void N6510_DecodeFMFrequency(double *freq, unsigned char *buff) { unsigned char buffer[20]; @@ -3927,180 +3973,216 @@ static GSM_Error N6510_SetFMStation (GSM_StateMachine *s, GSM_FMStation *FMStati smprintf(s, "Setting FM Station %i\n",FMStation->Location); return GSM_WaitFor (s, req, 0x13+len*2, 0x3E, 2, ID_SetFMStation); } static GSM_Error N6510_ReplySetLight(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Light set\n"); return ERR_NONE; } GSM_Error N6510_SetLight(GSM_StateMachine *s, N6510_PHONE_LIGHTS light, bool enable) { unsigned char req[14] = { N6110_FRAME_HEADER, 0x05, 0x01, /* 0x01 = Display, 0x03 = keypad */ 0x01, /* 0x01 = Enable, 0x02 = disable */ 0x00, 0x00, 0x00, 0x01, 0x05, 0x04, 0x02, 0x00}; req[4] = light; if (!enable) req[5] = 0x02; smprintf(s, "Setting light\n"); return GSM_WaitFor (s, req, 14, 0x3A, 4, ID_SetLight); } static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable) { GSM_Error error; if (enable) { error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,true); if (error != ERR_NONE) return error; error=N6510_SetLight(s,N6510_LIGHT_TORCH,true); if (error != ERR_NONE) return error; return N6510_SetLight(s,N6510_LIGHT_KEYPAD,true); } else { error=N6510_SetLight(s,N6510_LIGHT_DISPLAY,false); if (error != ERR_NONE) return error; error=N6510_SetLight(s,N6510_LIGHT_TORCH,false); if (error != ERR_NONE) return error; return N6510_SetLight(s,N6510_LIGHT_KEYPAD,false); } } +static GSM_Error N6510_ReplyGetNoteInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + return N6510_ReplyGetCalendarInfo3(msg, s, &s->Phone.Data.Priv.N6510.LastNote); +} + +static GSM_Error N6510_ReplyGetNote(GSM_Protocol_Message msg, GSM_StateMachine *s) +{ + smprintf(s, "Note received\n"); + memcpy(s->Phone.Data.Note->Text,msg.Buffer+54,(msg.Buffer[50]*256+msg.Buffer[51])*2); + s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2] = 0; + s->Phone.Data.Note->Text[(msg.Buffer[50]*256+msg.Buffer[51])*2+1] = 0; + return ERR_NONE; +} + +GSM_Error N6510_GetNextNote(GSM_StateMachine *s, GSM_NoteEntry *Note, bool start) +{ + GSM_Error error; + GSM_NOKIACalToDoLocations *LastNote = &s->Phone.Data.Priv.N6510.LastNote; + + if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOTES)) return ERR_NOTSUPPORTED; + + if (start) { + error=N6510_GetCalendarInfo3(s,LastNote,2); + if (error!=ERR_NONE) return error; + Note->Location = 1; + } else { + Note->Location++; + } + + if (Note->Location > LastNote->Number) return ERR_EMPTY; + + s->Phone.Data.Note = Note; + smprintf(s, "Getting note\n"); + return N6510_PrivGetGenericCalendar3(s, LastNote->Location[Note->Location-1], ID_GetNote); +} + static int N6510_FindFileCheckSum(unsigned char *ptr, int len) { int acc, i, accx; accx = 0; acc = 0xffff; while (len--) { accx = (accx & 0xffff00ff) | (acc & 0xff00); acc = (acc & 0xffff00ff) | *ptr++ << 8; for (i = 0; i < 8; i++) { acc <<= 1; if (acc & 0x10000) acc ^= 0x1021; if (accx & 0x80000000) acc ^= 0x1021; accx <<= 1; } } dbgprintf("Checksum from Gammu is %04X\n",(acc & 0xffff)); return (acc & 0xffff); } static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_File *File = s->Phone.Data.FileInfo; GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; int i; switch (msg.Buffer[3]) { case 0x15: smprintf(s,"File or folder details received\n"); CopyUnicodeString(File->Name,msg.Buffer+10); if (!strncmp(DecodeUnicodeString(File->Name),"GMSTemp",7)) return ERR_EMPTY; if (File->Name[0] == 0x00 && File->Name[1] == 0x00) return ERR_UNKNOWN; i = msg.Buffer[8]*256+msg.Buffer[9]; dbgprintf("%02x %02x %02x %02x %02x %02x %02x %02x %02x\n", msg.Buffer[i-5],msg.Buffer[i-4],msg.Buffer[i-3], msg.Buffer[i-2],msg.Buffer[i-1],msg.Buffer[i], msg.Buffer[i+1],msg.Buffer[i+2],msg.Buffer[i+3]); File->Folder = false; if (msg.Buffer[i-5] == 0x00) File->Folder = true; File->ReadOnly = false; File->Protected = false; File->System = false; File->Hidden = false; if (msg.Buffer[i+2] == 0x01) File->Protected = true; if (msg.Buffer[i+4] == 0x01) File->ReadOnly = true; if (msg.Buffer[i+5] == 0x01) File->Hidden = true; if (msg.Buffer[i+6] == 0x01) File->System = true;//fixme File->ModifiedEmpty = false; NOKIA_DecodeDateTime(s, msg.Buffer+i-22, &File->Modified); if (File->Modified.Year == 0x00) File->ModifiedEmpty = true; dbgprintf("%02x %02x %02x %02x\n",msg.Buffer[i-22],msg.Buffer[i-21],msg.Buffer[i-20],msg.Buffer[i-19]); Priv->FileToken = msg.Buffer[i-10]*256+msg.Buffer[i-9]; Priv->ParentID = msg.Buffer[i]*256+msg.Buffer[i+1]; smprintf(s,"ParentID is %i\n",Priv->ParentID); File->Type = GSM_File_Other; if (msg.Length > 240){ i = 227; if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x01) File->Type = GSM_File_Image_JPG; else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x02) File->Type = GSM_File_Image_BMP; else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x07) File->Type = GSM_File_Image_BMP; else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x03) File->Type = GSM_File_Image_PNG; else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x05) File->Type = GSM_File_Image_GIF; else if (msg.Buffer[i]==0x02 && msg.Buffer[i+2]==0x09) File->Type = GSM_File_Image_WBMP; else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x01) File->Type = GSM_File_Sound_AMR; else if (msg.Buffer[i]==0x04 && msg.Buffer[i+2]==0x02) File->Type = GSM_File_Sound_MIDI; else if (msg.Buffer[i]==0x08 && msg.Buffer[i+2]==0x05) File->Type = GSM_File_Video_3GP; else if (msg.Buffer[i]==0x10 && msg.Buffer[i+2]==0x01) File->Type = GSM_File_Java_JAR; -#if DEVELOP +#ifdef DEVELOP else if (msg.Buffer[i]==0x00 && msg.Buffer[i+2]==0x01) File->Type = GSM_File_MMS; #endif } return ERR_NONE; case 0x2F: smprintf(s,"File or folder used bytes received\n"); File->Used = msg.Buffer[6]*256*256*256+ msg.Buffer[7]*256*256+ msg.Buffer[8]*256+ msg.Buffer[9]; return ERR_NONE; case 0x33: if (s->Phone.Data.RequestID == ID_GetFileInfo) { i = Priv->FilesLocationsUsed-1; while (1) { if (i==Priv->FilesLocationsCurrent-1) break; dbgprintf("Copying %i to %i, max %i, current %i\n", i,i+msg.Buffer[9], Priv->FilesLocationsUsed,Priv->FilesLocationsCurrent); Priv->FilesLocations[i+msg.Buffer[9]] = Priv->FilesLocations[i]; Priv->FilesLevels[i+msg.Buffer[9]] = Priv->FilesLevels[i]; i--; } Priv->FilesLocationsUsed += msg.Buffer[9]; for (i=0;i<msg.Buffer[9];i++) { Priv->FilesLocations[Priv->FilesLocationsCurrent+i] = msg.Buffer[13+i*4-1]*256 + msg.Buffer[13+i*4]; Priv->FilesLevels[Priv->FilesLocationsCurrent+i] = File->Level+1; dbgprintf("%i ",Priv->FilesLocations[Priv->FilesLocationsCurrent+i]); } dbgprintf("\n"); } if (msg.Buffer[9] != 0x00) File->Folder = true; return ERR_NONE; case 0x43: Priv->FileCheckSum = msg.Buffer[6] * 256 + msg.Buffer[7]; smprintf(s,"File checksum from phone is %04X\n",Priv->FileCheckSum); return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_GetFileFolderInfo(GSM_StateMachine *s, GSM_File *File, GSM_Phone_RequestID Request) { GSM_Error error; unsigned char req[10] = { N7110_FRAME_HEADER, 0x14, /* 0x14 - info, 0x22 - free/total, 0x2E - used, 0x32 - sublocations */ @@ -4353,97 +4435,97 @@ static GSM_Error N6510_SetReadOnly(GSM_StateMachine *s, unsigned char *ID, bool smprintf(s, "Setting readonly attribute\n"); return GSM_WaitFor (s, SetAttr, 10, 0x6D, 4, ID_DeleteFile); } static GSM_Error N6510_ReplyAddFileHeader(GSM_Protocol_Message msg, GSM_StateMachine *s) { switch (msg.Buffer[3]) { case 0x03: smprintf(s,"File header added\n"); sprintf(s->Phone.Data.File->ID_FullName,"%i",msg.Buffer[9]); return ERR_NONE; case 0x13: return ERR_NONE; } return ERR_UNKNOWNRESPONSE; } static GSM_Error N6510_ReplyAddFilePart(GSM_Protocol_Message msg, GSM_StateMachine *s) { return ERR_NONE; } static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos) { GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510; GSM_File File2; GSM_Error error; int j; unsigned char Header[400] = { N7110_FRAME_HEADER, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0C, /* parent folder ID */ 0x00, 0x00, 0x00, 0xE8}; unsigned char Add[15000] = { N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, /* file ID */ 0x00, 0x00, 0x01, 0x28}; /* length */ unsigned char end[30] = { N7110_FRAME_HEADER, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, /* file ID */ 0x00, 0x00, 0x00, 0x00}; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_NOFILESYSTEM)) return ERR_NOTSUPPORTED; s->Phone.Data.File = File; if (*Pos == 0) { error = N6510_SearchForFileName(s,File); - if (error == ERR_NONE) return ERR_INVALIDLOCATION; + if (error == ERR_NONE) return ERR_FILEALREADYEXIST; if (error != ERR_EMPTY) return error; Header[8] = atoi(File->ID_FullName) / 256; Header[9] = atoi(File->ID_FullName) % 256; memset(Header+14, 0x00, 300); CopyUnicodeString(Header+14,File->Name); Header[222] = File->Used / (256*256*256); Header[223] = File->Used / (256*256); Header[224] = File->Used / 256; Header[225] = File->Used % 256; switch(File->Type) { case GSM_File_Image_JPG : Header[231]=0x02; Header[233]=0x01; break; case GSM_File_Image_BMP : Header[231]=0x02; Header[233]=0x02; break; case GSM_File_Image_PNG : Header[231]=0x02; Header[233]=0x03; break; case GSM_File_Image_GIF : Header[231]=0x02; Header[233]=0x05; break; case GSM_File_Image_WBMP : Header[231]=0x02; Header[233]=0x09; break; case GSM_File_Sound_AMR : Header[231]=0x04; Header[233]=0x01; break; case GSM_File_Sound_MIDI : Header[231]=0x04; Header[233]=0x05; break; //Header[238]=0x01; case GSM_File_Sound_NRT : Header[231]=0x04; Header[233]=0x06; break; case GSM_File_Video_3GP : Header[231]=0x08; Header[233]=0x05; break; case GSM_File_Java_JAR : Header[231]=0x10; Header[233]=0x01; break; #ifdef DEVELOP case GSM_File_MMS: Header[214]=0x07; Header[215]=0xd3; Header[216]=0x06; Header[217]=0x01; Header[218]=0x12; Header[219]=0x13; Header[220]=0x29; Header[233]=0x01; break; #endif default : Header[231]=0x01; Header[233]=0x05; } Header[235] = 0x01; Header[236] = atoi(File->ID_FullName) / 256; Header[237] = atoi(File->ID_FullName) % 256; if (File->Protected) Header[238] = 0x01; //Nokia forward lock if (File->Hidden) Header[241] = 0x01; if (File->System) Header[242] = 0x01; //fixme smprintf(s, "Adding file header\n"); error=GSM_WaitFor (s, Header, 246, 0x6D, 4, ID_AddFile); if (error != ERR_NONE) return error; } j = 1000; if (File->Used - *Pos < 1000) j = File->Used - *Pos; @@ -4769,97 +4851,97 @@ static GSM_Error N6510_SetGPRSAccessPoint(GSM_StateMachine *s, GSM_GPRSAccessPoi error=GSM_WaitFor (s, buff, s->Phone.Data.Priv.N6510.GPRSPointsLength, 0x43, 4, ID_SetGPRSPoint); if (error != ERR_NONE) return error; } return error; } /* ToDo support - 6310 style */ static GSM_Error N6510_ReplyGetToDoStatus1(GSM_Protocol_Message msg, GSM_StateMachine *s) { int i; GSM_NOKIACalToDoLocations *Last = &s->Phone.Data.Priv.N6510.LastToDo; smprintf(s, "TODO locations received\n"); Last->Number=msg.Buffer[6]*256+msg.Buffer[7]; smprintf(s, "Number of Entries: %i\n",Last->Number); smprintf(s, "Locations: "); for (i=0;i<Last->Number;i++) { Last->Location[i]=msg.Buffer[12+(i*4)]*256+msg.Buffer[(i*4)+13]; smprintf(s, "%i ",Last->Location[i]); } smprintf(s, "\n"); return ERR_NONE; } /* ToDo support - 6310 style */ static GSM_Error N6510_GetToDoStatus1(GSM_StateMachine *s, GSM_ToDoStatus *status) { GSM_Error error; GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; unsigned char reqLoc[] = { N6110_FRAME_HEADER, 0x15, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}; smprintf(s, "Getting ToDo locations\n"); error = GSM_WaitFor (s, reqLoc, 10, 0x55, 4, ID_GetToDo); if (error != ERR_NONE) return error; status->Used = LastToDo->Number; return ERR_NONE; } static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *status) { GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; GSM_Error error; - error = N6510_GetCalendarInfo3(s,LastToDo,false); + error = N6510_GetCalendarInfo3(s,LastToDo,1); if (error!=ERR_NONE) return error; status->Used = LastToDo->Number; return ERR_NONE; } static GSM_Error N6510_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) { status->Used = 0; if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { return N6510_GetToDoStatus1(s, status); } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { return N6510_GetToDoStatus2(s, status); } else { return ERR_NOTSUPPORTED; } } /* ToDo support - 6310 style */ static GSM_Error N6510_ReplyGetToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) { GSM_ToDoEntry *Last = s->Phone.Data.ToDo; smprintf(s, "TODO received method 1\n"); switch (msg.Buffer[4]) { case 1 : Last->Priority = GSM_Priority_High; break; case 2 : Last->Priority = GSM_Priority_Medium; break; case 3 : Last->Priority = GSM_Priority_Low; break; default : return ERR_UNKNOWN; } smprintf(s, "Priority: %i\n",msg.Buffer[4]); CopyUnicodeString(Last->Entries[0].Text,msg.Buffer+14); Last->Entries[0].EntryType = TODO_TEXT; Last->EntriesNum = 1; smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); return ERR_NONE; } /* ToDo support - 6310 style */ static GSM_Error N6510_GetNextToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) { GSM_Error error; GSM_ToDoStatus status; GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; @@ -4899,196 +4981,187 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine smprintf(s, "ToDo received method 2\n"); switch (msg.Buffer[44]) { case 0x10: Last->Priority = GSM_Priority_Low; break; case 0x20: Last->Priority = GSM_Priority_Medium; break; case 0x30: Last->Priority = GSM_Priority_High; break; default : return ERR_UNKNOWN; } memcpy(Last->Entries[0].Text,msg.Buffer+54,msg.Buffer[51]*2); Last->Entries[0].Text[msg.Buffer[51]*2] = 0; Last->Entries[0].Text[msg.Buffer[51]*2+1] = 0; Last->Entries[0].EntryType = TODO_TEXT; smprintf(s, "Text: \"%s\"\n",DecodeUnicodeString(Last->Entries[0].Text)); smprintf(s,"EndTime: %04i-%02i-%02i %02i:%02i\n", msg.Buffer[34]*256+msg.Buffer[35], msg.Buffer[36],msg.Buffer[37],msg.Buffer[38], msg.Buffer[39]); Date.Year = msg.Buffer[34]*256+msg.Buffer[35]; Date.Month = msg.Buffer[36]; Date.Day = msg.Buffer[37]; Date.Hour = msg.Buffer[38]; Date.Minute = msg.Buffer[39]; Date.Second = 0; Last->Entries[1].EntryType = TODO_END_DATETIME; memcpy(&Last->Entries[1].Date,&Date,sizeof(GSM_DateTime)); smprintf(s,"StartTime: %04i-%02i-%02i %02i:%02i\n", msg.Buffer[28]*256+msg.Buffer[29], msg.Buffer[30],msg.Buffer[31],msg.Buffer[32], msg.Buffer[33]); Date.Year = msg.Buffer[28]*256+msg.Buffer[29]; Date.Month = msg.Buffer[30]; Date.Day = msg.Buffer[31]; Date.Hour = msg.Buffer[32]; Date.Minute = msg.Buffer[33]; Date.Second = 0; Last->EntriesNum = 2; if (msg.Buffer[45] == 0x01) { Last->Entries[2].Number = msg.Buffer[45]; Last->Entries[2].EntryType = TODO_COMPLETED; Last->EntriesNum++; smprintf(s,"Completed\n"); } - if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) - { + if (msg.Buffer[14] == 0xFF && msg.Buffer[15] == 0xFF && msg.Buffer[16] == 0xff && msg.Buffer[17] == 0xff) { smprintf(s, "No alarm\n"); } else { diff = ((unsigned int)msg.Buffer[14]) << 24; diff += ((unsigned int)msg.Buffer[15]) << 16; diff += ((unsigned int)msg.Buffer[16]) << 8; diff += msg.Buffer[17]; memcpy(&Last->Entries[Last->EntriesNum].Date,&Date,sizeof(GSM_DateTime)); GetTimeDifference(diff, &Last->Entries[Last->EntriesNum].Date, false, 60); smprintf(s, "Alarm date : %02i-%02i-%04i %02i:%02i:%02i\n", Last->Entries[Last->EntriesNum].Date.Day, Last->Entries[Last->EntriesNum].Date.Month, Last->Entries[Last->EntriesNum].Date.Year, Last->Entries[Last->EntriesNum].Date.Hour, Last->Entries[Last->EntriesNum].Date.Minute,Last->Entries[Last->EntriesNum].Date.Second); Last->Entries[Last->EntriesNum].EntryType = TODO_ALARM_DATETIME; if (msg.Buffer[22]==0x00 && msg.Buffer[23]==0x00 && msg.Buffer[24]==0x00 && msg.Buffer[25]==0x00) { Last->Entries[Last->EntriesNum].EntryType = TODO_SILENT_ALARM_DATETIME; smprintf(s, "Alarm type : Silent\n"); } Last->EntriesNum++; } return ERR_NONE; } /* ToDo support - 6610 style */ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) { GSM_Error error; GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; - /* The same to getting calendar method 3 */ - unsigned char req[] = { - N6110_FRAME_HEADER,0x7D,0x00,0x00,0x00,0x00, - 0x00,0x99, /* Location */ - 0xff,0xff,0xff,0xff,0x01}; if (refresh) { - error=N6510_GetCalendarInfo3(s,LastToDo,false); + error=N6510_GetCalendarInfo3(s,LastToDo,1); if (error!=ERR_NONE) return error; ToDo->Location = 1; } else { ToDo->Location++; } if (ToDo->Location > LastToDo->Number) return ERR_EMPTY; - req[8] = LastToDo->Location[ToDo->Location-1] / 256; - req[9] = LastToDo->Location[ToDo->Location-1] % 256; - s->Phone.Data.ToDo = ToDo; smprintf(s, "Getting todo method 2\n"); - return GSM_WaitFor (s, req, 15, 0x13, 4, ID_GetToDo); + return N6510_PrivGetGenericCalendar3(s, LastToDo->Location[ToDo->Location-1], ID_GetToDo); } static GSM_Error N6510_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool refresh) { if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { return N6510_GetNextToDo1(s, ToDo, refresh); } else if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { return N6510_GetNextToDo2(s, ToDo, refresh); } else { return ERR_NOTSUPPORTED; } } /* ToDo support - 6310 style */ static GSM_Error N6510_ReplyDeleteAllToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "All TODO deleted\n"); return ERR_NONE; } /* ToDo support - 6310 style */ static GSM_Error N6510_DeleteAllToDo1(GSM_StateMachine *s) { unsigned char req[] = {N6110_FRAME_HEADER, 0x11}; if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO63)) { return ERR_NOTSUPPORTED; } smprintf(s, "Deleting all ToDo method 1\n"); return GSM_WaitFor (s, req, 4, 0x55, 4, ID_DeleteAllToDo); } static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) { GSM_Error error; GSM_NOKIACalToDoLocations *LastToDo = &s->Phone.Data.Priv.N6510.LastToDo; GSM_CalendarEntry Note; if (!IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_TODO66)) { return ERR_NOTSUPPORTED; } - error=N6510_GetCalendarInfo3(s,LastToDo,false); + error=N6510_GetCalendarInfo3(s,LastToDo,1); if (error!=ERR_NONE) return error; smprintf(s, "Deleting ToDo method 2\n"); if (ToDo->Location > LastToDo->Number || ToDo->Location == 0) return ERR_INVALIDLOCATION; Note.Location = LastToDo->Location[ToDo->Location-1]; return N71_65_DelCalendar(s,&Note); } /* ToDo support - 6310 style */ static GSM_Error N6510_ReplyGetToDoFirstLoc1(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "TODO first location received method 1: %02x\n",msg.Buffer[9]); s->Phone.Data.ToDo->Location = msg.Buffer[9]; return ERR_NONE; } /* ToDo support - 6310 style */ static GSM_Error N6510_ReplyAddToDo1(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "TODO set OK\n"); return ERR_NONE; } /* ToDo support - 6310 style */ static GSM_Error N6510_AddToDo1(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) { int Text, Alarm, EndTime, Completed, ulen, Phone; GSM_Error error; unsigned char reqLoc[] = {N6110_FRAME_HEADER, 0x0F}; unsigned char reqSet[500] = { N6110_FRAME_HEADER, 0x01, 0x03, /* Priority */ 0x00, /* Length of text */ 0x80,0x00,0x00, 0x18}; /* Location */ s->Phone.Data.ToDo = ToDo; smprintf(s, "Getting first ToDo location\n"); error = GSM_WaitFor (s, reqLoc, 4, 0x55, 4, ID_SetToDo); if (error != ERR_NONE) return error; reqSet[9] = ToDo->Location; switch (ToDo->Priority) { case GSM_Priority_Low : reqSet[4] = 3; break; case GSM_Priority_Medium: reqSet[4] = 2; break; @@ -5406,160 +5479,168 @@ static GSM_Error N6510_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *book smprintf(s, "Setting WAP bookmark\n"); error = GSM_WaitFor (s, req, count, 0x3f, 4, ID_SetWAPBookmark); if (error != ERR_NONE) { if (error == ERR_INSIDEPHONEMENU || error == ERR_EMPTY || error == ERR_FULL) { DCT3DCT4_DisableConnectionFunctions(s); } return error; } return DCT3DCT4_DisableConnectionFunctions(s); } GSM_Error N6510_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) { GSM_Error error; /* We have to enable WAP frames in phone */ error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); if (error!=ERR_NONE) return error; return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); } GSM_Error N6510_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) { GSM_Error error; /* We have to enable WAP frames in phone */ error=N6510_EnableConnectionFunctions(s,N6510_WAP_SETTINGS); if (error!=ERR_NONE) return error; return DCT3DCT4_GetWAPBookmarkPart(s,bookmark); } static GSM_Reply_Function N6510ReplyFunctions[] = { {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall }, {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall }, {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_DialVoice }, {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame }, + {N71_65_ReplyCallInfo, "\x01",0x03,0x0F,ID_IncomingFrame }, + {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_DialVoice }, + {N71_65_ReplyCallInfo, "\x01",0x03,0x10,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame }, {N71_65_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame }, {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF }, {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame }, {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF }, {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF }, + {N71_65_ReplyCallInfo, "\x01",0x03,0xA6,ID_IncomingFrame }, + {N71_65_ReplyCallInfo, "\x01",0x03,0xD2,ID_IncomingFrame }, + {N71_65_ReplyCallInfo, "\x01",0x03,0xD3,ID_IncomingFrame }, {N6510_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame }, {N6510_ReplyIncomingSMS, "\x02",0x03,0x04,ID_IncomingFrame }, {N6510_ReplySetSMSC, "\x02",0x03,0x13,ID_SetSMSC }, {N6510_ReplyGetSMSC, "\x02",0x03,0x15,ID_GetSMSC }, {N6510_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus }, {N6510_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory }, {N6510_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory }, {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap }, {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory }, {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert }, {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame }, {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame }, {NoneReply, "\x06",0x03,0x09,ID_IncomingFrame }, {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x08,ID_EnterSecurityCode }, {N6510_ReplyEnterSecurityCode, "\x08",0x03,0x09,ID_EnterSecurityCode }, {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus }, {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo }, {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame }, {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame }, {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality }, {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame }, {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame }, {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap }, {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap }, {NoneReply, "\x0B",0x03,0x01,ID_PlayTone }, {NoneReply, "\x0B",0x03,0x15,ID_PlayTone }, {NoneReply, "\x0B",0x03,0x16,ID_PlayTone }, {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote }, {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote }, {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote }, {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote }, {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote }, {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/ {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/ {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/ #ifdef DEBUG {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote }, #endif {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/ {N6510_ReplyAddCalendar3, "\x13",0x03,0x66,ID_SetCalendarNote },/*method 3*/ {N6510_ReplyAddToDo2, "\x13",0x03,0x66,ID_SetToDo }, {N6510_ReplyGetCalendar3, "\x13",0x03,0x7E,ID_GetCalendarNote },/*method 3*/ {N6510_ReplyGetToDo2, "\x13",0x03,0x7E,ID_GetToDo }, + {N6510_ReplyGetNote, "\x13",0x03,0x7E,ID_GetNote }, {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x86,ID_GetCalendarSettings }, {N6510_ReplyGetLocale, "\x13",0x03,0x8A,ID_GetLocale }, {N6510_ReplyGetCalendarSettings, "\x13",0x03,0x8E,ID_GetCalendarSettings }, {N6510_ReplyGetCalendarNotePos, "\x13",0x03,0x96,ID_GetCalendarNotePos },/*method 3*/ {N6510_ReplyGetToDoFirstLoc2, "\x13",0x03,0x96,ID_SetToDo }, {N6510_ReplyGetCalendarInfo, "\x13",0x03,0x9F,ID_GetCalendarNotesInfo},/*method 3*/ {N6510_ReplyGetToDoStatus2, "\x13",0x03,0x9F,ID_GetToDo }, + {N6510_ReplyGetNoteInfo, "\x13",0x03,0x9F,ID_GetNote }, {N6510_ReplySaveSMSMessage, "\x14",0x03,0x01,ID_SaveSMSMessage }, {N6510_ReplySetPicture, "\x14",0x03,0x01,ID_SetBitmap }, {N6510_ReplyGetSMSMessage, "\x14",0x03,0x03,ID_GetSMSMessage }, {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x05,ID_DeleteSMSMessage }, {N6510_ReplyDeleteSMSMessage, "\x14",0x03,0x06,ID_DeleteSMSMessage }, {N6510_ReplyGetSMSStatus, "\x14",0x03,0x09,ID_GetSMSStatus }, {N6510_ReplyGetSMSFolderStatus, "\x14",0x03,0x0d,ID_GetSMSFolderStatus }, {N6510_ReplyGetSMSMessage, "\x14",0x03,0x0f,ID_GetSMSMessage }, {N6510_ReplyAddSMSFolder, "\x14",0x03,0x11,ID_AddSMSFolder }, {N6510_ReplyGetSMSFolders, "\x14",0x03,0x13,ID_GetSMSFolders }, {N6510_ReplySaveSMSMessage, "\x14",0x03,0x17,ID_SaveSMSMessage }, {N6510_ReplyGetSMSStatus, "\x14",0x03,0x1a,ID_GetSMSStatus }, {DCT4_ReplySetPhoneMode, "\x15",0x03,0x64,ID_Reset }, {DCT4_ReplyGetPhoneMode, "\x15",0x03,0x65,ID_Reset }, {NoneReply, "\x15",0x03,0x68,ID_Reset }, {N6510_ReplyGetBatteryCharge, "\x17",0x03,0x0B,ID_GetBatteryCharge }, {N6510_ReplySetDateTime, "\x19",0x03,0x02,ID_SetDateTime }, {N6510_ReplyGetDateTime, "\x19",0x03,0x0B,ID_GetDateTime }, {N6510_ReplySetAlarm, "\x19",0x03,0x12,ID_SetAlarm }, {N6510_ReplyGetAlarm, "\x19",0x03,0x1A,ID_GetAlarm }, {N6510_ReplyGetAlarm, "\x19",0x03,0x20,ID_GetAlarm }, {DCT4_ReplyGetIMEI, "\x1B",0x03,0x01,ID_GetIMEI }, {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x08,ID_GetHardware }, {N6510_ReplyGetPPM, "\x1B",0x03,0x08,ID_GetPPM }, {NOKIA_ReplyGetPhoneString, "\x1B",0x03,0x0C,ID_GetProductCode }, /* 0x1C - vibra */ {N6510_ReplyGetRingtonesInfo, "\x1f",0x03,0x08,ID_GetRingtonesInfo }, {N6510_ReplyDeleteRingtones, "\x1f",0x03,0x11,ID_SetRingtone }, {N6510_ReplyGetRingtone, "\x1f",0x03,0x13,ID_GetRingtone }, {N6510_ReplySetBinRingtone, "\x1f",0x03,0x0F,ID_SetRingtone }, /* 0x23 - voice records */ {N6510_ReplyGetProfile, "\x39",0x03,0x02,ID_GetProfile }, {N6510_ReplySetProfile, "\x39",0x03,0x04,ID_SetProfile }, {N6510_ReplyGetProfile, "\x39",0x03,0x06,ID_GetProfile }, {N6510_ReplySetLight, "\x3A",0x03,0x06,ID_SetLight }, {N6510_ReplyGetFMStation, "\x3E",0x03,0x06,ID_GetFMStation }, {N6510_ReplyGetFMStatus, "\x3E",0x03,0x0E,ID_GetFMStation }, @@ -5606,177 +5687,178 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { /* 0x53 - simlock */ {N6510_ReplyAddToDo1, "\x55",0x03,0x02,ID_SetToDo }, {N6510_ReplyGetToDo1, "\x55",0x03,0x04,ID_GetToDo }, {N6510_ReplyGetToDoFirstLoc1, "\x55",0x03,0x10,ID_SetToDo }, {N6510_ReplyDeleteAllToDo1, "\x55",0x03,0x12,ID_DeleteAllToDo }, {N6510_ReplyGetToDoStatus1, "\x55",0x03,0x16,ID_GetToDo }, {N6510_ReplyAddFileHeader, "\x6D",0x03,0x03,ID_AddFile }, {N6510_ReplyAddFolder, "\x6D",0x03,0x05,ID_AddFolder }, {N6510_ReplyGetFilePart, "\x6D",0x03,0x0F,ID_GetFile }, {N6510_ReplyAddFileHeader, "\x6D",0x03,0x13,ID_AddFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFileInfo }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_GetFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x15,ID_AddFile }, {N6510_ReplyDeleteFile, "\x6D",0x03,0x19,ID_DeleteFile }, {N6510_ReplyDeleteFile, "\x6D",0x03,0x1F,ID_DeleteFile }, {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x23,ID_FileSystemStatus }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFileInfo }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x2F,ID_GetFile }, {N6510_ReplyGetFileSystemStatus, "\x6D",0x03,0x2F,ID_FileSystemStatus }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFileInfo }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x33,ID_GetFile }, {N6510_ReplyAddFilePart, "\x6D",0x03,0x41,ID_AddFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_AddFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFile }, {N6510_ReplyGetFileFolderInfo, "\x6D",0x03,0x43,ID_GetFileInfo }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_GetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x01,ID_SetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_GetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x0F,ID_SetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_GetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x10,ID_SetBitmap }, {N6510_ReplyStartupNoteLogo, "\x7A",0x04,0x25,ID_SetBitmap }, {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel }, {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware }, /* 0xD7 - Bluetooth */ {N6510_ReplyGetRingtoneID, "\xDB",0x03,0x02,ID_SetRingtone }, {NULL, "\x00",0x00,0x00,ID_None } }; GSM_Phone_Functions N6510Phone = { - "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6800|7210|7250|7250i|7600|8310|8390|8910|8910i", + "1100|1100a|1100b|3100|3100b|3108|3200|3200a|3300|3510|3510i|3530|3589i|3590|3595|5100|5140|6100|6200|6220|6230|6310|6310i|6385|6510|6610|6610i|6800|6810|6820|7210|7250|7250i|7600|8310|8390|8910|8910i", N6510ReplyFunctions, N6510_Initialise, NONEFUNCTION, /* Terminate */ GSM_DispatchMessage, N6510_ShowStartInfo, NOKIA_GetManufacturer, DCT3DCT4_GetModel, DCT3DCT4_GetFirmware, DCT4_GetIMEI, N6510_GetOriginalIMEI, N6510_GetManufactureMonth, DCT4_GetProductCode, DCT4_GetHardware, N6510_GetPPM, NOTSUPPORTED, /* GetSIMIMSI */ N6510_GetDateTime, N6510_SetDateTime, N6510_GetAlarm, N6510_SetAlarm, N6510_GetLocale, NOTSUPPORTED, /* SetLocale */ N6510_PressKey, DCT4_Reset, NOTIMPLEMENTED, /* ResetPhoneSettings */ N6510_EnterSecurityCode, N6510_GetSecurityStatus, NOTSUPPORTED, /* GetDisplayStatus */ NOTIMPLEMENTED, /* SetAutoNetworkLogin */ N6510_GetBatteryCharge, N6510_GetSignalQuality, N6510_GetNetworkInfo, NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTSUPPORTED, /* GetCategoryStatus */ N6510_GetMemoryStatus, N6510_GetMemory, NOTIMPLEMENTED, /* GetNextMemory */ N6510_SetMemory, NOTIMPLEMENTED, /* AddMemory */ N6510_DeleteMemory, NOTIMPLEMENTED, /* DeleteAllMemory */ N6510_GetSpeedDial, NOTIMPLEMENTED, /* SetSpeedDial */ N6510_GetSMSC, N6510_SetSMSC, N6510_GetSMSStatus, N6510_GetSMSMessage, N6510_GetNextSMSMessage, N6510_SetSMS, N6510_AddSMS, N6510_DeleteSMSMessage, N6510_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOKIA_SetIncomingSMS, NOTIMPLEMENTED, /* SetIncomingCB */ N6510_GetSMSFolders, N6510_AddSMSFolder, NOTIMPLEMENTED, /* DeleteSMSFolder */ N6510_DialVoice, N6510_AnswerCall, N6510_CancelCall, NOTIMPLEMENTED, /* HoldCall */ NOTIMPLEMENTED, /* UnholdCall */ NOTIMPLEMENTED, /* ConferenceCall */ NOTIMPLEMENTED, /* SplitCall */ NOTIMPLEMENTED, /* TransferCall */ NOTIMPLEMENTED, /* SwitchCall */ DCT3DCT4_GetCallDivert, DCT3DCT4_SetCallDivert, DCT3DCT4_CancelAllDiverts, NOKIA_SetIncomingCall, NOKIA_SetIncomingUSSD, DCT3DCT4_SendDTMF, N6510_GetRingtone, N6510_SetRingtone, N6510_GetRingtonesInfo, N6510_DeleteUserRingtones, N6510_PlayTone, N6510_GetWAPBookmark, N6510_SetWAPBookmark, N6510_DeleteWAPBookmark, N6510_GetWAPSettings, N6510_SetWAPSettings, N6510_GetMMSSettings, N6510_SetMMSSettings, N6510_GetSyncMLSettings, NOTSUPPORTED, /* SetSyncMLSettings */ N6510_GetChatSettings, NOTSUPPORTED, /* SetChatSettings */ N6510_GetBitmap, N6510_SetBitmap, N6510_GetToDoStatus, NOTIMPLEMENTED, /* GetToDo */ N6510_GetNextToDo, NOTIMPLEMENTED, /* SetToDo */ N6510_AddToDo, N6510_DeleteToDo2, N6510_DeleteAllToDo1, N6510_GetCalendarStatus, NOTIMPLEMENTED, /* GetCalendar */ N6510_GetNextCalendar, NOTIMPLEMENTED, /* SetCalendar */ N6510_AddCalendar, N71_65_DelCalendar, NOTIMPLEMENTED, /* DeleteAllCalendar */ N6510_GetCalendarSettings, NOTSUPPORTED, /* SetCalendarSettings */ - NOTIMPLEMENTED, /* GetNote */ + N6510_GetNextNote, N6510_GetProfile, N6510_SetProfile, N6510_GetFMStation, N6510_SetFMStation, N6510_ClearFMStations, N6510_GetNextFileFolder, N6510_GetFilePart, N6510_AddFilePart, N6510_GetFileSystemStatus, N6510_DeleteFile, N6510_AddFolder, N6510_GetGPRSAccessPoint, N6510_SetGPRSAccessPoint }; #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/nokia/dct4/n6510.h b/gammu/emb/common/phone/nokia/dct4/n6510.h index 4717aeb..26623d6 100644 --- a/gammu/emb/common/phone/nokia/dct4/n6510.h +++ b/gammu/emb/common/phone/nokia/dct4/n6510.h @@ -1,84 +1,86 @@ /* (c) 2002-2004 by Marcin Wiacek */ #ifndef n6510_h #define n6510_h #include "../ncommon.h" #include "../../../service/sms/gsmsms.h" typedef enum { N6510_MMS_SETTINGS = 0x01, N6510_CHAT_SETTINGS, N6510_WAP_SETTINGS, N6510_SYNCML_SETTINGS } N6510_Connection_Settings; typedef enum { N6510_LIGHT_DISPLAY = 0x01, N6510_LIGHT_KEYPAD = 0x03, N6510_LIGHT_TORCH = 0x10 } N6510_PHONE_LIGHTS; typedef struct { int LastCalendarYear; int LastCalendarPos; GSM_NOKIACalToDoLocations LastCalendar; int FirstCalendarPos; unsigned char CalendarIcons[10]; GSM_CalendarNoteType CalendarIconsTypes[10]; int CalendarIconsNum; GSM_NOKIASMSFolder LastSMSFolder; GSM_SMSFolders LastSMSFolders; GSM_NOKIACalToDoLocations LastToDo; + GSM_NOKIACalToDoLocations LastNote; + unsigned char RingtoneID; /* When set with preview */ int FilesLocations[1000]; int FilesLevels[1000]; int FilesLocationsUsed; int FilesLocationsCurrent; int FileToken; int ParentID; int FileCheckSum; unsigned char FMStatus[4000]; int FMStatusLength; unsigned char GPRSPoints[4000]; int GPRSPointsLength; int BearerNumber; unsigned char PhoneMode; } GSM_Phone_N6510Data; void N6510_EncodeFMFrequency(double freq, unsigned char *buff); void N6510_DecodeFMFrequency(double *freq, unsigned char *buff); #ifndef GSM_USED_MBUS2 # define GSM_USED_MBUS2 #endif #ifndef GSM_USED_FBUS2 # define GSM_USED_FBUS2 #endif #ifndef GSM_USED_FBUS2DLR3 # define GSM_USED_FBUS2DLR3 #endif #ifndef GSM_USED_FBUS2DKU5 # define GSM_USED_FBUS2DKU5 #endif #ifndef GSM_USED_PHONETBLUE # define GSM_USED_PHONETBLUE #endif #ifndef GSM_USED_IRDAPHONET # define GSM_USED_IRDAPHONET #endif #ifndef GSM_USED_BLUEPHONET # define GSM_USED_BLUEPHONET #endif #ifndef GSM_USED_FBUS2PL2303 # define GSM_USED_FBUS2PL2303 #endif diff --git a/gammu/emb/common/phone/nokia/nauto.c b/gammu/emb/common/phone/nokia/nauto.c index bf74bc9..3bb53ec 100644 --- a/gammu/emb/common/phone/nokia/nauto.c +++ b/gammu/emb/common/phone/nokia/nauto.c @@ -76,69 +76,69 @@ GSM_Phone_Functions NAUTOPhone = { NOTSUPPORTED, /* GetSMSFolders */ NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ NOTSUPPORTED, /* DialVoice */ NOTSUPPORTED, /* AnswerCall */ NOTSUPPORTED, /* CancelCall */ NOTSUPPORTED, /* HoldCall */ NOTSUPPORTED, /* UnholdCall */ NOTSUPPORTED, /* ConferenceCall */ NOTSUPPORTED, /* SplitCall */ NOTSUPPORTED, /* TransferCall */ NOTSUPPORTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NOTSUPPORTED, /* SetIncomingCall */ NOTSUPPORTED, /* SetIncomingUSSD */ NOTSUPPORTED, /* SendDTMF */ NOTSUPPORTED, /* GetRingtone */ NOTSUPPORTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetBitmap */ NOTSUPPORTED, /* SetBitmap */ NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ NOTSUPPORTED, /* GetCalendarStatus */ NOTSUPPORTED, /* GetCalendar */ NOTSUPPORTED, /* GetNextCalendar */ NOTSUPPORTED, /* SetCalendar */ NOTSUPPORTED, /* AddCalendar */ NOTSUPPORTED, /* DeleteCalendar */ NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ NOTSUPPORTED, /* GetNextFileFolder */ NOTSUPPORTED, /* GetFilePart */ NOTSUPPORTED, /* AddFilePart */ 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: */ diff --git a/gammu/emb/common/phone/nokia/nfunc.c b/gammu/emb/common/phone/nokia/nfunc.c index 3acfb10..d4d8b03 100644 --- a/gammu/emb/common/phone/nokia/nfunc.c +++ b/gammu/emb/common/phone/nokia/nfunc.c @@ -1348,125 +1348,139 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii tmp = 6; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); /* FIXME: read name from frame */ call.Status = GSM_CALL_CallStart; break; case 0x04: smprintf(s, "Remote end hang up\n"); smprintf(s, "Cause Type : %i\n",msg.Buffer[5]);//such interpretation is in gnokii smprintf(s, "CC : %i\n",msg.Buffer[6]); smprintf(s, "MM(?) : %i\n",msg.Buffer[7]); smprintf(s, "RR(?) : %i\n",msg.Buffer[8]); call.Status = GSM_CALL_CallRemoteEnd; call.StatusCode = msg.Buffer[6]; break; case 0x05: smprintf(s, "Incoming call\n"); smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii tmp = 6; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); /* FIXME: read name from frame */ call.Status = GSM_CALL_IncomingCall; tmp = 6; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false); break; case 0x07: smprintf(s, "Call answer initiated\n"); break; case 0x09: smprintf(s, "Call released\n"); call.Status = GSM_CALL_CallLocalEnd; break; case 0x0a: smprintf(s, "Call is being released\n"); break; case 0x0b: smprintf(s, "Meaning not known\n"); call.CallIDAvailable = false; break; case 0x0c: smprintf(s, "Audio status\n"); if (msg.Buffer[4] == 0x01) smprintf(s, "Audio enabled\n"); else smprintf(s, "Audio disabled\n"); call.CallIDAvailable = false; break; + case 0x0f: + case 0x10: + smprintf(s, "Meaning not known\n"); + call.CallIDAvailable = false; + break; case 0x23: smprintf(s, "Call held\n"); call.Status = GSM_CALL_CallHeld; break; case 0x25: smprintf(s, "Call resumed\n"); call.Status = GSM_CALL_CallResumed; break; case 0x27: smprintf(s, "Call switched\n"); call.Status = GSM_CALL_CallSwitched; break; case 0x53: smprintf(s, "Outgoing call\n"); smprintf(s, "Call mode : %i\n",msg.Buffer[5]);//such interpretation is in gnokii tmp = 6; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,buffer,false); smprintf(s, "Number : \"%s\"\n",DecodeUnicodeString(buffer)); /* FIXME: read name from frame */ call.Status = GSM_CALL_OutgoingCall; tmp = 6; NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,call.PhoneNumber,false); break; + case 0xA6: + case 0xD2: + case 0xD3: + smprintf(s, "Meaning not known\n"); + call.CallIDAvailable = false; + break; } if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg.Buffer[4]); if (s->Phone.Data.EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) { if (call.CallIDAvailable) call.CallID = msg.Buffer[4]; s->User.IncomingCall(s->CurrentConfig->Device, call); } + if (s->Phone.Data.RequestID == ID_DialVoice) { + if (msg.Buffer[3] == 0x10) return ERR_NOTSUPPORTED; + } if (s->Phone.Data.RequestID == ID_CancelCall) { if (msg.Buffer[3] == 0x09) { if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE; /* when we canceled call and see frame about other * call releasing, we don't give ERR_NONE for "our" * call release command */ return ERR_NEEDANOTHERANSWER; } } if (s->Phone.Data.RequestID == ID_AnswerCall) { if (msg.Buffer[3] == 0x07) { if (s->Phone.Data.CallID == msg.Buffer[4]) return ERR_NONE; return ERR_NEEDANOTHERANSWER; } } return ERR_NONE; } void N71_65_GetCalendarRecurrance(GSM_StateMachine *s, unsigned char *buffer, GSM_CalendarEntry *entry) { int Recurrance; Recurrance = buffer[0]*256 + buffer[1]; /* 8760 hours = 1 year */ if (Recurrance == 0xffff) Recurrance=8760; if (Recurrance != 0) { smprintf(s, "Recurrance : %i hours\n",Recurrance); entry->Entries[entry->EntriesNum].EntryType = CAL_RECURRANCE; entry->Entries[entry->EntriesNum].Number = Recurrance; entry->EntriesNum++; } } /* method 2 */ GSM_Error N71_65_ReplyAddCalendar2(GSM_Protocol_Message msg, GSM_StateMachine *s) { smprintf(s, "Calendar note added\n"); return ERR_NONE; } /* method 2 */ GSM_Error N71_65_AddCalendar2(GSM_StateMachine *s, GSM_CalendarEntry *Note) { GSM_CalendarNoteType NoteType; time_t t_time1,t_time2; GSM_DateTime Date,date_time; GSM_Error error; diff --git a/gammu/emb/common/phone/obex/obexgen.c b/gammu/emb/common/phone/obex/obexgen.c index dd14f8e..3106369 100644 --- a/gammu/emb/common/phone/obex/obexgen.c +++ b/gammu/emb/common/phone/obex/obexgen.c @@ -729,123 +729,124 @@ GSM_Phone_Functions OBEXGENPhone = { NONEFUNCTION, /* GetManufacturer */ NONEFUNCTION, /* GetModel */ NONEFUNCTION, /* GetFirmware */ NOTIMPLEMENTED, /* GetIMEI */ NOTIMPLEMENTED, /* GetOriginalIMEI */ NOTIMPLEMENTED, /* GetManufactureMonth */ NOTIMPLEMENTED, /* GetProductCode */ NOTIMPLEMENTED, /* GetHardware */ NOTIMPLEMENTED, /* GetPPM */ NOTIMPLEMENTED, /* GetSIMIMSI */ NOTIMPLEMENTED, /* GetDateTime */ NOTIMPLEMENTED, /* SetDateTime */ NOTIMPLEMENTED, /* GetAlarm */ NOTIMPLEMENTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ NOTIMPLEMENTED, /* PressKey */ NOTIMPLEMENTED, /* Reset */ NOTIMPLEMENTED, /* ResetPhoneSettings */ NOTIMPLEMENTED, /* EnterSecurityCode */ NOTIMPLEMENTED, /* GetSecurityStatus */ NOTIMPLEMENTED, /* GetDisplayStatus */ NOTIMPLEMENTED, /* SetAutoNetworkLogin */ NOTIMPLEMENTED, /* GetBatteryCharge */ NOTIMPLEMENTED, /* GetSignalQuality */ NOTIMPLEMENTED, /* GetNetworkInfo */ NOTIMPLEMENTED, /* GetCategory */ NOTSUPPORTED, /* AddCategory */ NOTIMPLEMENTED, /* GetCategoryStatus */ NOTIMPLEMENTED, /* GetMemoryStatus */ NOTIMPLEMENTED, /* GetMemory */ NOTIMPLEMENTED, /* GetNextMemory */ NOTIMPLEMENTED, /* SetMemory */ NOTIMPLEMENTED, /* AddMemory */ NOTIMPLEMENTED, /* DeleteMemory */ NOTIMPLEMENTED, /* DeleteAllMemory */ NOTIMPLEMENTED, /* GetSpeedDial */ NOTIMPLEMENTED, /* SetSpeedDial */ NOTIMPLEMENTED, /* GetSMSC */ NOTIMPLEMENTED, /* SetSMSC */ NOTIMPLEMENTED, /* GetSMSStatus */ NOTIMPLEMENTED, /* GetSMS */ NOTIMPLEMENTED, /* GetNextSMS */ NOTIMPLEMENTED, /* SetSMS */ NOTIMPLEMENTED, /* AddSMS */ NOTIMPLEMENTED, /* DeleteSMS */ NOTIMPLEMENTED, /* SendSMSMessage */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTIMPLEMENTED, /* SetIncomingSMS */ NOTIMPLEMENTED, /* SetIncomingCB */ NOTIMPLEMENTED, /* GetSMSFolders */ NOTIMPLEMENTED, /* AddSMSFolder */ NOTIMPLEMENTED, /* DeleteSMSFolder */ NOTIMPLEMENTED, /* DialVoice */ NOTIMPLEMENTED, /* AnswerCall */ NOTIMPLEMENTED, /* CancelCall */ NOTIMPLEMENTED, /* HoldCall */ NOTIMPLEMENTED, /* UnholdCall */ NOTIMPLEMENTED, /* ConferenceCall */ NOTIMPLEMENTED, /* SplitCall */ NOTIMPLEMENTED, /* TransferCall */ NOTIMPLEMENTED, /* SwitchCall */ NOTIMPLEMENTED, /* GetCallDivert */ NOTIMPLEMENTED, /* SetCallDivert */ NOTIMPLEMENTED, /* CancelAllDiverts */ NOTIMPLEMENTED, /* SetIncomingCall */ NOTIMPLEMENTED, /* SetIncomingUSSD */ NOTIMPLEMENTED, /* SendDTMF */ NOTIMPLEMENTED, /* GetRingtone */ NOTIMPLEMENTED, /* SetRingtone */ NOTIMPLEMENTED, /* GetRingtonesInfo */ NOTIMPLEMENTED, /* DeleteUserRingtones */ NOTIMPLEMENTED, /* PlayTone */ NOTIMPLEMENTED, /* GetWAPBookmark */ NOTIMPLEMENTED, /* SetWAPBookmark */ NOTIMPLEMENTED, /* DeleteWAPBookmark */ NOTIMPLEMENTED, /* GetWAPSettings */ NOTIMPLEMENTED, /* SetWAPSettings */ NOTIMPLEMENTED, /* GetMMSSettings */ NOTIMPLEMENTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ NOTIMPLEMENTED, /* GetBitmap */ NOTIMPLEMENTED, /* SetBitmap */ NOTIMPLEMENTED, /* GetToDoStatus */ NOTIMPLEMENTED, /* GetToDo */ NOTIMPLEMENTED, /* GetNextToDo */ NOTIMPLEMENTED, /* SetToDo */ NOTIMPLEMENTED, /* AddToDo */ NOTIMPLEMENTED, /* DeleteToDo */ NOTIMPLEMENTED, /* DeleteAllToDo */ NOTIMPLEMENTED, /* GetCalendarStatus */ NOTIMPLEMENTED, /* GetCalendar */ NOTIMPLEMENTED, /* GetNextCalendar */ NOTIMPLEMENTED, /* SetCalendar */ NOTIMPLEMENTED, /* AddCalendar */ NOTIMPLEMENTED, /* DeleteCalendar */ NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTIMPLEMENTED, /* GetProfile */ NOTIMPLEMENTED, /* SetProfile */ NOTIMPLEMENTED, /* GetFMStation */ NOTIMPLEMENTED, /* SetFMStation */ NOTIMPLEMENTED, /* ClearFMStations */ OBEXGEN_GetNextFileFolder, OBEXGEN_GetFilePart, OBEXGEN_AddFilePart, NOTIMPLEMENTED, /* GetFileSystemStatus */ OBEXGEN_DeleteFile, OBEXGEN_AddFolder, NOTIMPLEMENTED, /* GetGPRSAccessPoint */ NOTIMPLEMENTED /* SetGPRSAccessPoint */ }; #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/obex/obexgen.h b/gammu/emb/common/phone/obex/obexgen.h index 466fef5..b7033de 100644 --- a/gammu/emb/common/phone/obex/obexgen.h +++ b/gammu/emb/common/phone/obex/obexgen.h @@ -1,38 +1,42 @@ /* (c) 2003 by Marcin Wiacek */ #ifndef obexgen_h #define obexgen_h #include "../../gsmcomon.h" #include "../../gsmstate.h" #include "../../service/gsmmisc.h" #include "../../service/sms/gsmsms.h" #ifndef GSM_USED_IRDAOBEX # define GSM_USED_IRDAOBEX #endif #ifndef GSM_USED_BLUEOBEX # define GSM_USED_BLUEOBEX #endif typedef enum { OBEX_None = 1, OBEX_BrowsingFolders } OBEX_Service; typedef struct { int FileLev; int FilesLocationsUsed; int FilesLocationsCurrent; GSM_File Files[500]; bool FileLastPart; int FrameSize; OBEX_Service Service; } GSM_Phone_OBEXGENData; +GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File); +GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos); +GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s); + #endif /* How should editor hadle tabs in this file? Add editor commands here. * vim: noexpandtab sw=8 ts=8 sts=8: */ diff --git a/gammu/emb/common/phone/symbian/mroutgen.c b/gammu/emb/common/phone/symbian/mroutgen.c index 2c339be..a7382cf 100644 --- a/gammu/emb/common/phone/symbian/mroutgen.c +++ b/gammu/emb/common/phone/symbian/mroutgen.c @@ -98,123 +98,124 @@ GSM_Phone_Functions MROUTERGENPhone = { NOTSUPPORTED, /* ShowStartInfo */ NONEFUNCTION, /* GetManufacturer */ NONEFUNCTION, /* GetModel */ NONEFUNCTION, /* GetFirmware */ NOTIMPLEMENTED, /* GetIMEI */ NOTSUPPORTED, /* GetOriginalIMEI */ NOTSUPPORTED, /* GetManufactureMonth */ NOTSUPPORTED, /* GetProductCode */ NOTSUPPORTED, /* GetHardware */ NOTSUPPORTED, /* GetPPM */ NOTSUPPORTED, /* GetSIMIMSI */ NOTSUPPORTED, /* GetDateTime */ NOTSUPPORTED, /* SetDateTime */ NOTSUPPORTED, /* GetAlarm */ NOTSUPPORTED, /* SetAlarm */ NOTSUPPORTED, /* GetLocale */ NOTSUPPORTED, /* SetLocale */ NOTSUPPORTED, /* PressKey */ NOTSUPPORTED, /* Reset */ NOTSUPPORTED, /* ResetPhoneSettings */ NOTSUPPORTED, /* EnterSecurityCode */ NOTSUPPORTED, /* GetSecurityStatus */ NOTSUPPORTED, /* GetDisplayStatus */ NOTSUPPORTED, /* SetAutoNetworkLogin */ NOTSUPPORTED, /* GetBatteryCharge */ NOTSUPPORTED, /* GetSignalQuality */ NOTSUPPORTED, /* GetNetworkInfo */ NOTSUPPORTED, /* GetCategory */ NOTSUPPORTED, /* GetCategoryStatus */ NOTSUPPORTED, /* GetMemoryStatus */ NOTSUPPORTED, /* GetMemory */ NOTSUPPORTED, /* GetNextMemory */ NOTSUPPORTED, /* SetMemory */ NOTSUPPORTED, /* AddMemory */ NOTSUPPORTED, /* DeleteMemory */ NOTIMPLEMENTED, /* DeleteAllMemory */ NOTSUPPORTED, /* GetSpeedDial */ NOTSUPPORTED, /* SetSpeedDial */ NOTSUPPORTED, /* GetSMSC */ NOTSUPPORTED, /* SetSMSC */ NOTSUPPORTED, /* GetSMSStatus */ NOTSUPPORTED, /* GetSMS */ NOTSUPPORTED, /* GetNextSMS */ NOTSUPPORTED, /* SetSMS */ NOTSUPPORTED, /* AddSMS */ NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMSMessage */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ NOTSUPPORTED, /* AddSMSFolder */ NOTSUPPORTED, /* DeleteSMSFolder */ NOTSUPPORTED, /* DialVoice */ NOTSUPPORTED, /* AnswerCall */ NOTSUPPORTED, /* CancelCall */ NOTSUPPORTED, /* HoldCall */ NOTSUPPORTED, /* UnholdCall */ NOTSUPPORTED, /* ConferenceCall */ NOTSUPPORTED, /* SplitCall */ NOTSUPPORTED, /* TransferCall */ NOTSUPPORTED, /* SwitchCall */ NOTSUPPORTED, /* GetCallDivert */ NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NOTSUPPORTED, /* SetIncomingCall */ NOTSUPPORTED, /* SetIncomingUSSD */ NOTSUPPORTED, /* SendDTMF */ NOTSUPPORTED, /* GetRingtone */ NOTSUPPORTED, /* SetRingtone */ NOTSUPPORTED, /* GetRingtonesInfo */ NOTSUPPORTED, /* DeleteUserRingtones */ NOTSUPPORTED, /* PlayTone */ NOTSUPPORTED, /* GetWAPBookmark */ NOTSUPPORTED, /* SetWAPBookmark */ NOTSUPPORTED, /* DeleteWAPBookmark */ NOTSUPPORTED, /* GetWAPSettings */ NOTSUPPORTED, /* SetWAPSettings */ NOTSUPPORTED, /* GetMMSSettings */ NOTSUPPORTED, /* SetMMSSettings */ NOTSUPPORTED, /* GetSyncMLSettings */ NOTSUPPORTED, /* SetSyncMLSettings */ NOTSUPPORTED, /* GetChatSettings */ NOTSUPPORTED, /* SetChatSettings */ NOTSUPPORTED, /* GetBitmap */ NOTSUPPORTED, /* SetBitmap */ NOTSUPPORTED, /* GetToDoStatus */ NOTSUPPORTED, /* GetToDo */ NOTSUPPORTED, /* GetNextToDo */ NOTSUPPORTED, /* SetToDo */ NOTSUPPORTED, /* AddToDo */ NOTSUPPORTED, /* DeleteToDo */ NOTSUPPORTED, /* DeleteAllToDo */ NOTSUPPORTED, /* GetCalendarStatus */ NOTSUPPORTED, /* GetCalendar */ NOTSUPPORTED, /* GetNextCalendar */ NOTSUPPORTED, /* SetCalendar */ NOTSUPPORTED, /* AddCalendar */ NOTSUPPORTED, /* DeleteCalendar */ NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ NOTSUPPORTED, /* SetFMStation */ NOTSUPPORTED, /* ClearFMStations */ NOTSUPPORTED, /* GetNextFileFolder */ NOTSUPPORTED, /* GetFilePart */ NOTSUPPORTED, /* AddFilePart */ 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: */ |