8 #ifdef GSM_ENABLE_ATGEN 14 #include "../../misc/coding/coding.h" 15 #include "../../gsmcomon.h" 30 static struct ModelRes modres[] = {
44 static unsigned int crc32tab[] = {
45 0xD202EF8D, 0xA505DF1B, 0x3C0C8EA1, 0x4B0BBE37,
46 0xD56F2B94, 0xA2681B02, 0x3B614AB8, 0x4C667A2E,
47 0xDCD967BF, 0xABDE5729, 0x32D70693, 0x45D03605,
48 0xDBB4A3A6, 0xACB39330, 0x35BAC28A, 0x42BDF21C,
49 0xCFB5FFE9, 0xB8B2CF7F, 0x21BB9EC5, 0x56BCAE53,
50 0xC8D83BF0, 0xBFDF0B66, 0x26D65ADC, 0x51D16A4A,
51 0xC16E77DB, 0xB669474D, 0x2F6016F7, 0x58672661,
52 0xC603B3C2, 0xB1048354, 0x280DD2EE, 0x5F0AE278,
53 0xE96CCF45, 0x9E6BFFD3, 0x0762AE69, 0x70659EFF,
54 0xEE010B5C, 0x99063BCA, 0x000F6A70, 0x77085AE6,
55 0xE7B74777, 0x90B077E1, 0x09B9265B, 0x7EBE16CD,
56 0xE0DA836E, 0x97DDB3F8, 0x0ED4E242, 0x79D3D2D4,
57 0xF4DBDF21, 0x83DCEFB7, 0x1AD5BE0D, 0x6DD28E9B,
58 0xF3B61B38, 0x84B12BAE, 0x1DB87A14, 0x6ABF4A82,
59 0xFA005713, 0x8D076785, 0x140E363F, 0x630906A9,
60 0xFD6D930A, 0x8A6AA39C, 0x1363F226, 0x6464C2B0,
61 0xA4DEAE1D, 0xD3D99E8B, 0x4AD0CF31, 0x3DD7FFA7,
62 0xA3B36A04, 0xD4B45A92, 0x4DBD0B28, 0x3ABA3BBE,
63 0xAA05262F, 0xDD0216B9, 0x440B4703, 0x330C7795,
64 0xAD68E236, 0xDA6FD2A0, 0x4366831A, 0x3461B38C,
65 0xB969BE79, 0xCE6E8EEF, 0x5767DF55, 0x2060EFC3,
66 0xBE047A60, 0xC9034AF6, 0x500A1B4C, 0x270D2BDA,
67 0xB7B2364B, 0xC0B506DD, 0x59BC5767, 0x2EBB67F1,
68 0xB0DFF252, 0xC7D8C2C4, 0x5ED1937E, 0x29D6A3E8,
69 0x9FB08ED5, 0xE8B7BE43, 0x71BEEFF9, 0x06B9DF6F,
70 0x98DD4ACC, 0xEFDA7A5A, 0x76D32BE0, 0x01D41B76,
71 0x916B06E7, 0xE66C3671, 0x7F6567CB, 0x0862575D,
72 0x9606C2FE, 0xE101F268, 0x7808A3D2, 0x0F0F9344,
73 0x82079EB1, 0xF500AE27, 0x6C09FF9D, 0x1B0ECF0B,
74 0x856A5AA8, 0xF26D6A3E, 0x6B643B84, 0x1C630B12,
75 0x8CDC1683, 0xFBDB2615, 0x62D277AF, 0x15D54739,
76 0x8BB1D29A, 0xFCB6E20C, 0x65BFB3B6, 0x12B88320,
77 0x3FBA6CAD, 0x48BD5C3B, 0xD1B40D81, 0xA6B33D17,
78 0x38D7A8B4, 0x4FD09822, 0xD6D9C998, 0xA1DEF90E,
79 0x3161E49F, 0x4666D409, 0xDF6F85B3, 0xA868B525,
80 0x360C2086, 0x410B1010, 0xD80241AA, 0xAF05713C,
81 0x220D7CC9, 0x550A4C5F, 0xCC031DE5, 0xBB042D73,
82 0x2560B8D0, 0x52678846, 0xCB6ED9FC, 0xBC69E96A,
83 0x2CD6F4FB, 0x5BD1C46D, 0xC2D895D7, 0xB5DFA541,
84 0x2BBB30E2, 0x5CBC0074, 0xC5B551CE, 0xB2B26158,
85 0x04D44C65, 0x73D37CF3, 0xEADA2D49, 0x9DDD1DDF,
86 0x03B9887C, 0x74BEB8EA, 0xEDB7E950, 0x9AB0D9C6,
87 0x0A0FC457, 0x7D08F4C1, 0xE401A57B, 0x930695ED,
88 0x0D62004E, 0x7A6530D8, 0xE36C6162, 0x946B51F4,
89 0x19635C01, 0x6E646C97, 0xF76D3D2D, 0x806A0DBB,
90 0x1E0E9818, 0x6909A88E, 0xF000F934, 0x8707C9A2,
91 0x17B8D433, 0x60BFE4A5, 0xF9B6B51F, 0x8EB18589,
92 0x10D5102A, 0x67D220BC, 0xFEDB7106, 0x89DC4190,
93 0x49662D3D, 0x3E611DAB, 0xA7684C11, 0xD06F7C87,
94 0x4E0BE924, 0x390CD9B2, 0xA0058808, 0xD702B89E,
95 0x47BDA50F, 0x30BA9599, 0xA9B3C423, 0xDEB4F4B5,
96 0x40D06116, 0x37D75180, 0xAEDE003A, 0xD9D930AC,
97 0x54D13D59, 0x23D60DCF, 0xBADF5C75, 0xCDD86CE3,
98 0x53BCF940, 0x24BBC9D6, 0xBDB2986C, 0xCAB5A8FA,
99 0x5A0AB56B, 0x2D0D85FD, 0xB404D447, 0xC303E4D1,
100 0x5D677172, 0x2A6041E4, 0xB369105E, 0xC46E20C8,
101 0x72080DF5, 0x050F3D63, 0x9C066CD9, 0xEB015C4F,
102 0x7565C9EC, 0x0262F97A, 0x9B6BA8C0, 0xEC6C9856,
103 0x7CD385C7, 0x0BD4B551, 0x92DDE4EB, 0xE5DAD47D,
104 0x7BBE41DE, 0x0CB97148, 0x95B020F2, 0xE2B71064,
105 0x6FBF1D91, 0x18B82D07, 0x81B17CBD, 0xF6B64C2B,
106 0x68D2D988, 0x1FD5E91E, 0x86DCB8A4, 0xF1DB8832,
107 0x616495A3, 0x1663A535, 0x8F6AF48F, 0xF86DC419,
108 0x660951BA, 0x110E612C, 0x88073096, 0xFF000000
111 static unsigned int GetCRC(
char *data,
int size)
113 unsigned int crc = 0;
116 crc = crc32tab[(crc ^ *data++) & 0xff] ^ ((crc >> 8) & 0x00FFFFFF);
127 char readbuf[100]={0};
137 while (strstr(readbuf, t) == NULL && (sec + ttl) >= Date.
Second) {
153 count = size / BLKSZ;
155 for (i = 0; i < count; i++) {
156 error = WaitFor(s,
">", 4);
160 buff + i * BLKSZ, BLKSZ, 0x00);
164 error = WaitFor(s,
">", 4);
167 buff + i * BLKSZ, size%BLKSZ, 0x00);
183 unsigned long txcrc, rxcrc;
188 pos = strchr(msg->
Buffer,
'=');
191 txcrc = strtoul(pos, NULL, 0);
192 smprintf(s,
"Sent CRC : 0x%lx\n", txcrc);
195 pos = strchr(pos,
'=');
198 rxcrc = strtoul(pos, NULL, 0);
199 smprintf(s,
"Reveived CRC : 0x%lx\n", rxcrc);
202 pos = strchr(pos,
'=');
205 binsize = strtoul(pos, NULL, 0);
206 smprintf(s,
"Binary size : %d\n", binsize);
224 smprintf(s,
"Bitmap info received\n");
228 pos = strchr(msg->
Buffer,
':');
231 location = atoi(pos);
232 smprintf(s,
"Location : %d\n", location);
235 pos = strchr(pos,
'"');
238 for (count = 0; count < 31; count++) {
239 if (pos[count] ==
'"')
241 buffer[count] = pos[count];
264 return ReplySetSamsungFrame(msg, s);
269 unsigned char req[100];
274 len = sprintf(req,
"AT+IMGR=%d\r", Bitmap->
Location-1);
280 unsigned char req[100];
293 smprintf(s,
"Invalid picture type\n");
298 smprintf(s,
"Invalid binary picture type\n");
304 smprintf(s,
"Checking picture size for %s\n", model);
305 for (i = 0; modres[i].model; i++) {
306 if (!strcmp(model, modres[i].model)) {
309 smprintf(s,
"Model %s must use %ld x %ld picture size\n",
311 (
long)modres[i].width,
312 (
long)modres[i].height);
318 if (modres[i].model == NULL) {
319 smprintf(s,
"Model \"%s\" is not supported.\n", Data->
Model);
328 if ((dot = strrchr(name,
'.')) != NULL)
331 len = sprintf(req,
"AT+IMGW=0,\"%s\",2,0,0,0,0,100,%ld,%u\r", name,
348 unsigned char buffer[32];
350 int location, length, count;
354 smprintf(s,
"Ringtone info received\n");
358 pos = strchr(msg->
Buffer,
':');
361 location = atoi(pos);
362 smprintf(s,
"Location : %d\n", location);
365 pos = strchr(pos,
'"');
369 for (count = 0; count < 19; count++) {
370 if (pos[count] ==
'"')
372 buffer[count] = pos[count];
379 pos = strchr(pos,
',');
383 smprintf(s,
"Length : %d\n", length);
404 unsigned char req[100];
409 len = sprintf(req,
"AT+MELR=%d\r", Ringtone->
Location-1);
416 return ReplySetSamsungFrame(msg, s);
421 unsigned char req[100];
438 if ((dot = strrchr(name,
'.')) != NULL) *dot = 0;
441 len = sprintf(req,
"AT+MELW=0,\"%s\",4,%ld,%u\r", name,
463 smprintf(s,
"Checking for supported calendar commands\n");
511 int i, j, year = 1900, month = 0, day = 0;
515 smprintf(s,
"Phonebook entry received\n");
585 if (strcmp(str,
"OK") == 0)
return ERR_EMPTY;
617 "+SPBR: @i, @p, @p, @p, @p, @p, @s, @T, @T, @T, @T",
635 "+SPBR: @i, @p, @p, @p, @p, @p, @s, @T, @T, @i, @i, @i, @T, @T",
655 "+SPBR: @i, @T, @T, @T, @T, @T, @T, @T, @T, @T, @T, @T, @i, @i, @i, @T",
677 for (j = i + 1; j < Memory->
EntriesNum; j++) {
722 SAMSUNG_CheckCalendar(s);
731 smprintf(s,
"Setting memory for Samsung not implemented yet!\n");
760 "+ORGI: @i, @i, @i, @i, @i",
766 if (error !=
ERR_NONE)
return error;
796 if (error !=
ERR_NONE)
return error;
808 SAMSUNG_CheckCalendar(s);
826 int ignore, alarm_flag, alarm_time, alarm_quantity, alarm_repeat;
827 char ignorestring[10];
865 "+ORGR: @i, @i, @S, @S, @i, @i, @i, @i, @i, @i, @i, @i, @i, @i, @s, @I, @I, @I, @I, @s, @s, @I, @I, @I",
885 ignorestring,
sizeof(ignorestring),
886 ignorestring,
sizeof(ignorestring),
891 if (error !=
ERR_NONE)
return error;
898 int ignore, alarm_flag, alarm_time, alarm_quantity, alarm_repeat;
899 char ignorestring[10];
932 "+ORGR: @i, @i, @S, @S, @i, @i, @i, @i, @i, @s, @s, @s, @s, @s, @s, @i, @i, @i, @i, @0",
935 ignorestring,
sizeof(ignorestring),
942 ignorestring,
sizeof(ignorestring),
943 ignorestring,
sizeof(ignorestring),
944 ignorestring,
sizeof(ignorestring),
945 ignorestring,
sizeof(ignorestring),
946 ignorestring,
sizeof(ignorestring),
947 ignorestring,
sizeof(ignorestring),
953 if (error !=
ERR_NONE)
return error;
960 int ignore, alarm_flag, alarm_time, alarm_quantity, priority, status;
961 char ignorestring[10];
999 "+ORGR: @i, @i, @S, @S, @i, @i, @i, @i, @i, @i, @i, @i, @s, @s, @s, @i, @i, @i, @s, @i, @i, @0",
1002 ignorestring,
sizeof(ignorestring),
1012 ignorestring,
sizeof(ignorestring),
1013 ignorestring,
sizeof(ignorestring),
1014 ignorestring,
sizeof(ignorestring),
1018 ignorestring,
sizeof(ignorestring),
1022 if (error !=
ERR_NONE)
return error;
1048 if (strcmp(
"OK", line) == 0) {
1054 "+ORGR: @i, @i, @0",
1057 if (error !=
ERR_NONE)
return error;
1074 smprintf(s,
"WARNING: Unknown entry type %d, treating as memo!\n", type);
1090 SAMSUNG_CheckCalendar(s);
1107 smprintf(s,
"Getting calendar entry\n");
1136 SAMSUNG_CheckCalendar(s);
1141 len = sprintf(req,
"AT+ORGR=%d\r", Note->
Location - 1);
1143 len = sprintf(req,
"AT+SSHR=%d\r", Note->
Location);
1164 SAMSUNG_CheckCalendar(s);
1169 len = sprintf(req,
"AT+ORGD=%d\r", Note->
Location - 1);
1171 len = sprintf(req,
"AT+SSHD=%d\r", Note->
Location);
1184 SAMSUNG_CheckCalendar(s);
1199 SAMSUNG_CheckCalendar(s);
unsigned char Name[(GSM_MAX_RINGTONE_NAME_LENGTH+1) *2]
GSM_Error SAMSUNG_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
GSM_Error SAMSUNG_ORG_ReplySetCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
char * DecodeUnicodeString(const unsigned char *src)
GSM_RingtoneFormat Format
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
GSM_Error SAMSUNG_SSH_ReplyGetCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error ATGEN_HandleCMEError(GSM_StateMachine *s)
GSM_Error SAMSUNG_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
GSM_Error SAMSUNG_ParseTask(GSM_StateMachine *s, const char *line)
GSM_Error SAMSUNG_SetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
GSM_Error SAMSUNG_GetBitmap(GSM_StateMachine *, GSM_Bitmap *)
GSM_Error ATGEN_HandleCMSError(GSM_StateMachine *s)
const char * GetLineString(const char *message, GSM_CutLines *lines, int start)
#define ATGEN_WaitForAutoLen(s, cmd, type, time, request)
GSM_BinaryPicture_Types Type
GSM_Error SAMSUNG_ORG_ReplyGetCalendarStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
size_t UnicodeLength(const unsigned char *str)
GSM_Error(* WriteMessage)(GSM_StateMachine *s, unsigned const char *buffer, int length, int type)
GSM_CalendarStatus * CalStatus
GSM_PhoneModel * ModelInfo
GSM_Error SAMSUNG_ReplySetRingtone(GSM_Protocol_Message *, GSM_StateMachine *)
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
GSM_Error SAMSUNG_ReplyGetBitmap(GSM_Protocol_Message *, GSM_StateMachine *)
GSM_Error SAMSUNG_ParseAppointment(GSM_StateMachine *s, const char *line)
GSM_Error SAMSUNG_ReplyGetMemoryInfo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_CalendarNoteType Type
GSM_Error SAMSUNG_ReplyGetMemory(GSM_Protocol_Message *msg, GSM_StateMachine *s)
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
GSM_Error SAMSUNG_SetBitmap(GSM_StateMachine *, GSM_Bitmap *)
struct GSM_Phone_Data::@2 Priv
GSM_Error SAMSUNG_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start)
GSM_Error SAMSUNG_ReplyGetRingtone(GSM_Protocol_Message *, GSM_StateMachine *)
GSM_Error ATGEN_ParseReply(GSM_StateMachine *s, const unsigned char *input, const char *format,...)
GSM_Error GSM_WaitFor(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type, int timeout, GSM_Phone_RequestID request)
GSM_Error SAMSUNG_ORG_ReplyGetCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error SAMSUNG_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
int(* ReadDevice)(GSM_StateMachine *s, void *buf, size_t nbytes)
GSM_Error ATGEN_WaitFor(GSM_StateMachine *s, const char *cmd, size_t len, int type, int time, GSM_Phone_RequestID request)
GSM_CalendarType EntryType
GSM_Device_Functions * Functions
unsigned char Name[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
GSM_BinaryPicture BinaryPic
GSM_BinaryTone BinaryTone
GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]
void GSM_GetCurrentDateTime(GSM_DateTime *Date)
GSM_SamsungCalendar SamsungCalendar
GSM_EntryLocation Location
GSM_Error SAMSUNG_GetCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
GSM_Error SAMSUNG_DelCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
GSM_CalendarStatus CalendarStatus
GSM_Protocol_Functions * Functions
GSM_Error SAMSUNG_SetRingtone(GSM_StateMachine *, GSM_Ringtone *, int *)
GSM_Error SAMSUNG_ParseAniversary(GSM_StateMachine *s, const char *line)
GSM_AT_Reply_State ReplyState
GSM_Error SAMSUNG_GetRingtone(GSM_StateMachine *, GSM_Ringtone *, gboolean)
GSM_Error SAMSUNG_SSH_ReplyGetCalendarStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error SAMSUNG_ReplySetBitmap(GSM_Protocol_Message *, GSM_StateMachine *)
GSM_AT_Manufacturer Manufacturer
char Model[GSM_MAX_MODEL_LENGTH+1]
unsigned char Text[(GSM_MAX_CALENDAR_TEXT_LENGTH+1) *2]
int smprintf(GSM_StateMachine *s, const char *format,...)
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]