summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/at/atgen.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/at/atgen.c') (more/less context) (show whitespace changes)
-rw-r--r--gammu/emb/common/phone/at/atgen.c295
1 files changed, 244 insertions, 51 deletions
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
@@ -13,35 +13,15 @@
13#include "../../service/sms/gsmsms.h" 13#include "../../service/sms/gsmsms.h"
14#include "../pfunc.h" 14#include "../pfunc.h"
15
15#include "atgen.h" 16#include "atgen.h"
16 17
18#include "samsung.h"
19#include "siemens.h"
20#include "sonyeric.h"
21
17#ifdef GSM_ENABLE_ALCATEL 22#ifdef GSM_ENABLE_ALCATEL
18 extern GSM_Error ALCATEL_ProtocolVersionReply(GSM_Protocol_Message msg, GSM_StateMachine *s); 23GSM_Error ALCATEL_ProtocolVersionReply (GSM_Protocol_Message, GSM_StateMachine *);
19#endif 24#endif
20 25
21 extern GSM_Error ATGEN_CMS35ReplyGetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
22 extern GSM_Error ATGEN_CMS35ReplySetBitmap(GSM_Protocol_Message msg, GSM_StateMachine *s);
23 extern GSM_Error ATGEN_CMS35ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
24 extern GSM_Error ATGEN_CMS35ReplySetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s);
25 extern GSM_Error ATGEN_CMS35ReplyGetNextCal(GSM_Protocol_Message msg, GSM_StateMachine *s);
26 extern GSM_Error ATGEN_CMS35ReplySetCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
27 extern GSM_Error ATGEN_CMS35ReplyDeleteCalendar(GSM_Protocol_Message msg, GSM_StateMachine *s);
28 extern GSM_Error ATGEN_SL45ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s);
29
30 extern GSM_Error ATGEN_GetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone);
31 extern GSM_Error ATGEN_SetRingtone (GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength);
32 extern GSM_Error ATGEN_GetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
33 extern GSM_Error ATGEN_SetBitmap (GSM_StateMachine *s, GSM_Bitmap *Bitmap);
34 extern GSM_Error SIEMENS_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
35 extern GSM_Error SIEMENS_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
36 extern GSM_Error SIEMENS_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
37
38 extern GSM_Error SONYERIC_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start);
39 extern GSM_Error SONYERIC_GetNextToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo, bool start);
40 extern GSM_Error SONYERIC_GetToDoStatus (GSM_StateMachine *s, GSM_ToDoStatus *status);
41 extern GSM_Error SONYERIC_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
42 extern GSM_Error SONYERIC_AddToDo (GSM_StateMachine *s, GSM_ToDoEntry *ToDo);
43 extern GSM_Error SONYERIC_DeleteAllToDo (GSM_StateMachine *s);
44 extern GSM_Error SONYERIC_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note);
45 extern GSM_Error SONYERIC_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status);
46 26
47typedef struct { 27typedef struct {
@@ -176,4 +156,6 @@ GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
176 /* For error codes descriptions see table a bit above */ 156 /* For error codes descriptions see table a bit above */
177 switch (Priv->ErrorCode) { 157 switch (Priv->ErrorCode) {
158 case -1:
159 return ERR_EMPTY;
178 case 3: 160 case 3:
179 return ERR_PERMISSION; 161 return ERR_PERMISSION;
@@ -257,6 +239,14 @@ int ATGEN_ExtractOneParameter(unsigned char *input, unsigned char *output)
257void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input) 239void ATGEN_DecodeDateTime(GSM_DateTime *dt, unsigned char *input)
258{ 240{
259 dt->Year=2000+(*input-'0')*10; input++; 241 /* Samsung phones report year as %d instead of %02d */
242 if (input[2] == '/') {
243 dt->Year=(*input-'0')*10;
244 input++;
245 } else {
246 dt->Year=0;
247 }
248
260 dt->Year=dt->Year+(*input-'0'); input++; 249 dt->Year=dt->Year+(*input-'0'); input++;
250 dt->Year+=2000;
261 251
262 input++; 252 input++;
@@ -323,4 +313,16 @@ GSM_Error ATGEN_DispatchMessage(GSM_StateMachine *s)
323 ErrorCodes = CMSErrorCodes; 313 ErrorCodes = CMSErrorCodes;
324 } 314 }
315
316 /* FIXME: Samsung phones can answer +CME ERROR:-1 meaning empty location */
317 if (Priv->ReplyState == AT_Reply_CMEError && Priv->Manufacturer == AT_Samsung) {
318 err = line + 11;
319 Priv->ErrorCode = atoi(err);
320
321 if (Priv->ErrorCode == -1) {
322 Priv->ErrorText = "[Samsung] Empty location";
323 return GSM_DispatchMessage(s);
324 }
325 }
326
325 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) { 327 if (Priv->ReplyState == AT_Reply_CMEError || Priv->ReplyState == AT_Reply_CMSError) {
326 j = 0; 328 j = 0;
@@ -371,4 +373,40 @@ GSM_Error ATGEN_GenericReply(GSM_Protocol_Message msg, GSM_StateMachine *s)
371} 373}
372 374
375GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message msg, GSM_StateMachine *s)
376{
377 unsigned char buffer[2000],buffer2[4000];
378 int i = 10;
379
380 /* Ugly hack */
381 while (msg.Buffer[i]!=13) i++;
382 i = i - 6;
383 memcpy(buffer,msg.Buffer+10,i-11);
384 buffer[i-11] = 0x00;
385
386 smprintf(s, "USSD reply: \"%s\"\n",buffer);
387
388 if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
389 EncodeUnicode(buffer2,buffer,strlen(buffer));
390 s->User.IncomingUSSD(s->CurrentConfig->Device, buffer2);
391 }
392
393 return ERR_NONE;
394}
395
396GSM_Error ATGEN_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
397{
398 GSM_Error error;
399
400 if (enable) {
401 smprintf(s, "Enabling incoming USSD\n");
402 error=GSM_WaitFor (s, "AT+CUSD=1\r", 10, 0x00, 3, ID_SetUSSD);
403 } else {
404 smprintf(s, "Disabling incoming USSD\n");
405 error=GSM_WaitFor (s, "AT+CUSD=0\r", 10, 0x00, 3, ID_SetUSSD);
406 }
407 if (error==ERR_NONE) s->Phone.Data.EnableIncomingUSSD = enable;
408 return error;
409}
410
373GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s) 411GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
374{ 412{
@@ -395,8 +433,10 @@ GSM_Error ATGEN_ReplyGetModel(GSM_Protocol_Message msg, GSM_StateMachine *s)
395 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens; 433 else if (strstr(msg.Buffer,"M20")) Priv->Manufacturer = AT_Siemens;
396 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens; 434 else if (strstr(msg.Buffer,"MC35")) Priv->Manufacturer = AT_Siemens;
435 else if (strstr(msg.Buffer,"TC35")) Priv->Manufacturer = AT_Siemens;
397 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP; 436 else if (strstr(msg.Buffer, "iPAQ")) Priv->Manufacturer = AT_HP;
398 437
399 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20"); 438 if (strstr(msg.Buffer,"M20")) strcpy(Data->Model,"M20");
400 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35"); 439 else if (strstr(msg.Buffer,"MC35")) strcpy(Data->Model,"MC35");
440 else if (strstr(msg.Buffer,"TC35")) strcpy(Data->Model,"TC35");
401 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ"); 441 else if (strstr(msg.Buffer, "iPAQ")) strcpy(Data->Model,"iPAQ");
402 } else { 442 } else {
@@ -482,4 +522,9 @@ GSM_Error ATGEN_ReplyGetManufacturer(GSM_Protocol_Message msg, GSM_StateMachine
482 Priv->Manufacturer = AT_Sagem; 522 Priv->Manufacturer = AT_Sagem;
483 } 523 }
524 if (strstr(msg.Buffer,"Samsung")) {
525 smprintf(s, "Samsung\n");
526 strcpy(s->Phone.Data.Manufacturer,"Samsung");
527 Priv->Manufacturer = AT_Samsung;
528 }
484 return ERR_NONE; 529 return ERR_NONE;
485 case AT_Reply_CMSError: 530 case AT_Reply_CMSError:
@@ -675,14 +720,24 @@ GSM_Error ATGEN_ReplyGetSMSMemories(GSM_Protocol_Message msg, GSM_StateMachine *
675 * for "), (", which will appear between lists. 720 * for "), (", which will appear between lists.
676 */ 721 */
677 s->Phone.Data.Priv.ATGEN.CanSaveSMS = (strstr(msg.Buffer, "), (") != NULL); 722 s->Phone.Data.Priv.ATGEN.CanSaveSMS = false;
723 if (strstr(msg.Buffer, "), (") != NULL || strstr(msg.Buffer, "),(") != NULL) {
724 s->Phone.Data.Priv.ATGEN.CanSaveSMS = true;
725 }
726
678 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE; 727 if (strstr(msg.Buffer, "\"SM\"") != NULL) s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_AVAILABLE;
679 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE; 728 else s->Phone.Data.Priv.ATGEN.SIMSMSMemory = AT_NOTAVAILABLE;
729
680 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE; 730 if (strstr(msg.Buffer, "\"ME\"") != NULL) s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_AVAILABLE;
681 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE; 731 else s->Phone.Data.Priv.ATGEN.PhoneSMSMemory = AT_NOTAVAILABLE;
682 smprintf(s, "Available SMS memories received, ME = %d, SM = %d\n", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory); 732
733 smprintf(s, "Available SMS memories received, ME = %d, SM = %d, cansavesms =", s->Phone.Data.Priv.ATGEN.PhoneSMSMemory, s->Phone.Data.Priv.ATGEN.SIMSMSMemory);
734 if (s->Phone.Data.Priv.ATGEN.CanSaveSMS) smprintf(s, "true");
735 smprintf(s, "\n");
683 return ERR_NONE; 736 return ERR_NONE;
684 case AT_Reply_Error: 737 case AT_Reply_Error:
685 case AT_Reply_CMSError: 738 case AT_Reply_CMSError:
686 return ATGEN_HandleCMSError(s); 739 return ATGEN_HandleCMSError(s);
740 case AT_Reply_CMEError:
741 return ATGEN_HandleCMEError(s);
687 default: 742 default:
688 return ERR_UNKNOWNRESPONSE; 743 return ERR_UNKNOWNRESPONSE;
@@ -859,6 +914,7 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
859 /* Siemens M20 */ 914 /* Siemens M20 */
860 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 915 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
861 if (buffer[1]!=NUMBER_UNKNOWN && buffer[1]!=NUMBER_INTERNATIONAL && 916 /* we check for the most often visible */
862 buffer[1]!=NUMBER_ALPHANUMERIC) { 917 if (buffer[1]!=NUMBER_UNKNOWN_NUMBERING_PLAN_ISDN && buffer[1]!=NUMBER_INTERNATIONAL_NUMBERING_PLAN_ISDN &&
918 buffer[1]!=NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
863 /* Seems to be Delivery Report */ 919 /* Seems to be Delivery Report */
864 smprintf(s, "SMS type - status report (M20 style)\n"); 920 smprintf(s, "SMS type - status report (M20 style)\n");
@@ -895,5 +951,5 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
895 current2=((buffer[current])+1)/2+1; 951 current2=((buffer[current])+1)/2+1;
896 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 952 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
897 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 953 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
898 smprintf(s, "Trying to read alphanumeric number\n"); 954 smprintf(s, "Trying to read alphanumeric number\n");
899 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++]; 955 for(i=0;i<4;i++) smsframe[PHONE_SMSDeliver.Number+i]=buffer[current++];
@@ -926,5 +982,5 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
926 current2=((buffer[current])+1)/2+1; 982 current2=((buffer[current])+1)/2+1;
927 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) { 983 if (IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_M20SMS)) {
928 if (buffer[current+1]==NUMBER_ALPHANUMERIC) { 984 if (buffer[current+1]==NUMBER_ALPHANUMERIC_NUMBERING_PLAN_UNKNOWN) {
929 smprintf(s, "Trying to read alphanumeric number\n"); 985 smprintf(s, "Trying to read alphanumeric number\n");
930 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++]; 986 for(i=0;i<4;i++) smsframe[PHONE_SMSSubmit.Number+i]=buffer[current++];
@@ -950,5 +1006,5 @@ GSM_Error ATGEN_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s
950 sms->Folder = 1;/*INBOX SIM*/ 1006 sms->Folder = 1;/*INBOX SIM*/
951 sms->InboxFolder = true; 1007 sms->InboxFolder = true;
952 smprintf(s, "TPMR is %02x\n",buffer[current]); 1008 smprintf(s, "TPMR is %d\n",buffer[current]);
953 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++]; 1009 smsframe[PHONE_SMSStatusReport.TPMR] = buffer[current++];
954 current2=((buffer[current])+1)/2+1; 1010 current2=((buffer[current])+1)/2+1;
@@ -1641,9 +1697,9 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1641 smprintf(s, "SMS sent OK\n"); 1697 smprintf(s, "SMS sent OK\n");
1642 if (s->User.SendSMSStatus!=NULL) { 1698 if (s->User.SendSMSStatus!=NULL) {
1643 start = strstr(msg.Buffer, "+CMGW: "); 1699 start = strstr(msg.Buffer, "+CMGS: ");
1644 if (start != NULL) { 1700 if (start != NULL) {
1645 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7)); 1701 s->User.SendSMSStatus(s->CurrentConfig->Device,0,atoi(start+7));
1646 } else { 1702 } else {
1647 s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); 1703 s->User.SendSMSStatus(s->CurrentConfig->Device,0,-1);
1648 } 1704 }
1649 } 1705 }
@@ -1651,5 +1707,5 @@ GSM_Error ATGEN_ReplySendSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1651 case AT_Reply_CMSError: 1707 case AT_Reply_CMSError:
1652 smprintf(s, "Error %i\n",Priv->ErrorCode); 1708 smprintf(s, "Error %i\n",Priv->ErrorCode);
1653 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,0); 1709 if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,Priv->ErrorCode,-1);
1654 return ATGEN_HandleCMSError(s); 1710 return ATGEN_HandleCMSError(s);
1655 case AT_Reply_Error: 1711 case AT_Reply_Error:
@@ -1788,4 +1844,17 @@ GSM_Error ATGEN_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1788} 1844}
1789 1845
1846/* R320 only takes HH:MM. Do other phones understand full date? */
1847GSM_Error ATGEN_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
1848{
1849 char req[20];
1850
1851 if (alarm->Location != 1) return ERR_INVALIDLOCATION;
1852
1853 sprintf(req, "AT+CALA=\"%02i:%02i\"\r",alarm->DateTime.Hour,alarm->DateTime.Minute);
1854
1855 smprintf(s, "Setting Alarm\n");
1856 return GSM_WaitFor (s, req, strlen(req), 0x00, 3, ID_SetAlarm);
1857}
1858
1790GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) 1859GSM_Error ATGEN_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s)
1791{ 1860{
@@ -2203,4 +2272,6 @@ GSM_Error ATGEN_GetMemoryInfo(GSM_StateMachine *s, GSM_MemoryStatus *Status, GSM
2203 2272
2204 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus); 2273 error = GSM_WaitFor (s, "AT+CPBR=?\r", 10, 0x00, 4, ID_GetMemoryStatus);
2274 if (Priv->Manufacturer == AT_Samsung)
2275 error = GSM_WaitFor (s, "", 0, 0x00, 4, ID_GetMemoryStatus);
2205 if (error != ERR_NONE) return error; 2276 if (error != ERR_NONE) return error;
2206 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE; 2277 if (NeededInfo == AT_Total || NeededInfo == AT_Sizes || NeededInfo == AT_First) return ERR_NONE;
@@ -2269,4 +2340,10 @@ GSM_Error ATGEN_SetPBKCharset(GSM_StateMachine *s, bool PreferUnicode)
2269 if (error != ERR_NONE) return error; 2340 if (error != ERR_NONE) return error;
2270 2341
2342 /* Samsung (and Sagem?) phones use only PCCP437? */
2343 if (Priv->Manufacturer == AT_Samsung) {
2344 Priv->PBKCharset = AT_PBK_PCCP437;
2345 return ERR_NONE;
2346 }
2347
2271 if (PreferUnicode && !Priv->UCS2CharsetFailed) { 2348 if (PreferUnicode && !Priv->UCS2CharsetFailed) {
2272 smprintf(s, "Setting charset to UCS2\n"); 2349 smprintf(s, "Setting charset to UCS2\n");
@@ -2386,5 +2463,35 @@ GSM_Error ATGEN_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
2386 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1); 2463 DecodeHexUnicode(Memory->Entries[1].Text,buffer+1,strlen(buffer+1) - 1);
2387 break; 2464 break;
2465 case AT_PBK_PCCP437:
2466 /* FIXME: correctly decode PCCP437 */
2467 DecodeDefault(Memory->Entries[1].Text,buffer+1,strlen(buffer)-2,false,NULL);
2468 break;
2469 }
2470
2471 /* Samsung number type */
2472 if (Priv->Manufacturer == AT_Samsung) {
2473 int type;
2474
2475 pos += ATGEN_ExtractOneParameter(pos, buffer);
2476 smprintf(s, "Number type: %s\n",buffer);
2477 type = strtoul(buffer, NULL, 0);
2478 switch (type) {
2479 case 0:
2480 Memory->Entries[0].EntryType = PBK_Number_Mobile;
2481 break;
2482 case 1:
2483 Memory->Entries[0].EntryType = PBK_Number_Work;
2484 break;
2485 case 2:
2486 Memory->Entries[0].EntryType = PBK_Number_Home;
2487 break;
2488 case 3:
2489 Memory->Entries[0].EntryType = PBK_Text_Email;
2490 break;
2491 default:
2492 Memory->Entries[0].EntryType = PBK_Number_General;
2493 }
2388 } 2494 }
2495
2389 return ERR_NONE; 2496 return ERR_NONE;
2390 case AT_Reply_CMEError: 2497 case AT_Reply_CMEError:
@@ -2563,4 +2670,6 @@ GSM_Error ATGEN_ReplyEnterSecurityCode(GSM_Protocol_Message msg, GSM_StateMachin
2563 case AT_Reply_CMSError: 2670 case AT_Reply_CMSError:
2564 return ATGEN_HandleCMSError(s); 2671 return ATGEN_HandleCMSError(s);
2672 case AT_Reply_CMEError:
2673 return ATGEN_HandleCMEError(s);
2565 default: 2674 default:
2566 break; 2675 break;
@@ -2925,4 +3034,10 @@ GSM_Error ATGEN_PrivSetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
2925 len = strlen(name); 3034 len = strlen(name);
2926 break; 3035 break;
3036 case AT_PBK_PCCP437:
3037 /* FIXME: correctly decode PCCP437 */
3038 smprintf(s, "str: %s\n", DecodeUnicodeString(entry->Entries[Name].Text));
3039 len = UnicodeLength(entry->Entries[Name].Text);
3040 EncodeDefault(name, entry->Entries[Name].Text, &len, true, NULL);
3041 break;
2927 } 3042 }
2928 } else { 3043 } else {
@@ -3253,4 +3368,41 @@ GSM_Error ATGEN_DelCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
3253} 3368}
3254 3369
3370
3371GSM_Error ATGEN_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3372{
3373 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3374
3375 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetBitmap(s, Bitmap);
3376 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetBitmap(s, Bitmap);
3377 return ERR_NOTSUPPORTED;
3378}
3379
3380GSM_Error ATGEN_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
3381{
3382 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3383
3384 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetBitmap(s, Bitmap);
3385 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetBitmap(s, Bitmap);
3386 return ERR_NOTSUPPORTED;
3387}
3388
3389GSM_Error ATGEN_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
3390{
3391 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3392
3393 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_GetRingtone(s, Ringtone, PhoneRingtone);
3394 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_GetRingtone(s, Ringtone, PhoneRingtone);
3395 return ERR_NOTSUPPORTED;
3396}
3397
3398GSM_Error ATGEN_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
3399{
3400 GSM_Phone_ATGENData*Priv = &s->Phone.Data.Priv.ATGEN;
3401
3402 if (Priv->Manufacturer==AT_Siemens) return SIEMENS_SetRingtone(s, Ringtone, maxlength);
3403 if (Priv->Manufacturer==AT_Samsung) return SAMSUNG_SetRingtone(s, Ringtone, maxlength);
3404 return ERR_NOTSUPPORTED;
3405}
3406
3255GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press) 3407GSM_Error ATGEN_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, bool Press)
3256{ 3408{
@@ -3347,4 +3499,15 @@ GSM_Error ATGEN_SetIncomingCB(GSM_StateMachine *s, bool enable)
3347} 3499}
3348 3500
3501GSM_Error ATGEN_SetFastSMSSending(GSM_StateMachine *s, bool enable)
3502{
3503 if (enable) {
3504 smprintf(s, "Enabling fast SMS sending\n");
3505 return GSM_WaitFor(s, "AT+CMMS=2\r", 10, 0x00, 4, ID_SetFastSMSSending);
3506 } else {
3507 smprintf(s, "Disabling fast SMS sending\n");
3508 return GSM_WaitFor(s, "AT+CMMS=0\r", 10, 0x00, 4, ID_SetFastSMSSending);
3509 }
3510}
3511
3349GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) 3512GSM_Error ATGEN_IncomingSMSInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
3350{ 3513{
@@ -3425,4 +3588,16 @@ GSM_Error ATGEN_SetIncomingSMS(GSM_StateMachine *s, bool enable)
3425} 3588}
3426 3589
3590GSM_Error ATGEN_GetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3591{
3592 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_GetLocale(s,locale);
3593 return ERR_NOTSUPPORTED;
3594}
3595
3596GSM_Error ATGEN_SetLocale(GSM_StateMachine *s, GSM_Locale *locale)
3597{
3598 if (s->Phone.Data.Priv.ATGEN.Manufacturer==AT_Ericsson) return ERICSSON_SetLocale(s,locale);
3599 return ERR_NOTSUPPORTED;
3600}
3601
3427GSM_Reply_Function ATGENReplyFunctions[] = { 3602GSM_Reply_Function ATGENReplyFunctions[] = {
3428 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame }, 3603 {ATGEN_GenericReply, "AT\r" ,0x00,0x00,ID_IncomingFrame },
@@ -3433,4 +3608,9 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3433 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX }, 3608 {ATGEN_GenericReply, "AT*EOBEX" ,0x00,0x00,ID_SetOBEX },
3434 3609
3610 {ERICSSON_ReplyGetDateLocale, "*ESDF:" ,0x00,0x00,ID_GetLocale },
3611 {ERICSSON_ReplyGetTimeLocale, "*ESTF:" ,0x00,0x00,ID_GetLocale },
3612 {ATGEN_GenericReply, "AT*ESDF=" ,0x00,0x00,ID_SetLocale },
3613 {ATGEN_GenericReply, "AT*ESTF=" ,0x00,0x00,ID_SetLocale },
3614
3435#ifdef GSM_ENABLE_CELLBROADCAST 3615#ifdef GSM_ENABLE_CELLBROADCAST
3436 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame }, 3616 {ATGEN_ReplyIncomingCB, "+CBM:" ,0x00,0x00,ID_IncomingFrame },
@@ -3463,4 +3643,5 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3463 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters }, 3643 {ATGEN_GenericReply, "ATE1" ,0x00,0x00,ID_SetSMSParameters },
3464 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters }, 3644 {ATGEN_GenericReply, "\x1b\x0D" ,0x00,0x00,ID_SetSMSParameters },
3645 {ATGEN_GenericReply, "AT+CMMS" ,0x00,0x00,ID_SetFastSMSSending },
3465 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame }, 3646 {ATGEN_IncomingSMSInfo, "+CMTI:" ,0x00,0x00,ID_IncomingFrame },
3466 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame }, 3647 {ATGEN_IncomingSMSDeliver, "+CMT:" ,0x00,0x00,ID_IncomingFrame },
@@ -3470,4 +3651,5 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3470 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime }, 3651 {ATGEN_ReplyGetDateTime_Alarm, "AT+CCLK?" ,0x00,0x00,ID_GetDateTime },
3471 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime }, 3652 {ATGEN_GenericReply, "AT+CCLK=" ,0x00,0x00,ID_SetDateTime },
3653 {ATGEN_GenericReply, "AT+CALA=" ,0x00,0x00,ID_SetAlarm },
3472 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm }, 3654 {ATGEN_ReplyGetDateTime_Alarm, "AT+CALA?" ,0x00,0x00,ID_GetAlarm },
3473 3655
@@ -3485,21 +3667,23 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3485 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType }, 3667 {ATGEN_GenericReply, "AT+CPBS=" ,0x00,0x00,ID_SetMemoryType },
3486 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus }, 3668 {ATGEN_ReplyGetCPBSMemoryStatus,"AT+CPBS?" ,0x00,0x00,ID_GetMemoryStatus },
3669// /* Samsung phones reply +CPBR: after OK --claudio*/
3487 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus }, 3670 {ATGEN_ReplyGetCPBRMemoryInfo, "AT+CPBR=?" ,0x00,0x00,ID_GetMemoryStatus },
3671 {ATGEN_ReplyGetCPBRMemoryInfo, "+CPBR:" ,0x00,0x00,ID_GetMemoryStatus },
3488 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus }, 3672 {ATGEN_ReplyGetCPBRMemoryStatus,"AT+CPBR=" ,0x00,0x00,ID_GetMemoryStatus },
3489 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset }, 3673 {ATGEN_GenericReply, "AT+CSCS=" ,0x00,0x00,ID_SetMemoryCharset },
3490 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory }, 3674 {ATGEN_ReplyGetMemory, "AT+CPBR=" ,0x00,0x00,ID_GetMemory },
3491 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory }, 3675 {ATGEN_GenericReply, "AT^SBNR=?" ,0x00,0x00,ID_GetMemory },
3492 {ATGEN_SL45ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory }, 3676 {SIEMENS_ReplyGetMemory, "AT^SBNR" ,0x00,0x00,ID_GetMemory },
3493 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory }, 3677 {ATGEN_ReplySetMemory, "AT+CPBW" ,0x00,0x00,ID_SetMemory },
3494 3678
3495 {ATGEN_CMS35ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap }, 3679 {SIEMENS_ReplyGetBitmap, "AT^SBNR=\"bmp\"" ,0x00,0x00,ID_GetBitmap },
3496 {ATGEN_CMS35ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap }, 3680 {SIEMENS_ReplySetBitmap, "AT^SBNW=\"bmp\"" ,0x00,0x00,ID_SetBitmap },
3497 3681
3498 {ATGEN_CMS35ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone }, 3682 {SIEMENS_ReplyGetRingtone, "AT^SBNR=\"mid\"" ,0x00,0x00,ID_GetRingtone },
3499 {ATGEN_CMS35ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone }, 3683 {SIEMENS_ReplySetRingtone, "AT^SBNW=\"mid\"" ,0x00,0x00,ID_SetRingtone },
3500 3684
3501 {ATGEN_CMS35ReplyGetNextCal, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote }, 3685 {SIEMENS_ReplyGetNextCalendar, "AT^SBNR=\"vcs\"" ,0x00,0x00,ID_GetCalendarNote },
3502 {ATGEN_CMS35ReplySetCalendar, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote }, 3686 {SIEMENS_ReplyAddCalendarNote, "AT^SBNW=\"vcs\"" ,0x00,0x00,ID_SetCalendarNote },
3503 {ATGEN_CMS35ReplyDeleteCalendar,"AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote }, 3687 {SIEMENS_ReplyDelCalendarNote, "AT^SBNW=\"vcs\"",0x00,0x00,ID_DeleteCalendarNote },
3504 3688
3505 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode }, 3689 {ATGEN_ReplyEnterSecurityCode, "AT+CPIN=" ,0x00,0x00,ID_EnterSecurityCode },
@@ -3512,4 +3696,6 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3512 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice }, 3696 {ATGEN_ReplyDialVoice, "ATDT" ,0x00,0x00,ID_DialVoice },
3513 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall }, 3697 {ATGEN_ReplyCancelCall, "ATH" ,0x00,0x00,ID_CancelCall },
3698 {ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
3699 {ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
3514 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame }, 3700 {ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
3515 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame }, 3701 {ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
@@ -3522,4 +3708,10 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3522 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings }, 3708 {ATGEN_ReplyResetPhoneSettings, "AT&F" ,0x00,0x00,ID_ResetPhoneSettings },
3523 3709
3710 {SAMSUNG_ReplyGetBitmap, "AT+IMGR=" ,0x00,0x00,ID_GetBitmap },
3711 {SAMSUNG_ReplySetBitmap, "SDNDCRC =" ,0x00,0x00,ID_SetBitmap },
3712
3713 {SAMSUNG_ReplyGetRingtone, "AT+MELR=" ,0x00,0x00,ID_GetRingtone },
3714 {SAMSUNG_ReplySetRingtone, "SDNDCRC =" ,0x00,0x00,ID_SetRingtone },
3715
3524#ifdef GSM_ENABLE_ALCATEL 3716#ifdef GSM_ENABLE_ALCATEL
3525/* Why do I give Alcatel specific things here? It's simple, Alcatel needs 3717/* Why do I give Alcatel specific things here? It's simple, Alcatel needs
@@ -3539,5 +3731,5 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
3539 3731
3540GSM_Phone_Functions ATGENPhone = { 3732GSM_Phone_Functions ATGENPhone = {
3541 "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", 3733 "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",
3542 ATGENReplyFunctions, 3734 ATGENReplyFunctions,
3543 ATGEN_Initialise, 3735 ATGEN_Initialise,
@@ -3558,7 +3750,7 @@ GSM_Phone_Functions ATGENPhone = {
3558 ATGEN_SetDateTime, 3750 ATGEN_SetDateTime,
3559 ATGEN_GetAlarm, 3751 ATGEN_GetAlarm,
3560 NOTIMPLEMENTED, /* SetAlarm */ 3752 ATGEN_SetAlarm,
3561 NOTSUPPORTED, /* GetLocale */ 3753 ATGEN_GetLocale,
3562 NOTSUPPORTED, /* SetLocale */ 3754 ATGEN_SetLocale,
3563 ATGEN_PressKey, 3755 ATGEN_PressKey,
3564 ATGEN_Reset, 3756 ATGEN_Reset,
@@ -3593,4 +3785,5 @@ GSM_Phone_Functions ATGENPhone = {
3593 ATGEN_SendSMS, 3785 ATGEN_SendSMS,
3594 ATGEN_SendSavedSMS, 3786 ATGEN_SendSavedSMS,
3787 ATGEN_SetFastSMSSending,
3595 ATGEN_SetIncomingSMS, 3788 ATGEN_SetIncomingSMS,
3596 ATGEN_SetIncomingCB, 3789 ATGEN_SetIncomingCB,
@@ -3611,5 +3804,5 @@ GSM_Phone_Functions ATGENPhone = {
3611 NOTSUPPORTED, /* CancelAllDiverts*/ 3804 NOTSUPPORTED, /* CancelAllDiverts*/
3612 NONEFUNCTION, /* SetIncomingCall */ 3805 NONEFUNCTION, /* SetIncomingCall */
3613 NOTSUPPORTED, /* SetIncomingUSSD */ 3806 ATGEN_SetIncomingUSSD,
3614 ATGEN_SendDTMF, 3807 ATGEN_SendDTMF,
3615 ATGEN_GetRingtone, 3808 ATGEN_GetRingtone,
@@ -3647,5 +3840,5 @@ GSM_Phone_Functions ATGENPhone = {
3647 NOTSUPPORTED, /* GetCalendarSettings*/ 3840 NOTSUPPORTED, /* GetCalendarSettings*/
3648 NOTSUPPORTED, /* SetCalendarSettings*/ 3841 NOTSUPPORTED, /* SetCalendarSettings*/
3649 NOTSUPPORTED, /* GetNote */ 3842 NOTSUPPORTED, /* GetNextNote */
3650 NOTSUPPORTED, /* GetProfile */ 3843 NOTSUPPORTED, /* GetProfile */
3651 NOTSUPPORTED, /* SetProfile */ 3844 NOTSUPPORTED, /* SetProfile */