Imported gammu 0.90.7
[gammu.git] / common / phone / nokia / dct3 / n7110.c
blob522340d5c2b64619dd1d74f8e1f95e8da721c28b
2 #include "../../../gsmstate.h"
4 #ifdef GSM_ENABLE_NOKIA7110
6 #include <string.h>
7 #include <time.h>
9 #include "../../../misc/coding/coding.h"
10 #include "../../../gsmcomon.h"
11 #include "../../../service/gsmlogo.h"
12 #include "../../pfunc.h"
13 #include "../nfunc.h"
14 #include "../nfuncold.h"
15 #include "n7110.h"
16 #include "dct3func.h"
18 static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
20 return DCT3_GetAlarm(s, alarm, 0x19);
23 static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
25 return DCT3_SetAlarm(s, alarm, 0x19);
28 static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
30 GSM_Phone_Data *Data = &s->Phone.Data;
32 smprintf(s, "Phonebook entry received\n");
33 switch (msg.Buffer[6]) {
34 case 0x0f:
35 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
36 default:
37 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18);
39 return GE_UNKNOWN;
42 static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
44 unsigned char req[] = {
45 N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
46 0x02, /* memory type */
47 0x05,
48 0x00, 0x00, /* location */
49 0x00, 0x00};
51 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
52 if (req[9]==0xff) return GE_NOTSUPPORTED;
54 if (entry->Location==0x00) return GE_INVALIDLOCATION;
56 req[10] = (entry->Location>>8);
57 req[11] = entry->Location & 0xff;
59 s->Phone.Data.Memory=entry;
60 smprintf(s, "Getting phonebook entry\n");
61 return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory);
64 static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
66 GSM_Phone_Data *Data = &s->Phone.Data;
68 smprintf(s, "Memory status received\n");
69 /* Quess ;-)) */
70 if (msg.Buffer[10]==0x10) {
71 Data->MemoryStatus->Free = msg.Buffer[14]*256 + msg.Buffer[15];
72 } else {
73 Data->MemoryStatus->Free = msg.Buffer[18];
75 smprintf(s, " Size : %i\n",Data->MemoryStatus->Free);
76 Data->MemoryStatus->Used = msg.Buffer[16]*256 + msg.Buffer[17];
77 smprintf(s, " Used : %i\n",Data->MemoryStatus->Used);
78 Data->MemoryStatus->Free -= Data->MemoryStatus->Used;
79 smprintf(s, " Free : %i\n",Data->MemoryStatus->Free);
80 return GE_NONE;
83 static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
85 unsigned char req[] = {
86 N6110_FRAME_HEADER, 0x03, 0x02,
87 0x05 }; /* MemoryType */
89 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
90 if (req[5]==0xff) return GE_NOTSUPPORTED;
92 s->Phone.Data.MemoryStatus=Status;
93 smprintf(s, "Getting memory status\n");
94 return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus);
97 static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
99 int ifolderid;
101 /* simulate flat SMS memory */
102 if (sms->Folder==0x00) {
103 ifolderid = sms->Location / PHONE_MAXSMSINFOLDER;
104 *folderid = (ifolderid + 1) * 0x08;
105 *location = sms->Location - ifolderid * PHONE_MAXSMSINFOLDER;
106 } else {
107 *folderid = sms->Folder * 0x08;
108 *location = sms->Location;
110 smprintf(s, "SMS folder %i & location %i -> 7110 folder %i & location %i\n",
111 sms->Folder,sms->Location,*folderid,*location);
114 static void N7110_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
116 sms->Folder = 0;
117 sms->Location = (folderid / 0x08 - 1) * PHONE_MAXSMSINFOLDER + location;
118 smprintf(s, "7110 folder %i & location %i -> SMS folder %i & location %i\n",
119 folderid,location,sms->Folder,sms->Location);
122 static GSM_Error N7110_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s)
124 int j,current=5;
125 unsigned char buffer[200];
126 GSM_Phone_Data *Data = &s->Phone.Data;
128 switch (msg.Buffer[3]) {
129 case 0x7B:
130 smprintf(s, "SMS folders names received\n");
131 Data->SMSFolders->Number=msg.Buffer[4];
132 for (j=0;j<msg.Buffer[4];j++) {
133 smprintf(s, "Folder index: %02x",msg.Buffer[current]);
134 current++;
135 smprintf(s, ", folder name: \"");
136 CopyUnicodeString(buffer,msg.Buffer+current);
137 if ((UnicodeLength(buffer))>GSM_MAX_SMS_FOLDER_NAME_LEN) {
138 smprintf(s, "Too long text\n");
139 return GE_UNKNOWNRESPONSE;
141 CopyUnicodeString(Data->SMSFolders->Folder[j].Name,buffer);
142 smprintf(s, "%s\"\n",DecodeUnicodeString(buffer));
143 current=current+2+UnicodeLength(buffer)*2;
144 Data->SMSFolders->Folder[j].InboxFolder = false;
145 if (j==0) Data->SMSFolders->Folder[j].InboxFolder = true;
146 Data->SMSFolders->Folder[j].Memory = GMT_ME;
147 if (j==0 || j==1) Data->SMSFolders->Folder[j].InboxFolder = GMT_MT;
149 return GE_NONE;
150 case 0x7C:
151 smprintf(s, "Security error ? No PIN ?\n");
152 return GE_SECURITYERROR;
153 case 0xCA:
154 smprintf(s, "Wait a moment. Phone is during power on and busy now\n");
155 return GE_SECURITYERROR;
157 return GE_UNKNOWNRESPONSE;
160 static GSM_Error N7110_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
162 unsigned char req[] = {N6110_FRAME_HEADER, 0x7A, 0x00, 0x00};
164 s->Phone.Data.SMSFolders=folders;
165 smprintf(s, "Getting SMS folders\n");
166 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders);
169 static GSM_Error N7110_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
171 int i;
172 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
174 smprintf(s, "SMS folder status received\n");
175 Priv->LastSMSFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
176 smprintf(s, "Number of Entries: %i\n",Priv->LastSMSFolder.Number);
177 smprintf(s, "Locations: ");
178 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
179 Priv->LastSMSFolder.Location[i]=msg.Buffer[6+(i*2)]*256+msg.Buffer[(i*2)+7];
180 if (Priv->LastSMSFolder.Location[i] > PHONE_MAXSMSINFOLDER) {
181 smprintf(s, "Increase PHONE_MAXSMSINFOLDER\n");
182 return GE_UNKNOWNRESPONSE;
184 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]);
186 smprintf(s, "\n");
187 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder);
188 return GE_NONE;
191 static GSM_Error N7110_PrivGetSMSFolderStatus(GSM_StateMachine *s, int folderid)
193 unsigned char req[] = {
194 N7110_FRAME_HEADER, 0x6b,
195 0x08, /* folderID */
196 0x0F, 0x01};
198 req[4] = folderid;
200 smprintf(s, "Getting SMS folder status\n");
201 return GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetSMSFolderStatus);
204 static GSM_Error N7110_GetSMSFolderStatus(GSM_StateMachine *s, int folderid)
206 GSM_Error error;
207 int i;
208 GSM_NOKIASMSFolder folder;
210 error = N7110_PrivGetSMSFolderStatus(s,folderid);
211 /* 0x08 contais read Inbox, 0xf8 unread Inbox.
212 * we want all msg from Inbox, so read both 0x08 and 0xf8 */
213 if (folderid==0x08 && error==GE_NONE) {
214 folder=s->Phone.Data.Priv.N7110.LastSMSFolder;
215 error = N7110_PrivGetSMSFolderStatus(s,0xf8);
216 if (error==GE_NONE) {
217 for (i=0;i<folder.Number;i++) {
218 s->Phone.Data.Priv.N7110.LastSMSFolder.Location[s->Phone.Data.Priv.N7110.LastSMSFolder.Number++]=folder.Location[i];
222 return error;
225 static GSM_SMSMessageLayout N7110_SMSTemplate = {
226 36 /* SMS Text */, 17 /* Phone number */,
227 255 /* SMSC Number */, 15 /* TPDCS */,
228 255 /* SendingDateTime */, 255 /* SMSCDateTime */,
229 255 /* TPStatus */, 16 /* TPUDL */,
230 255 /* TPVP */, 12 /* firstbyte */,
231 255 /* TPMR */, 255 /* TPPID?? */};
233 static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
235 int i;
236 int Width, Height;
237 unsigned char output[500], output2[500];
238 GSM_Phone_Data *Data = &s->Phone.Data;
240 switch(msg.Buffer[3]) {
241 case 0x08:
242 switch (msg.Buffer[8]) {
243 case 0x00:
244 case 0x01:
245 smprintf(s, "SMS message\n");
246 if (Data->RequestID == ID_GetSMSMessage) {
247 Data->GetSMSMessage->Number=1;
248 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
249 DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+9);
250 return GE_NONE;
252 case 0x02:
253 smprintf(s, "SMS template\n");
254 if (Data->RequestID == ID_GetSMSMessage) {
255 Data->GetSMSMessage->Number=1;
256 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
257 Data->GetSMSMessage->SMS[0].PDU=SMS_Submit;
258 GSM_DecodeSMSFrame(&Data->GetSMSMessage->SMS[0],msg.Buffer+9,N7110_SMSTemplate);
259 return GE_NONE;
261 case 0x07:
262 smprintf(s, "Picture Image\n");
263 switch (Data->RequestID) {
264 case ID_GetBitmap:
265 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
266 Data->Bitmap->Width = Width;
267 Data->Bitmap->Height = Height;
268 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 51, Data->Bitmap);
269 GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender,msg.Buffer+22,true);
270 #ifdef DEBUG
271 GSM_UnpackSemiOctetNumber(output,msg.Buffer+9,true);
272 smprintf(s, "SMSC : %s\n",DecodeUnicodeString(output));
273 #endif
274 Data->Bitmap->Text[0] = 0;
275 Data->Bitmap->Text[1] = 0;
276 if (msg.Length!=304) {
277 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output);
278 DecodeDefault(Data->Bitmap->Text, output, msg.Length - 304, true, NULL);
280 return GE_NONE;
281 case ID_GetSMSMessage:
282 Data->GetSMSMessage->Number = 0;
283 i = 0;
284 output[i++] = 0x30; /* Smart Messaging 3.0 */
285 output[i++] = SM30_OTA;
286 output[i++] = 0x01; /* Length */
287 output[i++] = 0x00; /* Length */
288 output[i++] = 0x00;
289 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
290 output[i++] = Width;
291 output[i++] = Height;
292 output[i++] = 0x01;
293 memcpy(output+i,msg.Buffer+51,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0));
294 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0);
295 if (msg.Length!=304) {
296 output[i++] = SM30_UNICODETEXT;
297 output[i++] = 0;
298 output[i++] = 0; /* Length - later changed */
299 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output2);
300 DecodeDefault(output+i, output2, msg.Length - 304, true, NULL);
301 output[i - 1] = UnicodeLength(output+i) * 2;
302 i = i + output[i-1];
304 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,GSM_Coding_8bit,1,0);
305 for (i=0;i<3;i++) {
306 Data->GetSMSMessage->SMS[i].Number[0]=0;
307 Data->GetSMSMessage->SMS[i].Number[1]=0;
309 return GE_NONE;
310 default:
311 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
312 return GE_UNKNOWNRESPONSE;
314 default:
315 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
317 break;
318 case 0x09:
319 switch (msg.Buffer[4]) {
320 case 0x02:
321 smprintf(s, "Too high location ?\n");
322 return GE_INVALIDLOCATION;
323 case 0x07:
324 smprintf(s, "Empty\n");
325 return GE_EMPTY;
326 default:
327 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
329 case 0x6F:
330 smprintf(s, "SMS message info received\n");
331 if (msg.Length == 43) {
332 Data->GetSMSMessage->SMS[0].Name[0] = 0;
333 Data->GetSMSMessage->SMS[0].Name[1] = 0;
334 } else {
335 CopyUnicodeString(Data->GetSMSMessage->SMS[0].Name,msg.Buffer+43);
337 smprintf(s, "Name: \"%s\"\n",DecodeUnicodeString(Data->GetSMSMessage->SMS[0].Name));
338 return GE_NONE;
340 return GE_UNKNOWNRESPONSE;
343 static GSM_Error N7110_PrivGetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
345 GSM_Error error;
346 unsigned char folderid;
347 int location;
348 int i;
349 unsigned char req[] = {
350 N6110_FRAME_HEADER, 0x07,
351 0x08, /* folder ID */
352 0x00, 0x05, /* location */
353 0x01, 0x65, 0x01};
354 unsigned char NameReq[] = {
355 N6110_FRAME_HEADER, 0x6E,
356 0x08, /* folder ID */
357 0x00, 0x05}; /* location */
359 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
361 req[4]=folderid;
362 req[5]=location / 256;
363 req[6]=location;
365 s->Phone.Data.GetSMSMessage=sms;
366 smprintf(s, "Getting sms\n");
367 error=GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSMessage);
368 if (error==GE_NONE) {
369 NameReq[4] = folderid;
370 NameReq[5] = location / 256;
371 NameReq[6] = location;
372 smprintf(s, "Getting sms info\n");
373 error=GSM_WaitFor (s, NameReq, 7, 0x14, 4, ID_GetSMSMessage);
374 if (error != GE_NONE) return error;
375 for (i=0;i<sms->Number;i++) {
376 N7110_SetSMSLocation(s, &sms->SMS[i], folderid, location);
377 sms->SMS[i].Folder = folderid/0x08;
378 sms->SMS[i].InboxFolder = true;
379 if (folderid/0x08 != 0x01) sms->SMS[i].InboxFolder = false;
380 CopyUnicodeString(sms->SMS[i].Name,sms->SMS[0].Name);
381 sms->SMS[i].Memory = GMT_ME;
382 if (folderid/0x08 == 0x01 || folderid/0x08 == 0x02) {
383 sms->SMS[i].Memory = GMT_MT;
384 if (folderid/0x08 == 0x01) { /* Inbox */
385 if (sms->SMS[i].State == GSM_Sent) sms->SMS[i].Memory = GMT_ME;
386 if (sms->SMS[i].State == GSM_UnSent) sms->SMS[i].Memory = GMT_ME;
387 if (sms->SMS[i].State == GSM_Read) sms->SMS[i].Memory = GMT_SM;
388 if (sms->SMS[i].State == GSM_UnRead) sms->SMS[i].Memory = GMT_SM;
390 if (folderid/0x08 == 0x02) { /* Outbox */
391 if (sms->SMS[i].State == GSM_Sent) sms->SMS[i].Memory = GMT_SM;
392 if (sms->SMS[i].State == GSM_UnSent) sms->SMS[i].Memory = GMT_SM;
393 if (sms->SMS[i].State == GSM_Read) sms->SMS[i].Memory = GMT_ME;
394 if (sms->SMS[i].State == GSM_UnRead) sms->SMS[i].Memory = GMT_ME;
399 return error;
402 static GSM_Error N7110_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
404 GSM_Error error;
405 unsigned char folderid;
406 int location;
407 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
408 int i;
409 bool found = false;
411 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
412 error=N7110_GetSMSFolderStatus(s, folderid);
413 if (error!=GE_NONE) return error;
414 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
415 if (Priv->LastSMSFolder.Location[i]==location) {
416 found = true;
417 break;
420 if (!found) return GE_EMPTY;
421 return N7110_PrivGetSMSMessage(s,sms);
424 static GSM_Error N7110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
426 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
427 unsigned char folderid;
428 int location;
429 GSM_Error error;
430 int i;
431 bool findnextfolder = false;
433 if (start) {
434 folderid=0x00;
435 findnextfolder=true;
436 error=N7110_GetSMSFolders(s,&Priv->LastSMSFolders);
437 if (error!=GE_NONE) return error;
438 } else {
439 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
440 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
441 if (Priv->LastSMSFolder.Location[i]==location) break;
443 /* Is this last location in this folder ? */
444 if (i==Priv->LastSMSFolder.Number-1) {
445 findnextfolder=true;
446 } else {
447 location=Priv->LastSMSFolder.Location[i+1];
450 if (findnextfolder) {
451 Priv->LastSMSFolder.Number=0;
452 while (Priv->LastSMSFolder.Number==0) {
453 folderid=folderid+0x08;
454 /* Too high folder number */
455 if ((folderid/0x08)>Priv->LastSMSFolders.Number) return GE_EMPTY;
456 /* Get next folder status */
457 error=N7110_GetSMSFolderStatus(s, folderid);
458 if (error!=GE_NONE) return error;
459 /* First location from this folder */
460 location=Priv->LastSMSFolder.Location[0];
463 N7110_SetSMSLocation(s, &sms->SMS[0], folderid, location);
465 return N7110_PrivGetSMSMessage(s, sms);
468 static int N7110_ReturnBinaryRingtoneLocation(char *model)
470 if (strcmp(model,"NSE-5") == 0) return 0x72; /* first 0x72 - 7110 */
471 if (strcmp(model,"NPE-3") == 0) return 0x89; /* first 0x89 - 6210 */
472 if (strcmp(model,"NHM-3") == 0) return 0x89; /* quess for 6250 */
473 return 0;
476 static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
478 int tmp,i;
479 GSM_Phone_Data *Data = &s->Phone.Data;
481 smprintf(s, "Ringtone received\n");
482 switch (msg.Buffer[3]) {
483 case 0x23:
484 tmp=0;i=4;
485 while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) {
486 tmp++;
487 i=i+2;
488 if (i>msg.Length) return GE_EMPTY;
490 memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2);
491 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
492 /* Looking for end */
493 i=37;
494 while (true) {
495 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
496 i=i+2; break;
498 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
499 i=i+2; break;
501 i++;
502 if (i==msg.Length) return GE_EMPTY;
504 /* Copying frame */
505 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37);
506 Data->Ringtone->NokiaBinary.Length=i-37;
507 return GE_NONE;
508 case 0x24:
509 smprintf(s, "Invalid location. Too high ?\n");
510 return GE_INVALIDLOCATION;
512 return GE_UNKNOWNRESPONSE;
515 static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
517 unsigned char req[6] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00};
519 if (PhoneRingtone) return GE_NOTSUPPORTED;
520 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
522 switch (Ringtone->Format) {
523 case RING_NOTETONE:
524 /* In the future get binary and convert */
525 return GE_NOTSUPPORTED;
526 case RING_NOKIABINARY:
527 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
528 s->Phone.Data.Ringtone=Ringtone;
529 smprintf(s, "Getting binary ringtone\n");
530 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
531 case RING_MIDI:
532 return GE_NOTSUPPORTED;
534 return GE_NOTSUPPORTED;
537 static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
539 int i;
540 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
542 smprintf(s, "Received info for Picture Images\n");
543 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
544 smprintf(s, "Locations :");
545 Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
546 for (i=0;i<Priv->LastPictureImageFolder.Number;i++) {
547 Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2];
548 smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]);
550 smprintf(s, "\n");
551 return GE_NONE;
554 static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location)
556 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
557 GSM_SMSFolders folders;
558 GSM_Error error;
559 int i, j = 0, count = 0;
560 unsigned char req[7] = {
561 N6110_FRAME_HEADER, 0x96,
562 0x00, /* Folder ID */
563 0x0f, 0x07};
565 error=N7110_GetSMSFolders (s, &folders);
566 if (error!=GE_NONE) return error;
568 for (i=0;i<folders.Number;i++) {
569 req[4] = (i+1) * 0x08; /* SMS folder ID */
570 error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap);
571 if (error!=GE_NONE) return error;
572 for (j=0;j<Priv->LastPictureImageFolder.Number;j++) {
573 count++;
574 if (count==Bitmap->Location) break;
576 if (count==Bitmap->Location) break;
578 if (count!=Bitmap->Location) return GE_INVALIDLOCATION;
579 *folder = (i+1) * 0x08; /* SMS Folder ID */
580 *location = Priv->LastPictureImageFolder.Location[j];
581 return GE_NONE;
584 static GSM_Error N7110_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
586 unsigned char folder;
587 int location;
588 GSM_Error error;
589 unsigned char req[9] = {
590 N6110_FRAME_HEADER, 0x07,
591 0x00, /* Folder ID */
592 0x00, 0x00, /* Location */
593 0x00, 0x64};
595 error = N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
596 switch (error) {
597 case GE_NONE:
598 req[4] = folder;
599 req[5] = location / 256;
600 req[6] = location % 256;
601 return GSM_WaitFor (s, req, 9, 0x14, 4, ID_GetBitmap);
602 default:
603 return error;
607 static GSM_Error N7110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
609 GSM_MemoryEntry pbk;
610 GSM_Error error;
611 unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
613 s->Phone.Data.Bitmap=Bitmap;
614 switch (Bitmap->Type) {
615 case GSM_StartupLogo:
616 smprintf(s, "Getting startup logo\n");
617 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
618 case GSM_WelcomeNoteText:
619 smprintf(s, "Getting welcome note\n");
620 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
621 case GSM_DealerNoteText:
622 smprintf(s, "Getting dealer note\n");
623 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x17);
624 case GSM_CallerLogo:
625 pbk.MemoryType = GMT7110_CG;
626 pbk.Location = Bitmap->Location;
627 smprintf(s, "Getting caller group logo\n");
628 error=N7110_GetMemory(s,&pbk);
629 if (error==GE_NONE) NOKIA_GetDefaultCallerGroupName(s,Bitmap);
630 return error;
631 case GSM_OperatorLogo:
632 smprintf(s, "Getting operator logo\n");
633 /* This is like DCT3_GetNetworkInfo */
634 return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
635 case GSM_PictureImage:
636 /* 7110 doesn't support it */
637 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return GE_NOTSUPPORTED;
638 return N7110_GetPictureImage(s, Bitmap);
639 default:
640 break;
642 return GE_NOTSUPPORTED;
645 static GSM_Error N7110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
647 GSM_Ringtone dest;
648 GSM_Error error;
649 GSM_NetworkInfo NetInfo;
650 int size=200;
651 unsigned char req[1000] = {
652 0x7C, 0x01, 0x00, 0x0D, 0x00,
653 0x00, 0x00, 0x00, 0x00, 0x00,
654 0x00 }; /*Length*/
655 unsigned char req2[4000] = {
656 N7110_FRAME_HEADER, 0x1F, 0x00,
657 0x87, /* Location */
658 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
659 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
660 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
661 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
662 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
664 switch (Ringtone->Format) {
665 case RING_NOTETONE:
666 if (Ringtone->Location==255)
668 /* 7110 doesn't support it */
669 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return GE_NOTSUPPORTED;
670 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+11, &size);
671 req[10] = size;
672 error = s->Protocol.Functions->WriteMessage(s, req, size+11, 0x00);
673 if (error!=GE_NONE) return error;
674 my_sleep(1000);
675 /* We have to make something (not important, what) now */
676 /* no answer from phone*/
677 return DCT3_GetNetworkInfo(s,&NetInfo);
679 GSM_RingtoneConvert(&dest, Ringtone, RING_NOKIABINARY);
680 break;
681 case RING_NOKIABINARY:
682 memcpy(&dest,Ringtone,sizeof(GSM_Ringtone));
683 break;
684 default:
685 return GE_NOTSUPPORTED;
687 req2[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
688 CopyUnicodeString(req2+6,Ringtone->Name);
689 memcpy(req2+37,dest.NokiaBinary.Frame,dest.NokiaBinary.Length);
690 error = s->Protocol.Functions->WriteMessage(s, req2, 37+dest.NokiaBinary.Length, 0x1F);
691 if (error!=GE_NONE) return error;
692 my_sleep(1000);
693 /* We have to make something (not important, what) now */
694 /* no answer from phone*/
695 return DCT3_GetNetworkInfo(s,&NetInfo);
698 static GSM_Error N7110_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
700 GSM_Phone_Data *Data = &s->Phone.Data;
702 switch (msg.Buffer[3]) {
703 case 0x05:
704 smprintf(s, "SMS message saving status\n");
705 smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
706 if (msg.Buffer[4] == 0xf8) {
707 N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
708 Data->SaveSMSMessage->Folder = 0x01;
709 } else {
710 N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
711 Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
713 return GE_NONE;
714 case 0x06:
715 smprintf(s, "SMS message saving status\n");
716 switch (msg.Buffer[4]) {
717 case 0x03:
718 smprintf(s, "Too high location ?\n");
719 return GE_INVALIDLOCATION;
720 default:
721 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
723 break;
724 case 0x84:
725 smprintf(s, "Name for SMS changed OK to \"%s\"\n",DecodeUnicodeString(msg.Buffer+7));
726 smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
727 if (msg.Buffer[4] == 0xf8) {
728 N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
729 Data->SaveSMSMessage->Folder = 0x01;
730 } else {
731 N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
732 Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
734 return GE_NONE;
736 return GE_UNKNOWNRESPONSE;
739 static GSM_Error N7110_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
741 int length, location;
742 unsigned char folderid, folder;
743 GSM_Error error;
744 unsigned char req[256] = {
745 N6110_FRAME_HEADER, 0x04,
746 0x03, /* sms state */
747 0x10, /* folder */
748 0x00,0x00, /* location */
749 0x00};
750 unsigned char NameReq[200] = {N6110_FRAME_HEADER, 0x83};
752 switch (sms->State) {
753 case GSM_Read : req[4] = 0x01; break;
754 case GSM_UnRead : req[4] = 0x03; break;
755 case GSM_Sent : req[4] = 0x05; break;
756 case GSM_UnSent : req[4] = 0x07; break;
759 N7110_GetSMSLocation(s, sms, &folderid, &location);
760 req[5] = folderid;
761 req[6] = location / 256;
762 req[7] = location;
764 /* Outbox */
765 if (folderid == 0x10 && (sms->State == GSM_Sent || sms->State == GSM_UnSent)) {
766 /* We will use SIM Outbox */
767 sms->PDU = SMS_Submit;
769 /* Inbox */
770 if (folderid == 0x08 && sms->State == GSM_UnRead) {
771 /* We will use SIM Inbox */
772 req[5] = 0xf8;
775 switch (sms->PDU) {
776 case SMS_Deliver:
777 error = PHONE_EncodeSMSFrame(s,sms,req+9,PHONE_SMSDeliver,&length,true);
778 break;
779 case SMS_Submit:
780 smprintf(s, "Saving SMS template\n");
781 error = PHONE_EncodeSMSFrame(s,sms,req+9,N7110_SMSTemplate,&length,true);
782 req[8] = 0x02; /* SMS Template info */
783 break;
784 default:
785 return GE_UNKNOWN;
787 if (error != GE_NONE) return error;
789 s->Phone.Data.SaveSMSMessage=sms;
790 smprintf(s, "Saving sms\n");
791 error=GSM_WaitFor (s, req, 9+length, 0x14, 4, ID_SaveSMSMessage);
792 if (error == GE_NONE && UnicodeLength(sms->Name)!=0) {
793 folder = sms->Folder;
794 sms->Folder = 0;
795 N7110_GetSMSLocation(s, sms, &folderid, &location);
796 length = 4;
797 NameReq[length++] = folderid;
798 NameReq[length++] = location / 256;
799 NameReq[length++] = location;
800 CopyUnicodeString(NameReq+length, sms->Name);
801 length = length+UnicodeLength(sms->Name)*2;
802 NameReq[length++] = 0;
803 NameReq[length++] = 0;
804 error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage);
805 sms->Folder = folder;
807 return error;
810 static GSM_Error N7110_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
812 int location;
813 unsigned char folderid;
815 N7110_GetSMSLocation(s, sms, &folderid, &location);
816 if (location == 0) return GE_INVALIDLOCATION;
817 return N7110_PrivSetSMSMessage(s, sms);
820 static GSM_Error N7110_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
822 int location;
823 unsigned char folderid;
825 N7110_GetSMSLocation(s, sms, &folderid, &location);
826 location = 0;
827 N7110_SetSMSLocation(s, sms, folderid, location);
828 return N7110_PrivSetSMSMessage(s, sms);
831 static GSM_Error N7110_ReplyClearOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
833 smprintf(s, "Clearing operator logo.....\n");
834 return GE_NONE;
837 static GSM_Error N7110_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
839 smprintf(s, "Setting operator logo.....\n");
840 return GE_NONE;
843 static GSM_Error N7110_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap)
845 unsigned char req[500] = {
846 N6110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x0c,
847 0x00, 0x10, /* memory type */
848 0x00, 0x00, /* location */
849 0x00, 0x00, 0x00};
850 char string[500];
851 int block=0, i;
852 unsigned int count = 18;
853 int Width, Height;
855 req[13] = bitmap->Location;
857 /* Logo on/off */
858 if (bitmap->DefaultBitmap) {
859 /* We disable it */
860 string[0] = 0;
861 } else {
862 string[0] = bitmap->Enabled?1:0;
864 string[1] = 0;
865 count += N71_65_PackPBKBlock(s, N7110_ENTRYTYPE_LOGOON, 2, block++, string, req + count);
867 /* Ringtone */
868 if (!bitmap->DefaultRingtone) {
869 string[0] = bitmap->Ringtone;
870 string[1] = 0;
871 count += N71_65_PackPBKBlock(s, N7110_ENTRYTYPE_RINGTONE, 2, block++, string, req + count);
874 /* Number of group */
875 string[0] = bitmap->Location;
876 string[1] = 0;
877 count += N71_65_PackPBKBlock(s, N7110_ENTRYTYPE_GROUP, 2, block++, string, req + count);
879 /* Name */
880 if (!bitmap->DefaultName) {
881 i = UnicodeLength(bitmap->Text) * 2;
882 string[0] = i + 2;
883 memcpy(string + 1, bitmap->Text, i);
884 string[i + 1] = 0;
885 count += N71_65_PackPBKBlock(s, N7110_ENTRYTYPE_NAME, i + 2, block++, string, req + count);
888 /* Logo */
889 if (bitmap->DefaultBitmap) {
890 bitmap->Width = 72;
891 bitmap->Height = 14;
892 GSM_ClearBitmap(bitmap);
894 PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height);
895 string[0] = Width;
896 string[1] = Height;
897 string[2] = 0;
898 string[3] = 0;
899 string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0);
900 PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap);
901 count += N71_65_PackPBKBlock(s, N7110_ENTRYTYPE_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count);
903 req[17] = block;
905 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
908 static GSM_Error N7110_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s)
910 smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
911 return GE_NONE;
914 static GSM_Error N7110_SetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
916 unsigned char folder;
917 int location;
918 GSM_Error error;
919 int i;
920 int count;
921 GSM_Phone_Bitmap_Types Type = GSM_NokiaPictureImage;
922 int Width, Height;
923 unsigned char req[500] = {
924 N6110_FRAME_HEADER, 0x50, 0x07,
925 0x00, /* location */
926 0x00, 0x00, /* index */
927 0x07};
929 error=N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
930 switch (error) {
931 case GE_NONE:
932 req[5] = folder;
933 req[6] = location / 256;
934 req[7] = location % 256;
935 break;
936 case GE_INVALIDLOCATION:
937 req[5] = 0x21; /* Save in Templates folder */
938 req[6] = 0;
939 req[7] = 0;
940 break;
941 default:
942 return error;
945 /* Cleaning */
946 for (i=0;i<36;i++) req[i+9]=0;
948 count=8;
949 if (UnicodeLength(Bitmap->Text)==0) {
950 count+=2 ;req[count]=0x0c;
951 count+=2 ;req[count]=0x0d;
952 count+=2 ;req[count]=0x0e;
953 count+=2 ;req[count]=0x0f;
954 count+=2 ;req[count]=0x10;
955 count+=2 ;req[count]=0x11;
956 count+=23;req[count]=0x02;
957 count++ ;
958 } else {
959 count+=2 ;req[count]=0x54;
960 count++ ;req[count]=0xd4;
961 count++ ;req[count]=0x0d;
962 count+=2 ;req[count]=0x0e;
963 count+=2 ;req[count]=0x0f;
964 count+=2 ;req[count]=0x10;
965 count+=2 ;req[count]=0x11;
966 count+=21;req[count]=0x01;
967 count+=3 ;
969 req[count] = 0x01;
970 count+=2;
971 req[count++] = 0x01;
972 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
973 req[count++] = Width;
974 req[count++] = Height;
975 req[count++] = PHONE_GetBitmapSize(Type,0,0) / 256;
976 req[count++] = PHONE_GetBitmapSize(Type,0,0) % 256;
977 PHONE_EncodeBitmap(Type, req + count, Bitmap);
978 count += PHONE_GetBitmapSize(Type,0,0);
979 if (UnicodeLength(Bitmap->Text)!=0)
981 req[count] = UnicodeLength(Bitmap->Text);
982 GSM_PackSevenBitsToEight(0, Bitmap->Text, req+count+1,strlen(Bitmap->Text));
983 count = count + req[count];
984 } else {
985 req[count++]=0x00;
987 req[count++]=0x00;
988 smprintf(s, "Setting Picture Image\n");
989 return GSM_WaitFor (s, req, count, 0x14, 4, ID_SetBitmap);
992 static GSM_Error N7110_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
994 GSM_Error error;
995 GSM_Phone_Bitmap_Types Type;
996 int Width, Height, i;
997 unsigned char reqStartup[1000] = {
998 N7110_FRAME_HEADER, 0xec,
999 0x15, /* Startup Logo setting */
1000 0x00, 0x00, 0x00, 0x04, 0xc0, 0x02, 0x00,
1001 0x00, /* Bitmap height */
1002 0xc0, 0x03, 0x00,
1003 0x00, /* Bitmap width */
1004 0xc0, 0x04, 0x03, 0x00};
1005 unsigned char reqOp[1000] = {
1006 N7110_FRAME_HEADER, 0xa3, 0x01,
1007 0x00, /* logo disabled */
1008 0x00, 0xf0, 0x00, /* network code (000 00) */
1009 0x00 ,0x04,
1010 0x08, /* length of rest */
1011 0x00, 0x00, /* Bitmap width / height */
1012 0x00,
1013 0x00, /* Bitmap size */
1014 0x00, 0x00};
1015 unsigned char reqClrOp[] = {0x00, 0x01, 0x00, 0xaf, 0x00};
1016 unsigned char reqStartupText[500] = {
1017 N7110_FRAME_HEADER, 0xec,
1018 0x02}; /* Startup Text setting */
1020 switch (Bitmap->Type) {
1021 case GSM_StartupLogo:
1022 if (Bitmap->Location!=1) return GE_NOTSUPPORTED;
1023 Type=GSM_Nokia6210StartupLogo;
1024 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) Type=GSM_Nokia7110StartupLogo;
1025 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1026 reqStartup[12] = Height;
1027 reqStartup[16] = Width;
1028 PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
1029 smprintf(s, "Setting startup logo\n");
1030 return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
1031 case GSM_WelcomeNoteText:
1032 CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
1033 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1034 reqStartupText[i++] = 0;
1035 reqStartupText[i++] = 0;
1036 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
1037 case GSM_DealerNoteText:
1038 reqStartupText[4] = 0x17;
1039 CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
1040 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1041 reqStartupText[i++] = 0;
1042 reqStartupText[i++] = 0;
1043 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
1044 case GSM_OperatorLogo:
1045 /* We want to set operator logo, not clear */
1046 if (strcmp(Bitmap->NetworkCode,"000 00")) {
1047 reqOp[5] = 0x01; /* Logo enabled */
1048 NOKIA_EncodeNetworkCode(reqOp+6, Bitmap->NetworkCode);
1049 Type = GSM_Nokia7110OperatorLogo;
1050 reqOp[11] = 8 + PHONE_GetBitmapSize(Type,0,0);
1051 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1052 reqOp[12]=Width;
1053 reqOp[13]=Height;
1054 reqOp[15]=PHONE_GetBitmapSize(Type,0,0);
1055 PHONE_EncodeBitmap(Type, reqOp + 18, Bitmap);
1056 smprintf(s, "Setting operator logo\n");
1057 return GSM_WaitFor (s, reqOp, 18+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
1058 } else {
1059 smprintf(s, "Clearing operator logo\n");
1060 for (i=0;i<5;i++) {
1061 reqClrOp[4]=i;
1062 error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
1063 if (error!=GE_NONE) return error;
1065 return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap);
1067 case GSM_CallerLogo:
1068 return N7110_SetCallerLogo(s,Bitmap);
1069 case GSM_PictureImage:
1070 return N7110_SetPictureImage(s,Bitmap);
1071 default:
1072 break;
1074 return GE_NOTSUPPORTED;
1077 static GSM_Error N7110_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
1079 smprintf(s, "Phonebook entry deleted\n");
1080 return GE_NONE;
1083 static GSM_Error N7110_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1085 unsigned char req[] = {
1086 N7110_FRAME_HEADER, 0x0f, 0x00, 0x01,
1087 0x04, 0x00, 0x00, 0x0c, 0x01, 0xff,
1088 0x00, 0x01, /* location */
1089 0x05, /* memory type */
1090 0x00, 0x00, 0x00};
1092 req[12] = (entry->Location >> 8);
1093 req[13] = entry->Location & 0xff;
1095 req[14] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1096 if (req[14]==0xff) return GE_NOTSUPPORTED;
1098 smprintf(s, "Deleting phonebook entry\n");
1099 return GSM_WaitFor (s, req, 18, 0x03, 4, ID_SetMemory);
1102 static GSM_Error N7110_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1104 int count = 18, blocks;
1105 unsigned char req[500] = {
1106 N7110_FRAME_HEADER, 0x0b, 0x00, 0x01, 0x01, 0x00, 0x00, 0x0c,
1107 0x00, 0x00, /* memory type */
1108 0x00, 0x00, /* location */
1109 0x00, 0x00, 0x00};
1111 if (entry->Location == 0) return GE_NOTSUPPORTED;
1113 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1114 if (req[11]==0xff) return GE_NOTSUPPORTED;
1116 req[12] = (entry->Location >> 8);
1117 req[13] = entry->Location & 0xff;
1119 count = count + N71_65_EncodePhonebookFrame(s, req+18, *entry, &blocks, false, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS));
1120 req[17] = blocks;
1122 smprintf(s, "Writing phonebook entry\n");
1123 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory);
1126 static GSM_Error N7110_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
1128 unsigned char folderid;
1129 int location;
1130 unsigned char req[] = {
1131 N7110_FRAME_HEADER, 0x0a,
1132 0x00, /* folder */
1133 0x00, 0x00, /* location */
1134 0x01};
1136 N7110_GetSMSLocation(s, sms, &folderid, &location);
1137 req[4] = folderid;
1138 req[5] = location / 256;
1139 req[6] = location;
1141 smprintf(s, "Deleting sms\n");
1142 return GSM_WaitFor (s, req, 8, 0x14, 4, ID_DeleteSMSMessage);
1145 static GSM_Error N7110_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
1147 GSM_Phone_Data *Data = &s->Phone.Data;
1149 smprintf(s, "SMS status received\n");
1150 switch (msg.Buffer[3]) {
1151 case 0x37:
1152 smprintf(s, "Used in phone memory : %i\n",msg.Buffer[10]*256+msg.Buffer[11]);
1153 smprintf(s, "Unread in phone memory : %i\n",msg.Buffer[12]*256+msg.Buffer[13]);
1154 smprintf(s, "Used in SIM : %i\n",msg.Buffer[14]*256+msg.Buffer[15]);
1155 smprintf(s, "Unread in SIM : %i\n",msg.Buffer[16]*256+msg.Buffer[17]);
1156 smprintf(s, "SIM size : %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
1157 Data->SMSStatus->SIMUsed = msg.Buffer[14]*256+msg.Buffer[15];
1158 Data->SMSStatus->SIMUnRead = msg.Buffer[16]*256+msg.Buffer[17];
1159 Data->SMSStatus->SIMSize = msg.Buffer[8]*256+msg.Buffer[9];
1160 Data->SMSStatus->PhoneUsed = msg.Buffer[10]*256+msg.Buffer[11];
1161 Data->SMSStatus->PhoneUnRead = msg.Buffer[12]*256+msg.Buffer[13];
1162 Data->SMSStatus->PhoneSize = 150;
1163 return GE_NONE;
1164 case 0x38:
1165 smprintf(s, "Error. No PIN ?\n");
1166 return GE_SECURITYERROR;
1168 return GE_UNKNOWNRESPONSE;
1171 static GSM_Error N7110_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
1173 GSM_Error error;
1174 GSM_Phone_N7110Data *Priv = &s->Phone.Data.Priv.N7110;
1176 error = DCT3_GetSMSStatus(s,status);
1177 if (error != GE_NONE) return error;
1179 #ifndef ENABLE_LGPL
1180 /* Nokia 6210 and family does not show not "fixed" messages from the
1181 * Templates folder, ie. when you save a message to the Templates folder,
1182 * SMSStatus does not change! Workaround: get Templates folder status, which
1183 * does show these messages.
1185 #endif
1186 error = N7110_GetSMSFolderStatus(s, 0x20);
1187 if (error != GE_NONE) return error;
1188 status->TemplatesUsed = Priv->LastSMSFolder.Number;
1190 return GE_NONE;
1193 static GSM_Error N7110_ReplyGetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
1195 GSM_Phone_Data *Data = &s->Phone.Data;
1197 switch (msg.Buffer[3]) {
1198 case 0x02:
1199 smprintf(s, "Profile feature %02x with value %02x\n",msg.Buffer[6],msg.Buffer[10]);
1200 switch (msg.Buffer[6]) {
1201 case 0x03:
1202 smprintf(s, "Ringtone ID\n");
1203 Data->Profile->FeatureID [Data->Profile->FeaturesNumber] = Profile_RingtoneID;
1204 Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg.Buffer[10];
1205 Data->Profile->FeaturesNumber++;
1206 break;
1207 case 0x08: /* Caller groups */
1208 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,true);
1209 break;
1210 case 0x09: /* Autoanswer */
1211 if (Data->Profile->CarKitProfile || Data->Profile->HeadSetProfile) {
1212 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
1214 break;
1215 case 0xff :
1216 CopyUnicodeString(Data->Profile->Name, msg.Buffer+10);
1217 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
1218 Data->Profile->DefaultName = false;
1219 break;
1220 default:
1221 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
1223 return GE_NONE;
1225 return GE_UNKNOWNRESPONSE;
1228 static GSM_Error N7110_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
1230 GSM_Error error;
1231 int i;
1232 unsigned char Features[12] = {
1233 0x00,0x02,0x03,0x04,0x05,0x06,
1234 0x07,0x08,0x09,0xff,
1235 0x0a,0x22,};
1236 unsigned char req[] = {
1237 N6110_FRAME_HEADER, 0x01, 0x01, 0x01, 0x01,
1238 0x00, /* Profile Location */
1239 0xff}; /* Feature number */
1241 if (Profile->Location > 7) return GE_INVALIDLOCATION;
1243 Profile->CarKitProfile = false;
1244 Profile->HeadSetProfile = false;
1245 if (Profile->Location == 6) Profile->CarKitProfile = true;
1246 if (Profile->Location == 7) Profile->HeadSetProfile = true;
1248 Profile->FeaturesNumber = 0;
1250 s->Phone.Data.Profile=Profile;
1251 for (i = 0; i < 10; i++) {
1252 req[7] = Profile->Location;
1253 req[8] = Features[i];
1254 smprintf(s, "Getting profile feature\n");
1255 error = GSM_WaitFor (s, req, 9, 0x39, 4, ID_GetProfile);
1256 if (error!=GE_NONE) return error;
1258 NOKIA_GetDefaultProfileName(s, Profile);
1259 Profile->Active = false;
1260 return error;
1263 static GSM_Error N7110_ReplySetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
1265 smprintf(s, "Profile feature set\n");
1266 return GE_NONE;
1269 static GSM_Error N7110_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
1271 int i;
1272 bool found;
1273 unsigned char ID,Value;
1274 GSM_Error error;
1275 unsigned char req[] = {
1276 N6110_FRAME_HEADER, 0x03, 0x01, 0x01, 0x03,
1277 0x02, /* feature number */
1278 0x01, /* Profile Location */
1279 0x01,
1280 0xff}; /* Value */
1282 for (i=0;i<Profile->FeaturesNumber;i++) {
1283 found = false;
1284 switch (Profile->FeatureID[i]) {
1285 case Profile_RingtoneID:
1286 ID = 0x03;
1287 Value = Profile->FeatureValue[i];
1288 found = true;
1289 break;
1290 default:
1291 found=NOKIA_FindPhoneFeatureValue(
1293 Profile71_65,
1294 Profile->FeatureID[i],Profile->FeatureValue[i],
1295 &ID,&Value);
1297 if (found) {
1298 req[7] = ID;
1299 req[8] = Profile->Location;
1300 req[10] = Value;
1301 smprintf(s, "Setting profile feature\n");
1302 error = GSM_WaitFor (s, req, 11, 0x39, 4, ID_SetProfile);
1303 if (error!=GE_NONE) return error;
1306 return GE_NONE;
1309 static GSM_Error N7110_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
1311 GSM_MemoryEntry pbk;
1312 GSM_Error error;
1314 pbk.MemoryType = GMT7110_SP;
1315 pbk.Location = SpeedDial->Location;
1316 SpeedDial->MemoryLocation = 0;
1317 s->Phone.Data.SpeedDial = SpeedDial;
1319 smprintf(s, "Getting speed dial\n");
1320 error=N7110_GetMemory(s,&pbk);
1321 switch (error) {
1322 case GE_NOTSUPPORTED:
1323 smprintf(s, "No speed dials set in phone\n");
1324 return GE_EMPTY;
1325 case GE_NONE:
1326 if (SpeedDial->MemoryLocation == 0) {
1327 smprintf(s, "Speed dial not assigned or error in firmware\n");
1328 return GE_EMPTY;
1330 return GE_NONE;
1331 default:
1332 return error;
1336 static GSM_Error N7110_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1338 GSM_SMSMessage sms;
1339 GSM_Phone_Data *Data = &s->Phone.Data;
1341 #ifdef DEBUG
1342 smprintf(s, "SMS message received\n");
1343 sms.State = GSM_UnRead;
1344 sms.InboxFolder = true;
1345 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
1346 #endif
1347 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
1348 sms.State = GSM_UnRead;
1349 sms.InboxFolder = true;
1350 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
1352 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
1354 return GE_NONE;
1357 static GSM_Error N7110_Initialise (GSM_StateMachine *s)
1359 #ifdef DEBUG
1360 DCT3_SetIncomingCB(s,true);
1361 #endif
1362 #ifdef GSM_ENABLE_N71_92INCOMINGINFO
1363 /* Enables various things like incoming SMS, call info, etc. */
1364 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17", 6);
1365 #endif
1366 return GE_NONE;
1369 static GSM_Error N7110_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1371 /* Old method 1 for accessing calendar */
1372 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N7110.LastCalendar);
1375 #ifdef DEBUG
1376 static GSM_Error N7110_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
1378 /* Old method 1 for accessing calendar */
1379 return N71_65_ReplyGetCalendarNotePos1(msg, s, &s->Phone.Data.Priv.N7110.FirstCalendarPos);
1381 #endif
1383 static GSM_Error N7110_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
1385 return N71_65_GetNextCalendar1(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendar,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
1386 // return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
1389 static GSM_Error N7110_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
1391 GSM_Error error;
1393 /* Method 1 */
1394 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N7110.LastCalendar);
1395 if (error!=GE_NONE) return error;
1396 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
1397 return GE_NONE;
1399 /* Method 2 */
1400 // return GE_NOTSUPPORTED;
1403 static GSM_Error N7110_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
1405 // return N71_65_AddCalendar1(s, Note, NULL);
1406 return N71_65_AddCalendar2(s,Note);
1409 static GSM_Error N7110_ReplyGetNetworkInfoError(GSM_Protocol_Message msg, GSM_StateMachine *s)
1411 smprintf(s, "Probably means no PIN\n");
1412 return GE_SECURITYERROR;
1415 static GSM_Error N7110_SetIncomingCall(GSM_StateMachine *s, bool enable)
1417 #ifndef GSM_ENABLE_N71_92INCOMINGINFO
1418 return GE_SOURCENOTAVAILABLE;
1419 #endif
1420 return NOKIA_SetIncomingCall(s,enable);
1423 static GSM_Error N7110_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
1425 #ifndef GSM_ENABLE_N71_92INCOMINGINFO
1426 return GE_SOURCENOTAVAILABLE;
1427 #endif
1428 return NOKIA_SetIncomingUSSD(s,enable);
1431 static GSM_Error N7110_SetIncomingSMS(GSM_StateMachine *s, bool enable)
1433 #ifndef GSM_ENABLE_N71_92INCOMINGINFO
1434 return GE_SOURCENOTAVAILABLE;
1435 #endif
1436 return NOKIA_SetIncomingSMS(s,enable);
1439 GSM_Error N7110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
1441 if (!all) return DCT3DCT4_AnswerCall(s,ID);
1442 return DCT3_AnswerAllCalls(s);
1445 GSM_Error N7110_SetCallDivert(GSM_StateMachine *s, GSM_MultiCallDivert *divert)
1447 GSM_Error error;
1448 int i;
1450 /* No answer from phone side */
1451 i = s->ReplyNum;
1452 s->ReplyNum = 1;
1453 error = DCT3DCT4_SetCallDivert(s,divert);
1454 s->ReplyNum = i;
1455 return error;
1458 GSM_Error N7110_CancelAllDiverts(GSM_StateMachine *s)
1460 GSM_Error error;
1461 int i;
1463 /* No answer from phone side */
1464 i = s->ReplyNum;
1465 s->ReplyNum = 1;
1466 error = DCT3DCT4_CancelAllDiverts(s);
1467 s->ReplyNum = i;
1468 return error;
1471 static GSM_Reply_Function N7110ReplyFunctions[] = {
1472 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
1473 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
1474 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
1475 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
1476 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
1477 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
1478 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
1479 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
1480 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
1481 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
1482 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
1483 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
1484 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
1485 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
1486 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
1488 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
1489 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
1490 {N7110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
1491 #ifdef GSM_ENABLE_CELLBROADCAST
1492 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
1493 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
1494 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
1495 #endif
1496 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
1497 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
1498 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
1499 #ifdef GSM_ENABLE_CELLBROADCAST
1500 {DCT3_ReplySetIncomingCB, "\x02",0x03,0xCA,ID_SetIncomingCB },
1501 #endif
1503 {N7110_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
1504 {N7110_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
1505 {N7110_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
1506 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
1507 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
1509 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
1510 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
1512 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
1513 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
1515 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
1516 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetBitmap },
1517 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
1518 {N7110_ReplyGetNetworkInfoError, "\x0A",0x03,0x72,ID_GetNetworkInfo },
1519 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x73,ID_IncomingFrame },
1520 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality },
1521 {N7110_ReplySetOperatorLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
1522 {N7110_ReplyClearOperatorLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
1523 {NoneReply, "\x0A",0x03,0xB5,ID_IncomingFrame },
1525 #ifdef DEBUG
1526 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },/*method 1*/
1527 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },/*method 1*/
1528 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },/*method 1*/
1529 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },/*method 1*/
1530 #endif
1531 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
1532 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
1533 #ifdef DEBUG
1534 {N7110_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
1535 #endif
1536 {N7110_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
1537 #ifdef DEBUG
1538 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },/*method 2*/
1539 #endif
1540 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
1542 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
1543 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
1544 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
1545 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetBitmap },
1546 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
1547 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
1548 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
1549 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
1550 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
1551 {N7110_ReplySetPicture, "\x14",0x03,0x51,ID_SetBitmap },
1552 {N7110_ReplyGetSMSFolderStatus, "\x14",0x03,0x6C,ID_GetSMSFolderStatus },
1553 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x6F,ID_GetSMSMessage },
1554 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7B,ID_GetSMSFolders },
1555 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7C,ID_GetSMSFolders },
1556 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x84,ID_SaveSMSMessage },
1557 {N7110_ReplyGetPictureImageInfo, "\x14",0x03,0x97,ID_GetBitmap },
1558 {N7110_ReplyGetSMSFolders, "\x14",0x03,0xCA,ID_GetSMSFolders },
1560 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge },
1562 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
1563 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
1564 {DCT3_ReplySetAlarm, "\x19",0x03,0x6C,ID_SetAlarm },
1565 {DCT3_ReplyGetAlarm, "\x19",0x03,0x6E,ID_GetAlarm },
1567 {N7110_ReplyGetRingtone, "\x1f",0x03,0x23,ID_GetRingtone },
1568 {N7110_ReplyGetRingtone, "\x1f",0x03,0x24,ID_GetRingtone },
1570 {DCT3DCT4_ReplyEnableWAP, "\x3f",0x03,0x01,ID_EnableWAP },
1571 {DCT3DCT4_ReplyEnableWAP, "\x3f",0x03,0x02,ID_EnableWAP },
1572 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
1573 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
1574 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
1575 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
1576 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
1577 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
1578 {DCT3DCT4_ReplyGetActiveWAPMMSSet,"\x3f",0x03,0x10,ID_GetWAPSettings },
1579 {DCT3DCT4_ReplySetActiveWAPMMSSet,"\x3f",0x03,0x13,ID_SetWAPSettings },
1580 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetWAPSettings },
1581 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetWAPSettings },
1582 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetWAPSettings },
1583 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetWAPSettings },
1584 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetWAPSettings },
1585 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetWAPSettings },
1586 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetWAPSettings },
1588 {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile },
1589 {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile },
1591 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
1592 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
1593 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
1594 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
1595 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
1596 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
1597 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
1598 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
1599 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
1600 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
1601 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
1602 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth },
1603 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
1604 {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame },
1606 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
1607 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
1608 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
1609 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
1610 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap },
1611 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap },
1613 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
1614 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
1615 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
1616 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
1618 {NULL, "\x00",0x00,0x00,ID_None }
1621 GSM_Phone_Functions N7110Phone = {
1622 "6210|6250|7110|7190",
1623 N7110ReplyFunctions,
1624 N7110_Initialise,
1625 PHONE_Terminate,
1626 GSM_DispatchMessage,
1627 NOTSUPPORTED, /* ShowStartInfo */
1628 NOKIA_GetManufacturer,
1629 DCT3DCT4_GetModel,
1630 DCT3DCT4_GetFirmware,
1631 DCT3_GetIMEI,
1632 DCT3_GetOriginalIMEI,
1633 DCT3_GetManufactureMonth,
1634 DCT3_GetProductCode,
1635 DCT3_GetHardware,
1636 DCT3_GetPPM,
1637 NOTSUPPORTED, /* GetSIMIMSI */
1638 N71_92_GetDateTime,
1639 N71_92_SetDateTime,
1640 N7110_GetAlarm,
1641 N7110_SetAlarm,
1642 NOTSUPPORTED, /* GetLocale */
1643 NOTSUPPORTED, /* SetLocale */
1644 DCT3_PressKey,
1645 DCT3_Reset,
1646 N61_71_ResetPhoneSettings,
1647 NOTSUPPORTED, /* EnterSecurityCode */
1648 NOTSUPPORTED, /* GetSecurityStatus */
1649 NOTSUPPORTED, /* GetDisplayStatus */
1650 NOTIMPLEMENTED, /* SetAutoNetworkLogin */
1651 N71_92_GetBatteryCharge,
1652 N71_92_GetSignalQuality,
1653 DCT3_GetNetworkInfo,
1654 NOTSUPPORTED, /* GetCategory */
1655 NOTSUPPORTED, /* GetCategoryStatus */
1656 N7110_GetMemoryStatus,
1657 N7110_GetMemory,
1658 NOTIMPLEMENTED, /* GetNextMemory */
1659 N7110_SetMemory,
1660 NOTIMPLEMENTED, /* AddMemory */
1661 N7110_DeleteMemory,
1662 NOTIMPLEMENTED, /* DeleteAllMemory */
1663 N7110_GetSpeedDial,
1664 NOTIMPLEMENTED, /* SetSpeedDial */
1665 DCT3_GetSMSC,
1666 DCT3_SetSMSC,
1667 N7110_GetSMSStatus,
1668 N7110_GetSMSMessage,
1669 N7110_GetNextSMSMessage,
1670 N7110_SetSMS,
1671 N7110_AddSMS,
1672 N7110_DeleteSMS,
1673 DCT3_SendSMSMessage,
1674 N7110_SetIncomingSMS,
1675 DCT3_SetIncomingCB,
1676 N7110_GetSMSFolders,
1677 NOTIMPLEMENTED, /* AddSMSFolder */
1678 NOTIMPLEMENTED, /* DeleteSMSFolder */
1679 DCT3_DialVoice,
1680 N7110_AnswerCall,
1681 DCT3_CancelCall,
1682 NOTIMPLEMENTED, /* HoldCall */
1683 NOTIMPLEMENTED, /* UnholdCall */
1684 NOTIMPLEMENTED, /* ConferenceCall */
1685 NOTIMPLEMENTED, /* SplitCall */
1686 NOTIMPLEMENTED, /* TransferCall */
1687 NOTIMPLEMENTED, /* SwitchCall */
1688 NOTSUPPORTED, /* GetCallDivert */
1689 N7110_SetCallDivert,
1690 N7110_CancelAllDiverts,
1691 N7110_SetIncomingCall,
1692 N7110_SetIncomingUSSD,
1693 DCT3DCT4_SendDTMF,
1694 N7110_GetRingtone,
1695 N7110_SetRingtone,
1696 NOTSUPPORTED, /* GetRingtonesInfo */
1697 NOTSUPPORTED, /* DeleteUserRingtones */
1698 DCT3_PlayTone,
1699 DCT3DCT4_GetWAPBookmark,
1700 DCT3_SetWAPBookmark,
1701 DCT3DCT4_DeleteWAPBookmark,
1702 DCT3_GetWAPSettings,
1703 DCT3_SetWAPSettings,
1704 NOTSUPPORTED, /* GetMMSSettings */
1705 NOTSUPPORTED, /* SetMMSSettings */
1706 N7110_GetBitmap,
1707 N7110_SetBitmap,
1708 NOTSUPPORTED, /* GetToDoStatus */
1709 NOTSUPPORTED, /* GetToDo */
1710 NOTSUPPORTED, /* GetNextToDo */
1711 NOTSUPPORTED, /* SetToDo */
1712 NOTSUPPORTED, /* AddToDo */
1713 NOTSUPPORTED, /* DeleteToDo */
1714 NOTSUPPORTED, /* DeleteAllToDo */
1715 N7110_GetCalendarStatus,
1716 NOTIMPLEMENTED, /* GetCalendar */
1717 N7110_GetNextCalendar,
1718 NOTIMPLEMENTED, /* SetCalendar */
1719 N7110_AddCalendar,
1720 N71_65_DelCalendar,
1721 NOTIMPLEMENTED, /* DeleteAllCalendar */
1722 NOTSUPPORTED, /* GetCalendarSettings */
1723 NOTSUPPORTED, /* SetCalendarSettings */
1724 NOTSUPPORTED, /* GetNote */
1725 N7110_GetProfile,
1726 N7110_SetProfile,
1727 NOTSUPPORTED, /* GetFMStation */
1728 NOTSUPPORTED, /* SetFMStation */
1729 NOTSUPPORTED, /* ClearFMStations */
1730 NOTSUPPORTED, /* GetNextFileFolder */
1731 NOTSUPPORTED, /* GetFilePart */
1732 NOTSUPPORTED, /* AddFile */
1733 NOTSUPPORTED, /* GetFileSystemStatus */
1734 NOTSUPPORTED, /* DeleteFile */
1735 NOTSUPPORTED, /* AddFolder */
1736 NOTSUPPORTED, /* GetGPRSAccessPoint */
1737 NOTSUPPORTED /* SetGPRSAccessPoint */
1740 #endif
1742 /* How should editor hadle tabs in this file? Add editor commands here.
1743 * vim: noexpandtab sw=8 ts=8 sts=8: