From 50ab40e1e02ad7c65c17a78d08116a808b1257aa Mon Sep 17 00:00:00 2001 From: zautrix Date: Tue, 05 Oct 2004 11:13:51 +0000 Subject: updated to latest gammu version --- (limited to 'gammu/emb/common/phone') 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 @@ -9,9 +9,9 @@ * - BE5 series (501/701) * - BF5 series (715) * - BH4 series (535/735) - * For some functions it uses normal AT mode (not implemented here, look at - * ../at/atgen.[ch]) for others it switches into binary mode and initialises - * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and + * For some functions it uses normal AT mode (not implemented here, look at + * ../at/atgen.[ch]) for others it switches into binary mode and initialises + * underlaying protocol (see ../../protocol/alcatel/alcabus.[ch]) and * communicates over it. Don't ask me why Alcatel uses such silly thing... * * Notes for future features: @@ -101,6 +101,7 @@ 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); @@ -116,7 +117,7 @@ unsigned char GSM_AlcatelAlphabet[] = 0x81, 0x00,0x20, /* empty */ 0x82, 0x00,0x20, /* empty */ 0x83, 0x00,0x20, /* empty */ - + 0x84, 0x00,0xe7, /* c cedilla */ 0x85, 0x20,0x26, /* ... */ 0x86, 0x03,0xc0, /* pi */ @@ -168,18 +169,18 @@ unsigned char GSM_AlcatelAlphabet[] = 0xb4, 0x01,0x42, /* l stroke */ 0xb5, 0x00,0x20, /* empty */ - + 0xb6, 0x01,0x48, /* n caron */ 0xb7, 0x01,0x65, /* t caron */ - + 0xb8, 0x00,0x20, /* empty */ - + 0xb9, 0x01,0x7e, /* z caron */ 0xba, 0x01,0xe7, /* g caron */ - + 0xbb, 0x00,0x20, /* empty */ 0xbc, 0x00,0x20, /* empty */ - + 0xbd, 0x1e,0x20, /* G macron */ 0xbe, 0x1e,0x21, /* g macron */ 0xbf, 0x01,0x5e, /* S cedilla */ @@ -196,23 +197,23 @@ unsigned char GSM_AlcatelAlphabet[] = 0xca, 0x00,0x5d, /* ] */ 0xcb, 0x26,0x0f, /* phone */ 0xcc, 0x01,0x0f, /* d caron */ - + 0xcd, 0x00,0x20, /* empty */ 0xce, 0x00,0x7e, /* ~ */ 0xcf, 0x00,0x5c, /* \ */ 0xd0, 0x00,0x5e, /* ^ */ - + 0xd1, 0x00,0x20, /* empty */ - + 0xd2, 0x00,0x7b, /* { */ 0xd3, 0x00,0x7c, /* | */ 0xd4, 0x00,0x7d, /* } */ - + 0xd5, 0x00,0x20, /* empty */ - + 0xd6, 0x01,0x63, /* t cedilla */ - + 0xd7, 0x00,0x20, /* empty */ 0xd8, 0x00,0x20, /* empty */ 0xd9, 0x00,0x20, /* empty */ @@ -223,13 +224,13 @@ unsigned char GSM_AlcatelAlphabet[] = 0xde, 0x00,0x20, /* empty */ 0xdf, 0x00,0x20, /* empty */ 0xe0, 0x00,0x20, /* empty */ - + 0xe1, 0x00,0x20, /* two candles */ /* FIXME */ - + 0xe2, 0x00,0x20, /* empty */ 0xe3, 0x00,0x20, /* empty */ 0xe4, 0x00,0x20, /* empty */ - + 0xe5, 0x01,0xce, /* a caron */ 0xe6, 0x01,0x01, /* a macron */ 0xe7, 0x01,0x13, /* e macron */ @@ -239,34 +240,34 @@ unsigned char GSM_AlcatelAlphabet[] = 0xeb, 0x00,0x41, /* A */ 0xec, 0x00,0x40, /* @ */ 0xed, 0x00,0x20, /* some strange char :-) */ /* FIXME */ - + 0xee, 0x00,0x20, /* big key stroken */ /* FIXME */ 0xef, 0x00,0x20, /* big key */ /* FIXME */ - + 0xf0, 0x00,0x20, /* empty */ - + 0xf1, 0x00,0x31, /* 1 */ 0xf2, 0x00,0x21, /* bold ! */ 0xf3, 0x26,0x0e, /* black phone */ 0xf4, 0x00,0x26, /* & */ 0xf5, 0x23,0x7e, /* bell */ 0xf6, 0x26,0x6a, /* note */ - + 0xf7, 0x27,0x13, /* okay inv */ /* FIXME */ 0xf8, 0x27,0x13, /* okay */ - + 0xf9, 0x00,0x20, /* empty */ - + 0xfa, 0x00,0x20, /* key */ /* FIXME */ - + 0xfb, 0x00,0x20, /* empty */ - + 0xfc, 0x20,0xac, /* Euro */ 0xfd, 0x21,0x97, /* NE arrow */ 0xfe, 0x21,0x98, /* SE arrow */ 0xff, 0x00,0x20, /* empty */ - + 0x00, 0x00,0x00 }; @@ -315,7 +316,7 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) error=GSM_WaitFor (s, "AT+IFC=2,2\r", 11, 0x02, 4, ID_SetFlowControl); if (error != ERR_NONE) return error; - + error=GSM_WaitFor (s, "AT+CPROT=?\r", 11, 0x02, 4, ID_AlcatelProtocol); if (error != ERR_NONE) return error; @@ -324,11 +325,11 @@ static GSM_Error ALCATEL_SetBinaryMode(GSM_StateMachine *s) } else { error=GSM_WaitFor (s, "AT+CPROT=16,\"V1.1\",16\r", 22, 0x00, 4, ID_AlcatelConnect); } - + if (error == ERR_TIMEOUT && s->Speed != 19200) { smprintf(s, "HINT: Try changing speed to 19200, it is sometimes needed for Alcatel binary mode.\n"); } - + if (error != ERR_NONE) return error; dbgprintf ("Changing protocol to Alcabus\n"); @@ -376,7 +377,7 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary 0x00, /*type */ 0x00, 0x85, 0x00}; unsigned char commit_buffer[] = - {0x00, 0x04, + {0x00, 0x04, 0x00, /*type */ 0x20, 0x01}; @@ -443,7 +444,7 @@ static GSM_Error ALCATEL_GoToBinaryState(GSM_StateMachine *s, GSM_Alcatel_Binary } error=GSM_WaitFor (s, end_buffer, 9, 0x02, ALCATEL_TIMEOUT, ID_AlcatelEnd); if (error != ERR_NONE) return error; - + switch (Priv->BinaryType) { case TypeCalendar: close_buffer[2] = ALCATEL_SYNC_TYPE_CALENDAR; @@ -544,6 +545,8 @@ static GSM_Error ALCATEL_SetATMode(GSM_StateMachine *s) 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); @@ -628,11 +631,11 @@ static GSM_Error ALCATEL_IsIdAvailable(GSM_StateMachine *s, int id) { Priv->CurrentCount = &(Priv->ToDoItemsCount); break; } - + for (i=0; i<*Priv->CurrentCount; i++) { if ((*Priv->CurrentList)[i] == id) return ERR_NONE; } - + return ERR_EMPTY; } @@ -846,7 +849,7 @@ static GSM_Error ALCATEL_ReplyGetFieldValue(GSM_Protocol_Message msg, GSM_StateM Priv->ReturnDateTime.Hour = buffer[4]; Priv->ReturnDateTime.Minute = buffer[5]; Priv->ReturnDateTime.Second = buffer[6]; - + Priv->ReturnDateTime.Day = 0; Priv->ReturnDateTime.Month = 0; Priv->ReturnDateTime.Year = 0; @@ -1096,12 +1099,12 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { unsigned char buffer[] = {0x00, 0x04, 0x00 /*type*/, 0x0c, 0x00 /*list*/, 0x0A, 0x01, 0x00 /*item*/ }; GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; GSM_Error error; - + if (Priv->CurrentCategoriesCache[id][0] != '\000' || Priv->CurrentCategoriesCache[id][1] != '\000') { CopyUnicodeString(Priv->ReturnString, Priv->CurrentCategoriesCache[id]); return ERR_NONE; } - + smprintf(s,"Reading category %d\n", id); switch (Priv->BinaryType) { @@ -1123,7 +1126,7 @@ static GSM_Error ALCATEL_GetCategoryText(GSM_StateMachine *s, int id) { if (error != ERR_NONE) return error; error=GSM_WaitFor (s, 0, 0, 0x00, ALCATEL_TIMEOUT, ID_AlcatelGetCategoryText2); if (error != ERR_NONE) return error; - + CopyUnicodeString(Priv->CurrentCategoriesCache[id], Priv->ReturnString); return ERR_NONE; @@ -1213,9 +1216,9 @@ static GSM_Error ALCATEL_ReplyDeleteItem(GSM_Protocol_Message msg, GSM_StateMach static GSM_Error ALCATEL_BuildWriteBuffer(unsigned char * buffer, GSM_Alcatel_FieldType type, int field, void *data) { int len; - + buffer[1] = field & 0xff; - + switch(type) { case Alcatel_date: if (!CheckDate((GSM_DateTime *)data)) return ERR_INVALIDDATETIME; @@ -1329,10 +1332,10 @@ static GSM_Error ALCATEL_CreateField(GSM_StateMachine *s, GSM_Alcatel_FieldType } error = ALCATEL_BuildWriteBuffer(buffer + 6, type, field, data); if (error != ERR_NONE) return error; - + error = GSM_WaitFor (s, buffer, 8 + buffer[6], 0x02, ALCATEL_TIMEOUT, ID_AlcatelCreateField); if (error != ERR_NONE) return error; - + return ERR_NONE; } @@ -1342,7 +1345,7 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType unsigned char buffer[200] = {0x00, 0x04, 0x00, /* type */ - 0x26, 0x01, + 0x26, 0x01, 0x00, 0x00, 0x00, 0x00, /* id */ 0x65, 0x00, /* length of remaining part */ @@ -1350,7 +1353,7 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType 0x37}; /* data follows here */ smprintf(s,"Updating field (%08x.%02x)\n", id, field); - + buffer[5] = (id >> 24); buffer[6] = ((id >> 16) & 0xff); buffer[7] = ((id >> 8) & 0xff); @@ -1369,10 +1372,10 @@ static GSM_Error ALCATEL_UpdateField(GSM_StateMachine *s, GSM_Alcatel_FieldType } error = ALCATEL_BuildWriteBuffer(buffer + 10, type, field, data); if (error != ERR_NONE) return error; - + error = GSM_WaitFor (s, buffer, 12 + buffer[10], 0x02, ALCATEL_TIMEOUT, ID_AlcatelUpdateField); if (error != ERR_NONE) return error; - + return ERR_NONE; } @@ -1743,7 +1746,7 @@ static GSM_Error ALCATEL_GetNextMemory(GSM_StateMachine *s, GSM_MemoryEntry *ent if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; if (Priv->ContactsItemsCount == 0) return ERR_EMPTY; - + if (start) entry->Location = 0; if ((error = ALCATEL_GetNextId(s, &(entry->Location))) != ERR_NONE) return error; @@ -1768,7 +1771,7 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, 0))!= ERR_NONE) return error; for (i = 0; i < entry->EntriesNum; i++) { switch (entry->Entries[i].EntryType) { - case PBK_Number_General: + case PBK_Number_General: if ((error = ALCATEL_CreateField(s, Alcatel_phone, 8, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Number_Mobile: @@ -1777,7 +1780,7 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) case PBK_Number_Work: if ((error = ALCATEL_CreateField(s, Alcatel_phone, 7, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Fax: + case PBK_Number_Fax: if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Number_Home: @@ -1809,13 +1812,13 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) case PBK_Text_Company: if ((error = ALCATEL_CreateField(s, Alcatel_string, 2, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_JobTitle: + case PBK_Text_JobTitle: if ((error = ALCATEL_CreateField(s, Alcatel_string, 3, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Category: + case PBK_Category: if ((error = ALCATEL_CreateField(s, Alcatel_byte, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; break; - case PBK_Private: + case PBK_Private: if ((error = ALCATEL_CreateField(s, Alcatel_bool, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; break; case PBK_Text_StreetAddress: @@ -1840,12 +1843,12 @@ static GSM_Error ALCATEL_AddMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) if ((error = ALCATEL_CreateField(s, Alcatel_string, 22, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Text_Custom3: - if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; + if ((error = ALCATEL_CreateField(s, Alcatel_string, 23, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Text_Custom4: if ((error = ALCATEL_CreateField(s, Alcatel_string, 24, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_PictureID: + case PBK_PictureID: if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { if ((error = ALCATEL_CreateField(s, Alcatel_int, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; } else { @@ -1906,91 +1909,91 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) } /* Get fields for current item */ if ((error = ALCATEL_GetFields(s, entry->Location))!= ERR_NONE) return error; - + for (i = 0; i < 26; i++) { UpdatedFields[i] = false; } - + if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeContacts, entry->Location))!= ERR_NONE) return error; for (i = 0; i < entry->EntriesNum; i++) { switch (entry->Entries[i].EntryType) { - case PBK_Number_General: - UpdatedFields[8] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Number_General: + UpdatedFields[8] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 8, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Mobile: - UpdatedFields[12] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Number_Mobile: + UpdatedFields[12] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 12, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Work: - UpdatedFields[7] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Number_Work: + UpdatedFields[7] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 7, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Fax: - UpdatedFields[9] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Number_Fax: + UpdatedFields[9] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 9, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Home: - UpdatedFields[13] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Number_Home: + UpdatedFields[13] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 13, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Number_Pager: - UpdatedFields[11] = true; + case PBK_Number_Pager: + UpdatedFields[11] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 11, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Number_Other: UpdatedFields[10] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; + if ((error = ALCATEL_UpdateField(s, Alcatel_phone, entry->Location, 10, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_Note: + case PBK_Text_Note: UpdatedFields[4] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 4, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_Email: - UpdatedFields[14] = true; + case PBK_Text_Email: + UpdatedFields[14] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 14, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_Email2: - UpdatedFields[15] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Text_Email2: + UpdatedFields[15] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 15, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_LastName: - UpdatedFields[0] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; + case PBK_Text_LastName: + UpdatedFields[0] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; break; - case PBK_Text_FirstName: - UpdatedFields[1] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; + case PBK_Text_FirstName: + UpdatedFields[1] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = true; break; case PBK_Text_Company: - UpdatedFields[2] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; + UpdatedFields[2] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 2, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_JobTitle: + case PBK_Text_JobTitle: UpdatedFields[3] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 3, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Category: - UpdatedFields[5] = true; + UpdatedFields[5] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_byte, entry->Location, 5, &(entry->Entries[i].Number))) != ERR_NONE) return error; break; case PBK_Private: UpdatedFields[6] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_bool, entry->Location, 6, &(entry->Entries[i].Number))) != ERR_NONE) return error; break; - case PBK_Text_StreetAddress: + case PBK_Text_StreetAddress: UpdatedFields[16] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 16, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_City: - UpdatedFields[17] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Text_City: + UpdatedFields[17] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 17, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_State: - UpdatedFields[18] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Text_State: + UpdatedFields[18] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 18, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_Zip: - UpdatedFields[19] = true; - if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; + case PBK_Text_Zip: + UpdatedFields[19] = true; + if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 19, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Text_Country: UpdatedFields[20] = true; @@ -2000,7 +2003,7 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) UpdatedFields[21] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 21, entry->Entries[i].Text)) != ERR_NONE) return error; break; - case PBK_Text_Custom2: + case PBK_Text_Custom2: UpdatedFields[22] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 22, entry->Entries[i].Text)) != ERR_NONE) return error; break; @@ -2009,10 +2012,10 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 23, entry->Entries[i].Text)) != ERR_NONE) return error; break; case PBK_Text_Custom4: - UpdatedFields[24] = true; + UpdatedFields[24] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 24, entry->Entries[i].Text)) != ERR_NONE) return error ; break; - case PBK_PictureID: + case PBK_PictureID: if (s->Phone.Data.Priv.ALCATEL.ProtocolVersion == V_1_1) { UpdatedFields[25] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_int, entry->Location, 25, &(entry->Entries[i].Number))) != ERR_NONE) return error; @@ -2069,11 +2072,11 @@ static GSM_Error ALCATEL_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entr /* Do real delete */ error = ALCATEL_DeleteItem(s, entry->Location); if (error != ERR_NONE) return error; - + /* Refresh list */ if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeContacts, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; - + return ERR_NONE; } else { if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; @@ -2228,7 +2231,7 @@ static GSM_Error ALCATEL_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatur if ((error = ALCATEL_SetATMode(s))!= ERR_NONE) return error; return ATGEN_GetDisplayStatus(s, features); } - + static GSM_Error ALCATEL_SetAutoNetworkLogin(GSM_StateMachine *s) { GSM_Error error; @@ -2337,9 +2340,9 @@ static GSM_Error ALCATEL_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStat { GSM_Error error; GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; - + status->Used = 0; - + if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; @@ -2727,7 +2730,7 @@ static GSM_Error ALCATEL_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; if (Priv->CalendarItemsCount == 0) return ERR_EMPTY; - + if (start) Note->Location = 0; if ((error = ALCATEL_GetNextId(s, &(Note->Location))) != ERR_NONE) return error; @@ -2768,7 +2771,7 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, 0))!= ERR_NONE) return error; - + for (i = 0; i < Note->EntriesNum; i++) { switch (Note->Entries[i].EntryType) { case CAL_START_DATETIME: @@ -2806,7 +2809,7 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not case CAL_PHONE: if ((error = ALCATEL_CreateField(s, Alcatel_phone, 9, Note->Entries[i].Text)) != ERR_NONE) return error; phone_set = true; - break; + break; case CAL_REPEAT_DAYOFWEEK: if ((error = ALCATEL_CreateField(s, Alcatel_byte, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; repeating = true; @@ -2842,7 +2845,7 @@ static GSM_Error ALCATEL_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not break; } } - + switch (Note->Type) { case GSM_CAL_CALL: val = 3; @@ -2900,16 +2903,16 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not } /* Get fields for current item */ if ((error = ALCATEL_GetFields(s, Note->Location))!= ERR_NONE) return error; - + for (i = 0; i < 22; i++) { UpdatedFields[i] = false; } if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeCalendar, Note->Location))!= ERR_NONE) return error; - + for (i = 0; i < Note->EntriesNum; i++) { switch (Note->Entries[i].EntryType) { case CAL_START_DATETIME: if (!date_set) { - UpdatedFields[0] = true; + UpdatedFields[0] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_date, Note->Location, 0, &(Note->Entries[i].Date))) != ERR_NONE) return error; date_set = true; } @@ -2953,7 +2956,7 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not UpdatedFields[9] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_phone, Note->Location, 9, Note->Entries[i].Text)) != ERR_NONE) return error; phone_set = true; - break; + break; case CAL_REPEAT_DAYOFWEEK: UpdatedFields[10] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_byte, Note->Location, 10, &(Note->Entries[i].Number))) != ERR_NONE) return error; @@ -2996,7 +2999,7 @@ static GSM_Error ALCATEL_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Not break; } } - + switch (Note->Type) { case GSM_CAL_CALL: val = 3; @@ -3072,7 +3075,7 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeCalendar, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; - + for (i=0; iCalendarItemsCount; i++) { if ((error = ALCATEL_GetFieldValue(s, Priv->CalendarItems[i], 7))!= ERR_NONE) return error; if (Priv->ReturnType != Alcatel_enum) { @@ -3091,7 +3094,7 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) if (!Found) return ERR_EMPTY; Note.Location = Priv->CalendarItems[i]; - + if ((error = ALCATEL_GetCalendar(s, &Note))!= ERR_NONE) return error; if (Note.Type == GSM_CAL_ALARM) { @@ -3099,7 +3102,7 @@ static GSM_Error ALCATEL_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) } else { alarm->Repeating = true; } - + alarm->Text[0] = 0; alarm->Text[1] = 0; @@ -3146,7 +3149,7 @@ static GSM_Error ALCATEL_SetAlarm (GSM_StateMachine *s, GSM_Alarm *alarm) } } } - + if (Found) { Note.Location = Priv->CalendarItems[i]; } @@ -3184,9 +3187,9 @@ static GSM_Error ALCATEL_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *stat { GSM_Error error; GSM_Phone_ALCATELData *Priv = &s->Phone.Data.Priv.ALCATEL; - + status->Used = 0; - + if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, true))!= ERR_NONE) return error; @@ -3451,7 +3454,7 @@ static GSM_Error ALCATEL_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, b if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GetAvailableIds(s, false))!= ERR_NONE) return error; if (Priv->ToDoItemsCount == 0) return ERR_EMPTY; - + if (start) ToDo->Location = 0; if ((error = ALCATEL_GetNextId(s, &(ToDo->Location))) != ERR_NONE) return error; @@ -3490,7 +3493,7 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) if ((error = ALCATEL_GoToBinaryState(s, StateSession, TypeToDo, 0))!= ERR_NONE) return error; if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, 0))!= ERR_NONE) return error; - + switch (ToDo->Priority) { case GSM_Priority_High: val = 0; @@ -3518,7 +3521,7 @@ static GSM_Error ALCATEL_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) case TODO_COMPLETED: if ((error = ALCATEL_CreateField(s, Alcatel_bool, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; break; - case TODO_ALARM_DATETIME: + case TODO_ALARM_DATETIME: if ((error = ALCATEL_CreateField(s, Alcatel_date, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; if ((error = ALCATEL_CreateField(s, Alcatel_time, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; if ((error = ALCATEL_CreateField(s, Alcatel_date, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; @@ -3579,9 +3582,9 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) } /* Get fields for current item */ if ((error = ALCATEL_GetFields(s, ToDo->Location))!= ERR_NONE) return error; - + for (i = 0; i < 12; i++) { UpdatedFields[i] = false; } - + if ((error = ALCATEL_GoToBinaryState(s, StateEdit, TypeToDo, ToDo->Location))!= ERR_NONE) return error; switch (ToDo->Priority) { @@ -3608,42 +3611,42 @@ static GSM_Error ALCATEL_SetToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo) switch (ToDo->Entries[i].EntryType) { case TODO_END_DATETIME: if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 0, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; - UpdatedFields[0] = true; + UpdatedFields[0] = true; break; case TODO_COMPLETED: if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 1, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; - UpdatedFields[1] = true; + UpdatedFields[1] = true; break; - case TODO_ALARM_DATETIME: + case TODO_ALARM_DATETIME: if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 2, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; - UpdatedFields[2] = true; + UpdatedFields[2] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 3, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; - UpdatedFields[3] = true; + UpdatedFields[3] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_date, ToDo->Location, 10, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; - UpdatedFields[10] = true; + UpdatedFields[10] = true; if ((error = ALCATEL_UpdateField(s, Alcatel_time, ToDo->Location, 11, &(ToDo->Entries[i].Date))) != ERR_NONE) return error; - UpdatedFields[11] = true; + UpdatedFields[11] = true; break; case TODO_TEXT: if ((error = ALCATEL_UpdateField(s, Alcatel_string, ToDo->Location, 4, ToDo->Entries[i].Text)) != ERR_NONE) return error; - UpdatedFields[4] = true; + UpdatedFields[4] = true; break; case TODO_PRIVATE: if ((error = ALCATEL_UpdateField(s, Alcatel_bool, ToDo->Location, 5, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; - UpdatedFields[5] = true; + UpdatedFields[5] = true; break; case TODO_CATEGORY: if ((error = ALCATEL_UpdateField(s, Alcatel_byte, ToDo->Location, 6, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; - UpdatedFields[6] = true; + UpdatedFields[6] = true; break; case TODO_CONTACTID: if ((error = ALCATEL_UpdateField(s, Alcatel_int, ToDo->Location, 8, &(ToDo->Entries[i].Number))) != ERR_NONE) return error; - UpdatedFields[8] = true; + UpdatedFields[8] = true; contact_set = true; break; case TODO_PHONE: if ((error = ALCATEL_UpdateField(s, Alcatel_phone, ToDo->Location, 9, ToDo->Entries[i].Text)) != ERR_NONE) return error; - UpdatedFields[9] = true; + UpdatedFields[9] = true; phone_set = true; break; default: @@ -3822,6 +3825,14 @@ static GSM_Error ALCATEL_SetIncomingSMS (GSM_StateMachine *s, bool enable) 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 }, @@ -3913,6 +3924,7 @@ GSM_Phone_Functions ALCATELPhone = { ALCATEL_DeleteSMS, ALCATEL_SendSMS, ALCATEL_SendSavedSMS, + ALCATEL_SetFastSMSSending, ALCATEL_SetIncomingSMS, ALCATEL_SetIncomingCB, ALCATEL_GetSMSFolders, @@ -3967,7 +3979,7 @@ GSM_Phone_Functions ALCATELPhone = { ALCATEL_DeleteAllCalendar, NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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 @@ -12,37 +12,17 @@ #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; @@ -175,6 +155,8 @@ GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s) } /* For error codes descriptions see table a bit above */ switch (Priv->ErrorCode) { + case -1: + return ERR_EMPTY; case 3: return ERR_PERMISSION; case 4: @@ -256,8 +238,16 @@ int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output) 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++; @@ -322,6 +312,18 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s) 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 */ @@ -370,6 +372,42 @@ GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s) 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; @@ -394,10 +432,12 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) 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))); @@ -481,6 +521,11 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine 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); @@ -674,16 +719,26 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine * * 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; } @@ -858,8 +913,9 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s 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; @@ -894,7 +950,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s 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; @@ -925,7 +981,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s 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; @@ -949,7 +1005,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s 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;iUser.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; @@ -1787,6 +1843,19 @@ GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm) 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; @@ -2202,6 +2271,8 @@ GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM 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; @@ -2268,6 +2339,12 @@ GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode) 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); @@ -2385,7 +2462,37 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s) 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); @@ -2562,6 +2669,8 @@ GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachin return ERR_SECURITYERROR; case AT_Reply_CMSError: return ATGEN_HandleCMSError(s); + case AT_Reply_CMEError: + return ATGEN_HandleCMEError(s); default: break; } @@ -2924,6 +3033,12 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry) 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"); @@ -3252,6 +3367,43 @@ GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *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; @@ -3346,6 +3498,17 @@ GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable) #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"); @@ -3424,6 +3587,18 @@ GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable) 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 }, @@ -3432,6 +3607,11 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 }, @@ -3462,6 +3642,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 }, @@ -3469,6 +3650,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 }, @@ -3484,23 +3666,25 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 }, @@ -3511,6 +3695,8 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 }, @@ -3521,6 +3707,12 @@ GSM_Reply_Function ATGENReplyFunctions[] = { {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 @@ -3538,7 +3730,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = { }; 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, @@ -3557,9 +3749,9 @@ GSM_Phone_Functions ATGENPhone = { ATGEN_GetDateTime, ATGEN_SetDateTime, ATGEN_GetAlarm, - NOTIMPLEMENTED, /* SetAlarm */ - NOTSUPPORTED, /* GetLocale */ - NOTSUPPORTED, /* SetLocale */ + ATGEN_SetAlarm, + ATGEN_GetLocale, + ATGEN_SetLocale, ATGEN_PressKey, ATGEN_Reset, ATGEN_ResetPhoneSettings, @@ -3592,6 +3784,7 @@ GSM_Phone_Functions ATGENPhone = { ATGEN_DeleteSMS, ATGEN_SendSMS, ATGEN_SendSavedSMS, + ATGEN_SetFastSMSSending, ATGEN_SetIncomingSMS, ATGEN_SetIncomingCB, ATGEN_GetSMSFolders, @@ -3610,7 +3803,7 @@ GSM_Phone_Functions ATGENPhone = { NOTSUPPORTED, /* SetCallDivert */ NOTSUPPORTED, /* CancelAllDiverts */ NONEFUNCTION, /* SetIncomingCall */ - NOTSUPPORTED, /* SetIncomingUSSD */ + ATGEN_SetIncomingUSSD, ATGEN_SendDTMF, ATGEN_GetRingtone, ATGEN_SetRingtone, @@ -3646,7 +3839,7 @@ GSM_Phone_Functions ATGENPhone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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 @@ -42,13 +42,15 @@ typedef enum { 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 { @@ -103,6 +105,10 @@ typedef struct { 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. 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 + * Tested with S300 only! + */ + +#include "../../gsmstate.h" + +#ifdef GSM_ENABLE_ATGEN + +#include +#include +#include + +#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 + */ +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 @@ -13,25 +13,11 @@ #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; @@ -57,7 +43,7 @@ GSM_Error GetSiemensFrame(GSM_Protocol_Message msg, GSM_StateMachine *s, char *t 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; @@ -90,7 +76,7 @@ GSM_Error SetSiemensFrame (GSM_StateMachine *s, unsigned char *buff, char *templ 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; @@ -104,16 +90,31 @@ GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine * 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; @@ -122,13 +123,12 @@ GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 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); @@ -141,7 +141,7 @@ GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap) 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; @@ -158,29 +158,25 @@ GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine 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; @@ -190,7 +186,7 @@ GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *ma 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; @@ -235,12 +231,12 @@ GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, 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; @@ -283,7 +279,7 @@ GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) } /* (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; 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 @@ -11,17 +11,15 @@ #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) { @@ -126,7 +124,7 @@ static GSM_Error SONYERIC_SetFile(GSM_StateMachine *s, unsigned char *FileName, 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; @@ -162,7 +160,7 @@ GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, 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; @@ -201,7 +199,7 @@ GSM_Error SONYERIC_GetNextToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool st 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; @@ -232,7 +230,7 @@ GSM_Error SONYERIC_GetToDoStatus(GSM_StateMachine *s, GSM_ToDoStatus *status) 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; @@ -248,7 +246,7 @@ GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 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; @@ -267,7 +265,7 @@ GSM_Error SONYERIC_AddToDo(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 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; @@ -319,7 +317,7 @@ GSM_Error SONYERIC_DeleteAllToDo(GSM_StateMachine *s) 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; @@ -374,7 +372,7 @@ GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note) 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; @@ -403,7 +401,118 @@ GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *St #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. 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,6 +1,9 @@ /* (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 /* memcpy only */ #include @@ -394,6 +397,7 @@ GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) } 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++;} @@ -442,7 +446,7 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s char name[100]; smprintf(s, "Network info received\n"); - smprintf(s, " Status : "); + smprintf(s, "Status : "); switch (msg.Buffer[8]) { case 0x01: smprintf(s, "home network"); break; case 0x02: smprintf(s, "roaming network"); break; @@ -451,7 +455,7 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s default : smprintf(s, "unknown"); } smprintf(s, "\n"); - smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); + 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); @@ -459,8 +463,8 @@ GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s 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))); @@ -1208,11 +1212,11 @@ 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; 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 @@ -3,6 +3,8 @@ #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); 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,7 +1,9 @@ /* (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" @@ -127,6 +129,7 @@ static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const #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, @@ -824,6 +827,7 @@ static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, 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; @@ -1524,6 +1528,7 @@ static GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachi #endif return ERR_NONE; case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format); @@ -1561,6 +1566,7 @@ static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo,F_RING_SM)) return ERR_NOTSUPPORTED; break; case RING_MIDI: + case RING_MMF: return ERR_NOTSUPPORTED; } @@ -2443,8 +2449,8 @@ 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); @@ -2807,6 +2813,7 @@ GSM_Phone_Functions N6110Phone = { N6110_DeleteSMSMessage, DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOKIA_SetIncomingSMS, DCT3_SetIncomingCB, PHONE_GetSMSFolders, @@ -2861,7 +2868,7 @@ GSM_Phone_Functions N6110Phone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ N6110_GetProfile, N6110_SetProfile, NOTSUPPORTED, /* GetFMStation */ 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,5 +1,8 @@ /* (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" @@ -526,6 +529,7 @@ static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_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; @@ -1647,6 +1651,7 @@ GSM_Phone_Functions N7110Phone = { N7110_DeleteSMS, DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ N7110_SetIncomingSMS, DCT3_SetIncomingCB, N7110_GetSMSFolders, @@ -1701,7 +1706,7 @@ GSM_Phone_Functions N7110Phone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ N7110_GetProfile, N7110_SetProfile, NOTSUPPORTED, /* GetFMStation */ 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 @@ -319,6 +319,7 @@ GSM_Phone_Functions N9210Phone = { NOTIMPLEMENTED, /* DeleteSMS */ DCT3_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ N9210_SetIncomingSMS, DCT3_SetIncomingCB, NOTIMPLEMENTED, /* GetSMSFolders */ @@ -373,7 +374,7 @@ GSM_Phone_Functions N9210Phone = { NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTIMPLEMENTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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 @@ -194,6 +194,7 @@ GSM_Phone_Functions N3320Phone = { NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMS */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ @@ -248,7 +249,7 @@ GSM_Phone_Functions N3320Phone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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 @@ -315,6 +315,7 @@ GSM_Phone_Functions N3650Phone = { NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMS */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ @@ -369,7 +370,7 @@ GSM_Phone_Functions N3650Phone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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,5 +1,8 @@ /* (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" @@ -119,6 +122,8 @@ static GSM_Error N6510_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine * } 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;iPhone.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; } @@ -1765,7 +1770,8 @@ static GSM_Error N6510_GetSyncMLSettings(GSM_StateMachine *s, GSM_SyncMLSettings 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; @@ -2283,7 +2289,7 @@ static GSM_Error N6510_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMa { 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: @@ -2770,6 +2776,7 @@ static GSM_Error N6510_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, 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; @@ -2986,6 +2993,9 @@ static GSM_Error N6510_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile) 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; @@ -3115,9 +3125,21 @@ static GSM_Error N6510_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachi 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)); @@ -3140,9 +3162,21 @@ static GSM_Error N6510_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShow 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 */ @@ -3174,24 +3208,27 @@ static GSM_Error N6510_ReplyGetCalendarInfo3(GSM_Protocol_Message msg, GSM_State } /* 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; @@ -3207,12 +3244,15 @@ static GSM_Error N6510_GetCalendarInfo3(GSM_StateMachine *s, GSM_NOKIACalToDoLoc } 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; } @@ -3350,13 +3390,22 @@ GSM_Error N6510_ReplyGetCalendar3(GSM_Protocol_Message msg, GSM_StateMachine *s) 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 @@ -3379,12 +3428,9 @@ static GSM_Error N6510_PrivGetCalendar3(GSM_StateMachine *s, GSM_CalendarEntry * 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 */ @@ -3394,7 +3440,7 @@ GSM_Error N6510_GetNextCalendar3(GSM_StateMachine *s, GSM_CalendarEntry *Note, b 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; @@ -3477,7 +3523,7 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr 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; @@ -3494,7 +3540,7 @@ static GSM_Error N6510_FindCalendarIconID3(GSM_StateMachine *s, GSM_CalendarEntr } 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; @@ -3737,7 +3783,7 @@ static GSM_Error N6510_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus // 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; @@ -3972,6 +4018,42 @@ static GSM_Error N6510_ShowStartInfo(GSM_StateMachine *s, bool enable) } } +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; @@ -4055,7 +4137,7 @@ static GSM_Error N6510_ReplyGetFileFolderInfo(GSM_Protocol_Message msg, GSM_Stat 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 @@ -4398,7 +4480,7 @@ static GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos 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; @@ -4814,7 +4896,7 @@ static GSM_Error N6510_GetToDoStatus2(GSM_StateMachine *s, GSM_ToDoStatus *statu 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; @@ -4944,8 +5026,7 @@ static GSM_Error N6510_ReplyGetToDo2(GSM_Protocol_Message msg, GSM_StateMachine 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; @@ -4978,14 +5059,9 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo { 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 { @@ -4994,12 +5070,9 @@ static GSM_Error N6510_GetNextToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bo 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) @@ -5043,7 +5116,7 @@ static GSM_Error N6510_DeleteToDo2(GSM_StateMachine *s, GSM_ToDoEntry *ToDo) 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"); @@ -5451,6 +5524,9 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { {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 }, @@ -5458,6 +5534,9 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { {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 }, @@ -5508,6 +5587,7 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { {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 }, @@ -5515,6 +5595,7 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { {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 }, @@ -5651,7 +5732,7 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { }; 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 */ @@ -5705,6 +5786,7 @@ GSM_Phone_Functions N6510Phone = { N6510_DeleteSMSMessage, N6510_SendSMSMessage, NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOKIA_SetIncomingSMS, NOTIMPLEMENTED, /* SetIncomingCB */ N6510_GetSMSFolders, @@ -5759,7 +5841,7 @@ GSM_Phone_Functions N6510Phone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ N6510_GetCalendarSettings, NOTSUPPORTED, /* SetCalendarSettings */ - NOTIMPLEMENTED, /* GetNote */ + N6510_GetNextNote, N6510_GetProfile, N6510_SetProfile, N6510_GetFMStation, 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 @@ -34,6 +34,8 @@ typedef struct { GSM_NOKIACalToDoLocations LastToDo; + GSM_NOKIACalToDoLocations LastNote; + unsigned char RingtoneID; /* When set with preview */ int FilesLocations[1000]; 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 @@ -121,7 +121,7 @@ GSM_Phone_Functions NAUTOPhone = { NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ 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 @@ -1393,6 +1393,11 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 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; @@ -1416,12 +1421,21 @@ GSM_Error N71_65_ReplyCallInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 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; 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 @@ -774,6 +774,7 @@ GSM_Phone_Functions OBEXGENPhone = { NOTIMPLEMENTED, /* DeleteSMS */ NOTIMPLEMENTED, /* SendSMSMessage */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTIMPLEMENTED, /* SetIncomingSMS */ NOTIMPLEMENTED, /* SetIncomingCB */ NOTIMPLEMENTED, /* GetSMSFolders */ @@ -828,7 +829,7 @@ GSM_Phone_Functions OBEXGENPhone = { NOTIMPLEMENTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTIMPLEMENTED, /* GetProfile */ NOTIMPLEMENTED, /* SetProfile */ NOTIMPLEMENTED, /* GetFMStation */ 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 @@ -31,6 +31,10 @@ typedef struct { 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. 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 @@ -143,6 +143,7 @@ GSM_Phone_Functions MROUTERGENPhone = { NOTSUPPORTED, /* DeleteSMS */ NOTSUPPORTED, /* SendSMSMessage */ NOTSUPPORTED, /* SendSavedSMS */ + NOTSUPPORTED, /* SetFastSMSSending */ NOTSUPPORTED, /* SetIncomingSMS */ NOTSUPPORTED, /* SetIncomingCB */ NOTSUPPORTED, /* GetSMSFolders */ @@ -197,7 +198,7 @@ GSM_Phone_Functions MROUTERGENPhone = { NOTSUPPORTED, /* DeleteAllCalendar */ NOTSUPPORTED, /* GetCalendarSettings */ NOTSUPPORTED, /* SetCalendarSettings */ - NOTSUPPORTED, /* GetNote */ + NOTSUPPORTED, /* GetNextNote */ NOTSUPPORTED, /* GetProfile */ NOTSUPPORTED, /* SetProfile */ NOTSUPPORTED, /* GetFMStation */ -- cgit v0.9.0.2