summaryrefslogtreecommitdiffabout
path: root/gammu/emb/common/phone/nokia/dct3/n7110.c
Unidiff
Diffstat (limited to 'gammu/emb/common/phone/nokia/dct3/n7110.c') (more/less context) (ignore whitespace changes)
-rw-r--r--gammu/emb/common/phone/nokia/dct3/n7110.c1724
1 files changed, 1724 insertions, 0 deletions
diff --git a/gammu/emb/common/phone/nokia/dct3/n7110.c b/gammu/emb/common/phone/nokia/dct3/n7110.c
new file mode 100644
index 0000000..5a02c9c
--- a/dev/null
+++ b/gammu/emb/common/phone/nokia/dct3/n7110.c
@@ -0,0 +1,1724 @@
1/* (c) 2001-2004 by Marcin Wiacek */
2/* based on some work from Markus Plail and Gnokii */
3
4#include "../../../gsmstate.h"
5
6#ifdef GSM_ENABLE_NOKIA7110
7
8#include <string.h>
9#include <time.h>
10
11#include "../../../misc/coding/coding.h"
12#include "../../../gsmcomon.h"
13#include "../../../service/gsmlogo.h"
14#include "../../pfunc.h"
15#include "../nfunc.h"
16#include "../nfuncold.h"
17#include "n7110.h"
18#include "dct3func.h"
19
20static GSM_Error N7110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
21{
22 return DCT3_GetAlarm(s, alarm, 0x19);
23}
24
25static GSM_Error N7110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm)
26{
27 return DCT3_SetAlarm(s, alarm, 0x19);
28}
29
30static GSM_Error N7110_ReplyGetMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
31{
32 GSM_Phone_Data *Data = &s->Phone.Data;
33
34 smprintf(s, "Phonebook entry received\n");
35 switch (msg.Buffer[6]) {
36 case 0x0f:
37 return N71_65_ReplyGetMemoryError(msg.Buffer[10], s);
38 default:
39 return N71_65_DecodePhonebook(s, Data->Memory,Data->Bitmap,Data->SpeedDial,msg.Buffer+18,msg.Length-18,false);
40 }
41 return ERR_UNKNOWN;
42}
43
44static GSM_Error N7110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
45{
46 unsigned char req[] = {N7110_FRAME_HEADER, 0x07, 0x01, 0x01, 0x00, 0x01,
47 0x02, /* memory type */
48 0x05,
49 0x00, 0x00,/* location */
50 0x00, 0x00};
51
52 req[9] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
53 if (req[9]==0xff) return ERR_NOTSUPPORTED;
54
55 if (entry->Location==0x00) return ERR_INVALIDLOCATION;
56
57 req[10] = entry->Location / 256;
58 req[11] = entry->Location % 256;
59
60 s->Phone.Data.Memory=entry;
61 smprintf(s, "Getting phonebook entry\n");
62 return GSM_WaitFor (s, req, 14, 0x03, 4, ID_GetMemory);
63}
64
65static GSM_Error N7110_ReplyGetMemoryStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
66{
67 GSM_Phone_Data *Data = &s->Phone.Data;
68
69 smprintf(s, "Memory status received\n");
70 /* Quess ;-)) */
71 if (msg.Buffer[10]==0x10) {
72 Data->MemoryStatus->MemoryFree = msg.Buffer[14]*256 + msg.Buffer[15];
73 } else {
74 Data->MemoryStatus->MemoryFree = msg.Buffer[18];
75 }
76 smprintf(s, " Size : %i\n",Data->MemoryStatus->MemoryFree);
77 Data->MemoryStatus->MemoryUsed = msg.Buffer[16]*256 + msg.Buffer[17];
78 smprintf(s, " Used : %i\n",Data->MemoryStatus->MemoryUsed);
79 Data->MemoryStatus->MemoryFree -= Data->MemoryStatus->MemoryUsed;
80 smprintf(s, " Free : %i\n",Data->MemoryStatus->MemoryFree);
81 return ERR_NONE;
82}
83
84static GSM_Error N7110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
85{
86 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x02,
87 0x05}; /* Memory type */
88
89 req[5] = NOKIA_GetMemoryType(s, Status->MemoryType,N71_65_MEMORY_TYPES);
90 if (req[5]==0xff) return ERR_NOTSUPPORTED;
91
92 s->Phone.Data.MemoryStatus=Status;
93 smprintf(s, "Getting memory status\n");
94 return GSM_WaitFor (s, req, 6, 0x03, 4, ID_GetMemoryStatus);
95}
96
97static void N7110_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char *folderid, int *location)
98{
99 int ifolderid;
100
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;
109 }
110 smprintf(s, "SMS folder %i & location %i -> 7110 folder %i & location %i\n",
111 sms->Folder,sms->Location,*folderid,*location);
112}
113
114static void N7110_SetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigned char folderid, int location)
115{
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);
120}
121
122static GSM_Error N7110_ReplyGetSMSFolders(GSM_Protocol_Message msg, GSM_StateMachine *s)
123{
124 int j,current=5;
125 unsigned char buffer[200];
126 GSM_Phone_Data*Data = &s->Phone.Data;
127
128 switch (msg.Buffer[3]) {
129 case 0x7B:
130 smprintf(s, "Names for SMS folders 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 ERR_UNKNOWNRESPONSE;
140 }
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 = MEM_ME;
147 if (j==0 || j==1) Data->SMSFolders->Folder[j].InboxFolder = MEM_MT;
148 }
149 return ERR_NONE;
150 case 0x7C:
151 smprintf(s, "Security error ? No PIN ?\n");
152 return ERR_SECURITYERROR;
153 case 0xCA:
154 smprintf(s, "Wait a moment. Phone is during power on and busy now\n");
155 return ERR_SECURITYERROR;
156 }
157 return ERR_UNKNOWNRESPONSE;
158}
159
160static GSM_Error N7110_GetSMSFolders(GSM_StateMachine *s, GSM_SMSFolders *folders)
161{
162 unsigned char req[] = {N6110_FRAME_HEADER, 0x7A, 0x00, 0x00};
163
164 s->Phone.Data.SMSFolders=folders;
165 smprintf(s, "Getting SMS folders\n");
166 return GSM_WaitFor (s, req, 6, 0x14, 4, ID_GetSMSFolders);
167}
168
169static GSM_Error N7110_ReplyGetSMSFolderStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
170{
171 int i;
172 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
173
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 ERR_UNKNOWNRESPONSE;
183 }
184 smprintf(s, "%i ",Priv->LastSMSFolder.Location[i]);
185 }
186 smprintf(s, "\n");
187 NOKIA_SortSMSFolderStatus(s, &Priv->LastSMSFolder);
188 return ERR_NONE;
189}
190
191static GSM_Error N7110_PrivGetSMSFolderStatus(GSM_StateMachine *s, int folderid)
192{
193 unsigned char req[] = {N7110_FRAME_HEADER, 0x6b,
194 0x08, /* folderID */
195 0x0F, 0x01};
196
197 req[4] = folderid;
198
199 smprintf(s, "Getting SMS folder status\n");
200 return GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetSMSFolderStatus);
201}
202
203static GSM_Error N7110_GetSMSFolderStatus(GSM_StateMachine *s, int folderid)
204{
205 GSM_Error error;
206 int i;
207 GSM_NOKIASMSFolderfolder;
208
209 error = N7110_PrivGetSMSFolderStatus(s,folderid);
210 /* 0x08 contais read Inbox, 0xf8 unread Inbox.
211 * we want all msg from Inbox, so read both 0x08 and 0xf8 */
212 if (folderid==0x08 && error==ERR_NONE) {
213 folder=s->Phone.Data.Priv.N7110.LastSMSFolder;
214 error = N7110_PrivGetSMSFolderStatus(s,0xf8);
215 if (error==ERR_NONE) {
216 for (i=0;i<folder.Number;i++) {
217 s->Phone.Data.Priv.N7110.LastSMSFolder.Location[s->Phone.Data.Priv.N7110.LastSMSFolder.Number++]=folder.Location[i];
218 }
219 }
220 }
221 return error;
222}
223
224static GSM_SMSMessageLayout N7110_SMSTemplate = {
225 36 /* SMS Text */, 17 /* Phone number*/,
226 255 /* SMSC Number */, 15 /* TPDCS */,
227 255 /* SendingDateTime */, 255 /* SMSCDateTime*/,
228 255 /* TPStatus */, 16 /* TPUDL */,
229 255 /* TPVP */, 12 /* firstbyte*/,
230 13 /* TPMR */, 255 /* TPPID?? */};
231
232static GSM_Error N7110_ReplyGetSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
233{
234 int i;
235 int Width, Height;
236 unsigned char output[500], output2[500];
237 GSM_Phone_Data *Data = &s->Phone.Data;
238
239 switch(msg.Buffer[3]) {
240 case 0x08:
241 switch (msg.Buffer[8]) {
242 case 0x00:
243 case 0x01:
244 smprintf(s, "SMS message\n");
245 if (Data->RequestID == ID_GetSMSMessage) {
246 Data->GetSMSMessage->Number=1;
247 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
248 DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg.Buffer+9);
249 return ERR_NONE;
250 }
251 case 0x02:
252 smprintf(s, "SMS template\n");
253 if (Data->RequestID == ID_GetSMSMessage) {
254 Data->GetSMSMessage->Number=1;
255 NOKIA_DecodeSMSState(s, msg.Buffer[4], &Data->GetSMSMessage->SMS[0]);
256 Data->GetSMSMessage->SMS[0].PDU=SMS_Submit;
257 GSM_DecodeSMSFrame(&Data->GetSMSMessage->SMS[0],msg.Buffer+9,N7110_SMSTemplate);
258 return ERR_NONE;
259 }
260 case 0x07:
261 smprintf(s, "Picture Image\n");
262 switch (Data->RequestID) {
263 case ID_GetBitmap:
264 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
265 Data->Bitmap->BitmapWidth= Width;
266 Data->Bitmap->BitmapHeight= Height;
267 PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg.Buffer + 51, Data->Bitmap);
268 GSM_UnpackSemiOctetNumber(Data->Bitmap->Sender,msg.Buffer+22,true);
269#ifdef DEBUG
270 GSM_UnpackSemiOctetNumber(output,msg.Buffer+9,true);
271 smprintf(s, "SMSC : %s\n",DecodeUnicodeString(output));
272#endif
273 Data->Bitmap->Text[0] = 0;
274 Data->Bitmap->Text[1] = 0;
275 if (msg.Length!=304) {
276 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output);
277 DecodeDefault(Data->Bitmap->Text, output, msg.Length - 304, true, NULL);
278 }
279 return ERR_NONE;
280 case ID_GetSMSMessage:
281 Data->GetSMSMessage->Number = 0;
282 i = 0;
283 output[i++] = 0x30; /* Smart Messaging 3.0 */
284 output[i++] = SM30_OTA;
285 output[i++] = 0x01; /* Length */
286 output[i++] = 0x00; /* Length */
287 output[i++] = 0x00;
288 PHONE_GetBitmapWidthHeight(GSM_NokiaPictureImage, &Width, &Height);
289 output[i++] = Width;
290 output[i++] = Height;
291 output[i++] = 0x01;
292 memcpy(output+i,msg.Buffer+51,PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0));
293 i = i + PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0);
294 if (msg.Length!=304) {
295 output[i++] = SM30_UNICODETEXT;
296 output[i++] = 0;
297 output[i++] = 0; /* Length - later changed */
298 GSM_UnpackEightBitsToSeven(0, msg.Length-304, msg.Length-304, msg.Buffer+52+PHONE_GetBitmapSize(GSM_NokiaPictureImage,0,0),output2);
299 DecodeDefault(output+i, output2, msg.Length - 304, true, NULL);
300 output[i - 1] = UnicodeLength(output+i) * 2;
301 i = i + output[i-1];
302 }
303 GSM_MakeMultiPartSMS(Data->GetSMSMessage,output,i,UDH_NokiaProfileLong,SMS_Coding_8bit,1,0);
304 for (i=0;i<3;i++) {
305 Data->GetSMSMessage->SMS[i].Number[0]=0;
306 Data->GetSMSMessage->SMS[i].Number[1]=0;
307 }
308 return ERR_NONE;
309 default:
310 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
311 return ERR_UNKNOWNRESPONSE;
312 }
313 default:
314 smprintf(s, "Unknown SMS type: %i\n",msg.Buffer[8]);
315 }
316 break;
317 case 0x09:
318 switch (msg.Buffer[4]) {
319 case 0x02:
320 smprintf(s, "Too high location ?\n");
321 return ERR_INVALIDLOCATION;
322 case 0x07:
323 smprintf(s, "Empty\n");
324 return ERR_EMPTY;
325 default:
326 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
327 }
328 case 0x6F:
329 smprintf(s, "SMS message info received\n");
330 if (msg.Length == 43) {
331 Data->GetSMSMessage->SMS[0].Name[0] = 0;
332 Data->GetSMSMessage->SMS[0].Name[1] = 0;
333 } else {
334 CopyUnicodeString(Data->GetSMSMessage->SMS[0].Name,msg.Buffer+43);
335 }
336 smprintf(s, "Name: \"%s\"\n",DecodeUnicodeString(Data->GetSMSMessage->SMS[0].Name));
337 return ERR_NONE;
338 }
339 return ERR_UNKNOWNRESPONSE;
340}
341
342static GSM_Error N7110_PrivGetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
343{
344 GSM_Error error;
345 unsigned char folderid;
346 int location;
347 int i;
348 unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
349 0x08, /* folder ID */
350 0x00, 0x05, /* location */
351 0x01, 0x65, 0x01};
352 unsigned char NameReq[] = {N6110_FRAME_HEADER, 0x6E,
353 0x08, /* folder ID */
354 0x00, 0x05}; /* location */
355
356 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
357
358 req[4]=folderid;
359 req[5]=location / 256;
360 req[6]=location;
361
362 s->Phone.Data.GetSMSMessage=sms;
363 smprintf(s, "Getting sms\n");
364 error=GSM_WaitFor (s, req, 10, 0x14, 4, ID_GetSMSMessage);
365 if (error==ERR_NONE) {
366 NameReq[4] = folderid;
367 NameReq[5] = location / 256;
368 NameReq[6] = location;
369 smprintf(s, "Getting sms info\n");
370 error=GSM_WaitFor (s, NameReq, 7, 0x14, 4, ID_GetSMSMessage);
371 if (error != ERR_NONE) return error;
372 for (i=0;i<sms->Number;i++) {
373 N7110_SetSMSLocation(s, &sms->SMS[i], folderid, location);
374 sms->SMS[i].Folder = folderid/0x08;
375 sms->SMS[i].InboxFolder = true;
376 if (folderid/0x08 != 0x01) sms->SMS[i].InboxFolder = false;
377 CopyUnicodeString(sms->SMS[i].Name,sms->SMS[0].Name);
378 sms->SMS[i].Memory = MEM_ME;
379 if (folderid/0x08 == 0x01 || folderid/0x08 == 0x02) {
380 sms->SMS[i].Memory = MEM_MT;
381 if (folderid/0x08 == 0x01) { /* Inbox */
382 if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_ME;
383 if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_ME;
384 if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_SM;
385 if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_SM;
386 }
387 if (folderid/0x08 == 0x02) { /* Outbox */
388 if (sms->SMS[i].State == SMS_Sent) sms->SMS[i].Memory = MEM_SM;
389 if (sms->SMS[i].State == SMS_UnSent) sms->SMS[i].Memory = MEM_SM;
390 if (sms->SMS[i].State == SMS_Read) sms->SMS[i].Memory = MEM_ME;
391 if (sms->SMS[i].State == SMS_UnRead) sms->SMS[i].Memory = MEM_ME;
392 }
393 }
394 }
395 }
396 return error;
397}
398
399static GSM_Error N7110_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
400{
401 GSM_Error error;
402 unsigned char folderid;
403 int location;
404 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
405 int i;
406 bool found = false;
407
408 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
409 error=N7110_GetSMSFolderStatus(s, folderid);
410 if (error!=ERR_NONE) return error;
411 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
412 if (Priv->LastSMSFolder.Location[i]==location) {
413 found = true;
414 break;
415 }
416 }
417 if (!found) return ERR_EMPTY;
418 return N7110_PrivGetSMSMessage(s,sms);
419}
420
421static GSM_Error N7110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, bool start)
422{
423 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
424 unsigned char folderid;
425 int location;
426 GSM_Error error;
427 int i;
428 bool findnextfolder = false;
429
430 if (start) {
431 folderid=0x00;
432 findnextfolder=true;
433 error=N7110_GetSMSFolders(s,&Priv->LastSMSFolders);
434 if (error!=ERR_NONE) return error;
435 } else {
436 N7110_GetSMSLocation(s, &sms->SMS[0], &folderid, &location);
437 for (i=0;i<Priv->LastSMSFolder.Number;i++) {
438 if (Priv->LastSMSFolder.Location[i]==location) break;
439 }
440 /* Is this last location in this folder ? */
441 if (i==Priv->LastSMSFolder.Number-1) {
442 findnextfolder=true;
443 } else {
444 location=Priv->LastSMSFolder.Location[i+1];
445 }
446 }
447 if (findnextfolder) {
448 Priv->LastSMSFolder.Number=0;
449 while (Priv->LastSMSFolder.Number==0) {
450 folderid=folderid+0x08;
451 /* Too high folder number */
452 if ((folderid/0x08)>Priv->LastSMSFolders.Number) return ERR_EMPTY;
453 /* Get next folder status */
454 error=N7110_GetSMSFolderStatus(s, folderid);
455 if (error!=ERR_NONE) return error;
456 /* First location from this folder */
457 location=Priv->LastSMSFolder.Location[0];
458 }
459 }
460 N7110_SetSMSLocation(s, &sms->SMS[0], folderid, location);
461
462 return N7110_PrivGetSMSMessage(s, sms);
463}
464
465static int N7110_ReturnBinaryRingtoneLocation(char *model)
466{
467 if (strcmp(model,"NSE-5") == 0) return 0x72; /* first 0x72 - 7110 */
468 if (strcmp(model,"NPE-3") == 0) return 0x89; /* first 0x89 - 6210 */
469 if (strcmp(model,"NHM-3") == 0) return 0x89; /* quess for 6250 */
470 return 0;
471}
472
473static GSM_Error N7110_ReplyGetRingtone(GSM_Protocol_Message msg, GSM_StateMachine *s)
474{
475 int tmp,i;
476 GSM_Phone_Data *Data = &s->Phone.Data;
477
478 smprintf(s, "Ringtone received\n");
479 switch (msg.Buffer[3]) {
480 case 0x23:
481 tmp=0;i=4;
482 while (msg.Buffer[i]!=0 || msg.Buffer[i+1]!=0) {
483 tmp++;
484 i=i+2;
485 if (i>msg.Length) return ERR_EMPTY;
486 }
487 memcpy(Data->Ringtone->Name,msg.Buffer+6,tmp*2);
488 smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
489 /* Looking for end */
490 i=37;
491 while (true) {
492 if (msg.Buffer[i]==0x07 && msg.Buffer[i+1]==0x0b) {
493 i=i+2; break;
494 }
495 if (msg.Buffer[i]==0x0e && msg.Buffer[i+1]==0x0b) {
496 i=i+2; break;
497 }
498 i++;
499 if (i==msg.Length) return ERR_EMPTY;
500 }
501 /* Copying frame */
502 memcpy(Data->Ringtone->NokiaBinary.Frame,msg.Buffer+37,i-37);
503 Data->Ringtone->NokiaBinary.Length=i-37;
504 return ERR_NONE;
505 case 0x24:
506 smprintf(s, "Invalid location. Too high ?\n");
507 return ERR_INVALIDLOCATION;
508 }
509 return ERR_UNKNOWNRESPONSE;
510}
511
512static GSM_Error N7110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, bool PhoneRingtone)
513{
514 unsigned char req[] = {N7110_FRAME_HEADER, 0x22, 0x00, 0x00};
515
516 if (PhoneRingtone) return ERR_NOTSUPPORTED;
517 if (Ringtone->Format == 0x00) Ringtone->Format = RING_NOKIABINARY;
518
519 switch (Ringtone->Format) {
520 case RING_NOTETONE:
521 /* In the future get binary and convert */
522 return ERR_NOTSUPPORTED;
523 case RING_NOKIABINARY:
524 req[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
525 s->Phone.Data.Ringtone=Ringtone;
526 smprintf(s, "Getting binary ringtone\n");
527 return GSM_WaitFor (s, req, 6, 0x1f, 4, ID_GetRingtone);
528 case RING_MIDI:
529 return ERR_NOTSUPPORTED;
530 }
531 return ERR_NOTSUPPORTED;
532}
533
534static GSM_Error N7110_ReplyGetPictureImageInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
535{
536 int i;
537 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
538
539 smprintf(s, "Received info for Picture Images\n");
540 smprintf(s, "Number : %i\n",msg.Buffer[4]*256+msg.Buffer[5]);
541 smprintf(s, "Locations :");
542 Priv->LastPictureImageFolder.Number=msg.Buffer[4]*256+msg.Buffer[5];
543 for (i=0;i<Priv->LastPictureImageFolder.Number;i++) {
544 Priv->LastPictureImageFolder.Location[i]=msg.Buffer[6+i*2]*256+msg.Buffer[7+i*2];
545 smprintf(s, " %i",Priv->LastPictureImageFolder.Location[i]);
546 }
547 smprintf(s, "\n");
548 return ERR_NONE;
549}
550
551static GSM_Error N7110_GetPictureImageLocation(GSM_StateMachine *s, GSM_Bitmap *Bitmap, unsigned char *folder, int *location)
552{
553 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
554 GSM_SMSFolders folders;
555 GSM_Error error;
556 int i, j = 0, count = 0;
557 unsigned char req[] = {N6110_FRAME_HEADER, 0x96,
558 0x00, /* Folder ID */
559 0x0f, 0x07};
560
561 error=N7110_GetSMSFolders (s, &folders);
562 if (error!=ERR_NONE) return error;
563
564 for (i=0;i<folders.Number;i++) {
565 req[4] = (i+1) * 0x08;/* SMS folder ID */
566 error = GSM_WaitFor (s, req, 7, 0x14, 4, ID_GetBitmap);
567 if (error!=ERR_NONE) return error;
568 for (j=0;j<Priv->LastPictureImageFolder.Number;j++) {
569 count++;
570 if (count==Bitmap->Location) break;
571 }
572 if (count==Bitmap->Location) break;
573 }
574 if (count!=Bitmap->Location) return ERR_INVALIDLOCATION;
575 *folder = (i+1) * 0x08;/* SMS Folder ID */
576 *location= Priv->LastPictureImageFolder.Location[j];
577 return ERR_NONE;
578}
579
580static GSM_Error N7110_GetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
581{
582 unsigned char folder;
583 int location;
584 GSM_Error error;
585 unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
586 0x00, /* Folder ID */
587 0x00, 0x00, /* Location */
588 0x00, 0x64};
589
590 error = N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
591 switch (error) {
592 case ERR_NONE:
593 req[4] = folder;
594 req[5] = location / 256;
595 req[6] = location % 256;
596 return GSM_WaitFor (s, req, 9, 0x14, 4, ID_GetBitmap);
597 default:
598 return error;
599 }
600}
601
602static GSM_Error N7110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
603{
604 GSM_MemoryEntry pbk;
605 GSM_Error error;
606 unsigned char OpReq[] = {N6110_FRAME_HEADER, 0x70};
607
608 s->Phone.Data.Bitmap=Bitmap;
609 switch (Bitmap->Type) {
610 case GSM_StartupLogo:
611 smprintf(s, "Getting startup logo\n");
612 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x15);
613 case GSM_WelcomeNote_Text:
614 smprintf(s, "Getting welcome note\n");
615 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x02);
616 case GSM_DealerNote_Text:
617 smprintf(s, "Getting dealer note\n");
618 return N71_92_GetPhoneSetting(s, ID_GetBitmap, 0x17);
619 case GSM_CallerGroupLogo:
620 pbk.MemoryType = MEM7110_CG;
621 pbk.Location = Bitmap->Location;
622 smprintf(s, "Getting caller group logo\n");
623 error=N7110_GetMemory(s,&pbk);
624 if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(s,Bitmap);
625 return error;
626 case GSM_OperatorLogo:
627 smprintf(s, "Getting operator logo\n");
628 /* This is like DCT3_GetNetworkInfo */
629 return GSM_WaitFor (s, OpReq, 4, 0x0a, 4, ID_GetBitmap);
630 case GSM_PictureImage:
631 /* 7110 doesn't support it */
632 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return ERR_NOTSUPPORTED;
633 return N7110_GetPictureImage(s, Bitmap);
634 default:
635 break;
636 }
637 return ERR_NOTSUPPORTED;
638}
639
640static GSM_Error N7110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
641{
642 GSM_Ringtonedest;
643 GSM_Errorerror;
644 GSM_NetworkInfoNetInfo;
645 int size=200;
646 unsigned charreq[1000] = {0x7C, 0x01, 0x00, 0x0D, 0x00,
647 0x00, 0x00, 0x00, 0x00, 0x00,
648 0x00}; /*Length*/
649 unsigned charreq2[4000] = {N7110_FRAME_HEADER, 0x1F, 0x00,
650 0x87, /* Location */
651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
652 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
653 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
654 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
655 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
656
657 switch (Ringtone->Format) {
658 case RING_NOTETONE:
659 if (Ringtone->Location==255) {
660 /* 7110 doesn't support it */
661 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) return ERR_NOTSUPPORTED;
662 *maxlength=GSM_EncodeNokiaRTTLRingtone(*Ringtone, req+11, &size);
663 req[10] = size;
664 error = s->Protocol.Functions->WriteMessage(s, req, size+11, 0x00);
665 if (error!=ERR_NONE) return error;
666 my_sleep(1000);
667 /* We have to make something (not important, what) now */
668 /* no answer from phone*/
669 return DCT3_GetNetworkInfo(s,&NetInfo);
670 }
671 GSM_RingtoneConvert(&dest, Ringtone, RING_NOKIABINARY);
672 break;
673 case RING_NOKIABINARY:
674 memcpy(&dest,Ringtone,sizeof(GSM_Ringtone));
675 break;
676 default:
677 return ERR_NOTSUPPORTED;
678 }
679 req2[5]=N7110_ReturnBinaryRingtoneLocation(s->Phone.Data.Model)+Ringtone->Location;
680 CopyUnicodeString(req2+6,Ringtone->Name);
681 memcpy(req2+37,dest.NokiaBinary.Frame,dest.NokiaBinary.Length);
682 error = s->Protocol.Functions->WriteMessage(s, req2, 37+dest.NokiaBinary.Length, 0x1F);
683 if (error!=ERR_NONE) return error;
684 my_sleep(1000);
685 /* We have to make something (not important, what) now */
686 /* no answer from phone*/
687 return DCT3_GetNetworkInfo(s,&NetInfo);
688}
689
690static GSM_Error N7110_ReplySaveSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s)
691{
692 GSM_Phone_Data *Data = &s->Phone.Data;
693
694 switch (msg.Buffer[3]) {
695 case 0x05:
696 smprintf(s, "SMS message saving status\n");
697 smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
698 if (msg.Buffer[4] == 0xf8) {
699 N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
700 Data->SaveSMSMessage->Folder = 0x01;
701 } else {
702 N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
703 Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
704 }
705 return ERR_NONE;
706 case 0x06:
707 smprintf(s, "SMS message saving status\n");
708 switch (msg.Buffer[4]) {
709 case 0x03:
710 smprintf(s, "Too high location ?\n");
711 return ERR_INVALIDLOCATION;
712 default:
713 smprintf(s, "ERROR: unknown %i\n",msg.Buffer[4]);
714 }
715 break;
716 case 0x84:
717 smprintf(s, "Name for SMS changed OK to \"%s\"\n",DecodeUnicodeString(msg.Buffer+7));
718 smprintf(s, "Saved in folder %i at location %i\n",msg.Buffer[4], msg.Buffer[5]*256+msg.Buffer[6]);
719 if (msg.Buffer[4] == 0xf8) {
720 N7110_SetSMSLocation(s, Data->SaveSMSMessage,0x08,msg.Buffer[5]*256+msg.Buffer[6]);
721 Data->SaveSMSMessage->Folder = 0x01;
722 } else {
723 N7110_SetSMSLocation(s, Data->SaveSMSMessage,msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
724 Data->SaveSMSMessage->Folder = msg.Buffer[4] / 0x08;
725 }
726 return ERR_NONE;
727 }
728 return ERR_UNKNOWNRESPONSE;
729}
730
731static GSM_Error N7110_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
732{
733 int length, location;
734 unsigned char folderid, folder;
735 GSM_Error error;
736 unsigned char req[256] = {N6110_FRAME_HEADER, 0x04,
737 0x03, /* sms status */
738 0x10, /* folder */
739 0x00,0x00, /* location */
740 0x00};
741 unsigned char NameReq[200] = {N6110_FRAME_HEADER, 0x83};
742
743 switch (sms->State) {
744 case SMS_Read: req[4] = 0x01; break;
745 case SMS_UnRead: req[4] = 0x03; break;
746 case SMS_Sent: req[4] = 0x05; break;
747 case SMS_UnSent: req[4] = 0x07; break;
748 }
749
750 N7110_GetSMSLocation(s, sms, &folderid, &location);
751 req[5] = folderid;
752 req[6] = location / 256;
753 req[7] = location;
754
755 /* Outbox */
756 if (folderid == 0x10 && (sms->State == SMS_Sent || sms->State == SMS_UnSent)) {
757 /* We will use SIM Outbox */
758 sms->PDU = SMS_Submit;
759 }
760 /* Inbox */
761 if (folderid == 0x08 && sms->State == SMS_UnRead) {
762 /* We will use SIM Inbox */
763 req[5] = 0xf8;
764 }
765
766 switch (sms->PDU) {
767 case SMS_Deliver:
768 error = PHONE_EncodeSMSFrame(s,sms,req+9,PHONE_SMSDeliver,&length,true);
769 break;
770 case SMS_Submit:
771 smprintf(s, "Saving SMS template\n");
772 error = PHONE_EncodeSMSFrame(s,sms,req+9,N7110_SMSTemplate,&length,true);
773 req[8] = 0x02;/* SMS Template info */
774 break;
775 default:
776 return ERR_UNKNOWN;
777 }
778 if (error != ERR_NONE) return error;
779
780 s->Phone.Data.SaveSMSMessage=sms;
781 smprintf(s, "Saving sms\n");
782 error=GSM_WaitFor (s, req, 9+length, 0x14, 4, ID_SaveSMSMessage);
783 if (error == ERR_NONE && UnicodeLength(sms->Name)!=0) {
784 folder = sms->Folder;
785 sms->Folder = 0;
786 N7110_GetSMSLocation(s, sms, &folderid, &location);
787 length = 4;
788 NameReq[length++] = folderid;
789 NameReq[length++] = location / 256;
790 NameReq[length++] = location;
791 CopyUnicodeString(NameReq+length, sms->Name);
792 length = length+UnicodeLength(sms->Name)*2;
793 NameReq[length++] = 0;
794 NameReq[length++] = 0;
795 error=GSM_WaitFor (s, NameReq, length, 0x14, 4, ID_SaveSMSMessage);
796 sms->Folder = folder;
797 }
798 return error;
799}
800
801static GSM_Error N7110_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
802{
803 int location;
804 unsigned char folderid;
805
806 N7110_GetSMSLocation(s, sms, &folderid, &location);
807 if (location == 0) return ERR_INVALIDLOCATION;
808 return N7110_PrivSetSMSMessage(s, sms);
809}
810
811static GSM_Error N7110_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
812{
813 int location;
814 unsigned char folderid;
815
816 N7110_GetSMSLocation(s, sms, &folderid, &location);
817 location = 0;
818 N7110_SetSMSLocation(s, sms, folderid, location);
819 return N7110_PrivSetSMSMessage(s, sms);
820}
821
822static GSM_Error N7110_ReplyClearOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
823{
824 smprintf(s, "Clearing operator logo.....\n");
825 return ERR_NONE;
826}
827
828static GSM_Error N7110_ReplySetOperatorLogo(GSM_Protocol_Message msg, GSM_StateMachine *s)
829{
830 smprintf(s, "Setting operator logo.....\n");
831 return ERR_NONE;
832}
833
834static GSM_Error N7110_SetCallerLogo(GSM_StateMachine *s, GSM_Bitmap *bitmap)
835{
836 int block=0, i, Width, Height;
837 unsigned int count = 18;
838 char string[500];
839 unsigned char req[500] = {N6110_FRAME_HEADER, 0x0b, 0x00,
840 0x01, 0x01, 0x00, 0x00, 0x0c,
841 0x00, 0x10, /* memory type */
842 0x00, 0x00, /* location */
843 0x00, 0x00, 0x00};
844
845 req[13] = bitmap->Location;
846
847 /* Enabling/disabling logo */
848 if (bitmap->DefaultBitmap) {
849 string[0] = 0; //disabling
850 } else {
851 string[0] = bitmap->BitmapEnabled?1:0;
852 }
853 string[1] = 0;
854 count += N71_65_PackPBKBlock(s, N7110_PBK_LOGOON, 2, block++, string, req + count);
855
856 /* Ringtone */
857 if (!bitmap->DefaultRingtone) {
858 string[0] = bitmap->RingtoneID;
859 string[1] = 0;
860 count += N71_65_PackPBKBlock(s, N7110_PBK_RINGTONE_ID, 2, block++, string, req + count);
861 }
862
863 /* Number of group */
864 string[0] = bitmap->Location;
865 string[1] = 0;
866 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUP, 2, block++, string, req + count);
867
868 /* Name */
869 if (!bitmap->DefaultName) {
870 i = UnicodeLength(bitmap->Text) * 2;
871 string[0] = i + 2;
872 memcpy(string + 1, bitmap->Text, i);
873 string[i + 1] = 0;
874 count += N71_65_PackPBKBlock(s, N7110_PBK_NAME, i + 2, block++, string, req + count);
875 }
876
877 /* Logo */
878 if (bitmap->DefaultBitmap) {
879 bitmap->BitmapWidth = 72;
880 bitmap->BitmapHeight = 14;
881 GSM_ClearBitmap(bitmap);
882 }
883 PHONE_GetBitmapWidthHeight(GSM_NokiaCallerLogo, &Width, &Height);
884 string[0] = Width;
885 string[1] = Height;
886 string[2] = 0;
887 string[3] = 0;
888 string[4] = PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0);
889 PHONE_EncodeBitmap(GSM_NokiaCallerLogo, string + 5, bitmap);
890 count += N71_65_PackPBKBlock(s, N7110_PBK_GROUPLOGO, PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 5, block++, string, req + count);
891
892 req[17] = block;
893
894 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
895}
896
897static GSM_Error N7110_ReplySetPicture(GSM_Protocol_Message msg, GSM_StateMachine *s)
898{
899 smprintf(s, "Picture Image written OK, folder %i, location %i\n",msg.Buffer[4],msg.Buffer[5]*256+msg.Buffer[6]);
900 return ERR_NONE;
901}
902
903static GSM_Error N7110_SetPictureImage(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
904{
905 unsigned char folder;
906 GSM_Error error;
907 int location, i, count, Width, Height;
908 GSM_Phone_Bitmap_TypesType = GSM_NokiaPictureImage;
909 unsigned char req[500] = {N6110_FRAME_HEADER, 0x50, 0x07,
910 0x00, /* location*/
911 0x00, 0x00, /* index*/
912 0x07};
913
914 error=N7110_GetPictureImageLocation(s, Bitmap, &folder, &location);
915 switch (error) {
916 case ERR_NONE:
917 req[5] = folder;
918 req[6] = location / 256;
919 req[7] = location % 256;
920 break;
921 case ERR_INVALIDLOCATION:
922 req[5] = 0x21;/* Save in Templates folder */
923 req[6] = 0;
924 req[7] = 0;
925 break;
926 default:
927 return error;
928 }
929
930 /* Cleaning */
931 for (i=0;i<36;i++) req[i+9]=0;
932
933 count=8;
934 if (UnicodeLength(Bitmap->Text)==0) {
935 count+=2 ;req[count]=0x0c;
936 count+=2 ;req[count]=0x0d;
937 count+=2 ;req[count]=0x0e;
938 count+=2 ;req[count]=0x0f;
939 count+=2 ;req[count]=0x10;
940 count+=2 ;req[count]=0x11;
941 count+=23;req[count]=0x02;
942 count++ ;
943 } else {
944 count+=2 ;req[count]=0x54;
945 count++ ;req[count]=0xd4;
946 count++ ;req[count]=0x0d;
947 count+=2 ;req[count]=0x0e;
948 count+=2 ;req[count]=0x0f;
949 count+=2 ;req[count]=0x10;
950 count+=2 ;req[count]=0x11;
951 count+=21;req[count]=0x01;
952 count+=3 ;
953 }
954 req[count] = 0x01;
955 count+=2;
956 req[count++] = 0x01;
957 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
958 req[count++] = Width;
959 req[count++] = Height;
960 req[count++] = PHONE_GetBitmapSize(Type,0,0) / 256;
961 req[count++] = PHONE_GetBitmapSize(Type,0,0) % 256;
962 PHONE_EncodeBitmap(Type, req + count, Bitmap);
963 count += PHONE_GetBitmapSize(Type,0,0);
964 if (UnicodeLength(Bitmap->Text)!=0) {
965 req[count] = UnicodeLength(Bitmap->Text);
966 GSM_PackSevenBitsToEight(0, Bitmap->Text, req+count+1,strlen(Bitmap->Text));
967 count = count + req[count];
968 } else {
969 req[count++]=0x00;
970 }
971 req[count++]=0x00;
972 smprintf(s, "Setting Picture Image\n");
973 return GSM_WaitFor (s, req, count, 0x14, 4, ID_SetBitmap);
974}
975
976static GSM_Error N7110_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
977{
978 GSM_Error error;
979 GSM_Phone_Bitmap_TypesType;
980 int Width, Height, i;
981 unsigned char reqStartup[1000] = {N7110_FRAME_HEADER, 0xec,
982 0x15, /* Startup Logo setting */
983 0x00, 0x00, 0x00, 0x04, 0xc0, 0x02, 0x00,
984 0x00, /* Bitmap height */
985 0xc0, 0x03, 0x00,
986 0x00, /* Bitmap width */
987 0xc0, 0x04, 0x03, 0x00};
988 unsigned char reqOp[1000] = {N7110_FRAME_HEADER, 0xa3, 0x01,
989 0x00, /* logo disabled */
990 0x00, 0xf0, 0x00,/* network code (000 00) */
991 0x00 ,0x04,
992 0x08, /* length of rest */
993 0x00, 0x00, /* Bitmap width / height */
994 0x00,
995 0x00, /* Bitmap size */
996 0x00, 0x00};
997 unsigned char reqClrOp[] = {0x00, 0x01, 0x00, 0xaf, 0x00};
998 unsigned char reqStartupText[500] = {N7110_FRAME_HEADER, 0xec,
999 0x02}; /* Startup Text setting */
1000
1001 switch (Bitmap->Type) {
1002 case GSM_StartupLogo:
1003 if (Bitmap->Location!=1) return ERR_NOTSUPPORTED;
1004 Type=GSM_Nokia6210StartupLogo;
1005 if (strcmp(s->Phone.Data.Model,"NSE-5") == 0) Type=GSM_Nokia7110StartupLogo;
1006 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1007 reqStartup[12] = Height;
1008 reqStartup[16] = Width;
1009 PHONE_EncodeBitmap(Type, reqStartup + 21, Bitmap);
1010 smprintf(s, "Setting startup logo\n");
1011 return GSM_WaitFor (s, reqStartup, 21+PHONE_GetBitmapSize(Type,0,0), 0x7A, 4, ID_SetBitmap);
1012 case GSM_WelcomeNote_Text:
1013 CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
1014 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1015 reqStartupText[i++] = 0;
1016 reqStartupText[i++] = 0;
1017 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
1018 case GSM_DealerNote_Text:
1019 reqStartupText[4] = 0x17;
1020 CopyUnicodeString(reqStartupText + 5, Bitmap->Text);
1021 i = 6 + UnicodeLength(Bitmap->Text) * 2;
1022 reqStartupText[i++] = 0;
1023 reqStartupText[i++] = 0;
1024 return GSM_WaitFor (s, reqStartupText, i, 0x7A, 4, ID_SetBitmap);
1025 case GSM_OperatorLogo:
1026 /* We want to set operator logo, not clear */
1027 if (strcmp(Bitmap->NetworkCode,"000 00")) {
1028 reqOp[5] = 0x01;/* Logo enabled */
1029 NOKIA_EncodeNetworkCode(reqOp+6, Bitmap->NetworkCode);
1030 Type = GSM_Nokia7110OperatorLogo;
1031 reqOp[11] = 8 + PHONE_GetBitmapSize(Type,0,0);
1032 PHONE_GetBitmapWidthHeight(Type, &Width, &Height);
1033 reqOp[12]=Width;
1034 reqOp[13]=Height;
1035 reqOp[15]=PHONE_GetBitmapSize(Type,0,0);
1036 PHONE_EncodeBitmap(Type, reqOp + 18, Bitmap);
1037 smprintf(s, "Setting operator logo\n");
1038 return GSM_WaitFor (s, reqOp, 18+PHONE_GetBitmapSize(Type,0,0), 0x0A, 4, ID_SetBitmap);
1039 } else {
1040 smprintf(s, "Clearing operator logo\n");
1041 for (i=0;i<5;i++) {
1042 reqClrOp[4]=i;
1043 error=GSM_WaitFor (s, reqClrOp, 5, 0x0A, 4, ID_SetBitmap);
1044 if (error!=ERR_NONE) return error;
1045 }
1046 return GSM_WaitFor (s, reqOp, 18, 0x0A, 4, ID_SetBitmap);
1047 }
1048 case GSM_CallerGroupLogo:
1049 return N7110_SetCallerLogo(s,Bitmap);
1050 case GSM_PictureImage:
1051 return N7110_SetPictureImage(s,Bitmap);
1052 default:
1053 break;
1054 }
1055 return ERR_NOTSUPPORTED;
1056}
1057
1058static GSM_Error N7110_ReplyDeleteMemory(GSM_Protocol_Message msg, GSM_StateMachine *s)
1059{
1060 smprintf(s, "Phonebook entry deleted\n");
1061 return ERR_NONE;
1062}
1063
1064static GSM_Error N7110_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1065{
1066 unsigned char req[] = {N7110_FRAME_HEADER, 0x0f, 0x00, 0x01,
1067 0x04, 0x00, 0x00, 0x0c, 0x01, 0xff,
1068 0x00, 0x01, /* location*/
1069 0x05, /* memory type*/
1070 0x00, 0x00, 0x00};
1071
1072 req[12] = entry->Location / 256;
1073 req[13] = entry->Location % 256;
1074
1075 req[14] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1076 if (req[14]==0xff) return ERR_NOTSUPPORTED;
1077
1078 smprintf(s, "Deleting phonebook entry\n");
1079 return GSM_WaitFor (s, req, 18, 0x03, 4, ID_SetMemory);
1080}
1081
1082static GSM_Error N7110_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1083{
1084 int count = 18, blocks;
1085 unsigned char req[500] = {N7110_FRAME_HEADER, 0x0b, 0x00,
1086 0x01, 0x01, 0x00, 0x00, 0x0c,
1087 0x00, 0x00, /* memory type*/
1088 0x00, 0x00, /* location*/
1089 0x00, 0x00, 0x00};
1090
1091 if (entry->Location == 0) return ERR_NOTSUPPORTED;
1092
1093 req[11] = NOKIA_GetMemoryType(s, entry->MemoryType,N71_65_MEMORY_TYPES);
1094 if (req[11]==0xff) return ERR_NOTSUPPORTED;
1095
1096 req[12] = entry->Location >> 8;
1097 req[13] = entry->Location & 0xff;
1098
1099 count = count + N71_65_EncodePhonebookFrame(s, req+18, *entry, &blocks, false, IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_VOICETAGS));
1100 req[17] = blocks;
1101
1102 smprintf(s, "Writing phonebook entry\n");
1103 return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetMemory);
1104}
1105
1106static GSM_Error N7110_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
1107{
1108 unsigned char folderid;
1109 int location;
1110 unsigned char req[] = {N7110_FRAME_HEADER, 0x0a,
1111 0x00, /* folder */
1112 0x00, 0x00, /* location */
1113 0x01};
1114
1115 N7110_GetSMSLocation(s, sms, &folderid, &location);
1116 req[4] = folderid;
1117 req[5] = location / 256;
1118 req[6] = location;
1119
1120 smprintf(s, "Deleting sms\n");
1121 return GSM_WaitFor (s, req, 8, 0x14, 4, ID_DeleteSMSMessage);
1122}
1123
1124static GSM_Error N7110_ReplyGetSMSStatus(GSM_Protocol_Message msg, GSM_StateMachine *s)
1125{
1126 GSM_Phone_Data *Data = &s->Phone.Data;
1127
1128 smprintf(s, "SMS status received\n");
1129 switch (msg.Buffer[3]) {
1130 case 0x37:
1131 smprintf(s, "SIM size : %i\n",msg.Buffer[8]*256+msg.Buffer[9]);
1132 smprintf(s, "Used in phone memory : %i\n",msg.Buffer[10]*256+msg.Buffer[11]);
1133 smprintf(s, "Unread in phone memory : %i\n",msg.Buffer[12]*256+msg.Buffer[13]);
1134 smprintf(s, "Used in SIM : %i\n",msg.Buffer[14]*256+msg.Buffer[15]);
1135 smprintf(s, "Unread in SIM : %i\n",msg.Buffer[16]*256+msg.Buffer[17]);
1136 Data->SMSStatus->SIMSize= msg.Buffer[8]*256+msg.Buffer[9];
1137 Data->SMSStatus->PhoneUsed= msg.Buffer[10]*256+msg.Buffer[11];
1138 Data->SMSStatus->PhoneUnRead = msg.Buffer[12]*256+msg.Buffer[13];
1139 Data->SMSStatus->PhoneSize= 150;
1140 Data->SMSStatus->SIMUsed = msg.Buffer[14]*256+msg.Buffer[15];
1141 Data->SMSStatus->SIMUnRead = msg.Buffer[16]*256+msg.Buffer[17];
1142 return ERR_NONE;
1143 case 0x38:
1144 smprintf(s, "Error. No PIN ?\n");
1145 return ERR_SECURITYERROR;
1146 }
1147 return ERR_UNKNOWNRESPONSE;
1148}
1149
1150static GSM_Error N7110_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
1151{
1152 GSM_Error error;
1153 GSM_Phone_N7110Data*Priv = &s->Phone.Data.Priv.N7110;
1154
1155 error = DCT3_GetSMSStatus(s,status);
1156 if (error != ERR_NONE) return error;
1157
1158 /* 6210 family doesn't show in frame with SMS status info
1159 * about Templates. We get separately info about this SMS folder.
1160 */
1161 error = N7110_GetSMSFolderStatus(s, 0x20);
1162 if (error != ERR_NONE) return error;
1163 status->TemplatesUsed = Priv->LastSMSFolder.Number;
1164
1165 return ERR_NONE;
1166}
1167
1168static GSM_Error N7110_ReplyGetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
1169{
1170 GSM_Phone_Data *Data = &s->Phone.Data;
1171
1172 switch (msg.Buffer[3]) {
1173 case 0x02:
1174 smprintf(s, "Profile feature %02x with value %02x\n",msg.Buffer[6],msg.Buffer[10]);
1175 switch (msg.Buffer[6]) {
1176 case 0x03:
1177 smprintf(s, "Ringtone ID\n");
1178 Data->Profile->FeatureID[Data->Profile->FeaturesNumber] = Profile_RingtoneID;
1179 Data->Profile->FeatureValue[Data->Profile->FeaturesNumber] = msg.Buffer[10];
1180 Data->Profile->FeaturesNumber++;
1181 break;
1182 case 0x08:/* Caller groups */
1183 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,true);
1184 break;
1185 case 0x09:/* Autoanswer */
1186 if (Data->Profile->CarKitProfile || Data->Profile->HeadSetProfile) {
1187 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
1188 }
1189 break;
1190 case 0xff :
1191 CopyUnicodeString(Data->Profile->Name, msg.Buffer+10);
1192 smprintf(s, "profile Name: \"%s\"\n", DecodeUnicodeString(Data->Profile->Name));
1193 Data->Profile->DefaultName = false;
1194 break;
1195 default:
1196 NOKIA_FindFeatureValue(s, Profile71_65,msg.Buffer[6],msg.Buffer[10],Data,false);
1197 }
1198 return ERR_NONE;
1199 }
1200 return ERR_UNKNOWNRESPONSE;
1201}
1202
1203static GSM_Error N7110_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
1204{
1205 GSM_Error error;
1206 int i;
1207 unsigned char Features[12] = {0x00,0x02,0x03,0x04,0x05,0x06,
1208 0x07,0x08,0x09,0xff,
1209 0x0a,0x22};
1210 unsigned char req[] = {N6110_FRAME_HEADER, 0x01, 0x01, 0x01, 0x01,
1211 0x00, /* Profile Location*/
1212 0xff}; /* Feature number*/
1213
1214 if (Profile->Location > 7) return ERR_INVALIDLOCATION;
1215
1216 Profile->CarKitProfile = false;
1217 Profile->HeadSetProfile = false;
1218 if (Profile->Location == 6) Profile->CarKitProfile = true;
1219 if (Profile->Location == 7) Profile->HeadSetProfile = true;
1220
1221 Profile->FeaturesNumber = 0;
1222
1223 s->Phone.Data.Profile=Profile;
1224 for (i = 0; i < 10; i++) {
1225 req[7] = Profile->Location;
1226 req[8] = Features[i];
1227 smprintf(s, "Getting profile feature\n");
1228 error = GSM_WaitFor (s, req, 9, 0x39, 4, ID_GetProfile);
1229 if (error!=ERR_NONE) return error;
1230 }
1231 NOKIA_GetDefaultProfileName(s, Profile);
1232 Profile->Active = false;
1233 return error;
1234}
1235
1236static GSM_Error N7110_ReplySetProfileFeature(GSM_Protocol_Message msg, GSM_StateMachine *s)
1237{
1238 smprintf(s, "Profile feature set\n");
1239 return ERR_NONE;
1240}
1241
1242static GSM_Error N7110_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
1243{
1244 int i;
1245 bool found;
1246 GSM_Errorerror;
1247 unsigned charID,Value;
1248 unsigned char req[] = {N6110_FRAME_HEADER, 0x03, 0x01, 0x01, 0x03,
1249 0x02, /* feature number*/
1250 0x01, /* Profile Location */
1251 0x01,
1252 0xff}; /* Value */
1253
1254 for (i=0;i<Profile->FeaturesNumber;i++) {
1255 found = false;
1256 switch (Profile->FeatureID[i]) {
1257 case Profile_RingtoneID:
1258 ID = 0x03;
1259 Value = Profile->FeatureValue[i];
1260 found = true;
1261 break;
1262 default:
1263 found=NOKIA_FindPhoneFeatureValue(
1264 s,
1265 Profile71_65,
1266 Profile->FeatureID[i],Profile->FeatureValue[i],
1267 &ID,&Value);
1268 }
1269 if (found) {
1270 req[7] = ID;
1271 req[8] = Profile->Location;
1272 req[10] = Value;
1273 smprintf(s, "Setting profile feature\n");
1274 error = GSM_WaitFor (s, req, 11, 0x39, 4, ID_SetProfile);
1275 if (error!=ERR_NONE) return error;
1276 }
1277 }
1278 return ERR_NONE;
1279}
1280
1281static GSM_Error N7110_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
1282{
1283 GSM_MemoryEntry pbk;
1284 GSM_Error error;
1285
1286 pbk.MemoryType = MEM7110_SP;
1287 pbk.Location = SpeedDial->Location;
1288 SpeedDial->MemoryLocation = 0;
1289 s->Phone.Data.SpeedDial = SpeedDial;
1290
1291 smprintf(s, "Getting speed dial\n");
1292 error=N7110_GetMemory(s,&pbk);
1293 switch (error) {
1294 case ERR_NOTSUPPORTED:
1295 smprintf(s, "No speed dials set in phone\n");
1296 return ERR_EMPTY;
1297 case ERR_NONE:
1298 if (SpeedDial->MemoryLocation == 0) {
1299 smprintf(s, "Speed dial not assigned or error in firmware\n");
1300 return ERR_EMPTY;
1301 }
1302 return ERR_NONE;
1303 default:
1304 return error;
1305 }
1306}
1307
1308static GSM_Error N7110_ReplyIncomingSMS(GSM_Protocol_Message msg, GSM_StateMachine *s)
1309{
1310 GSM_SMSMessage sms;
1311 GSM_Phone_Data *Data = &s->Phone.Data;
1312
1313#ifdef DEBUG
1314 smprintf(s, "SMS message received\n");
1315 sms.State = SMS_UnRead;
1316 sms.InboxFolder = true;
1317 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
1318#endif
1319 if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
1320 sms.State = SMS_UnRead;
1321 sms.InboxFolder = true;
1322 DCT3_DecodeSMSFrame(s, &sms,msg.Buffer+8);
1323
1324 s->User.IncomingSMS(s->CurrentConfig->Device,sms);
1325 }
1326 return ERR_NONE;
1327}
1328
1329static GSM_Error N7110_Initialise (GSM_StateMachine *s)
1330{
1331#ifdef DEBUG
1332 DCT3_SetIncomingCB(s,true);
1333#endif
1334#ifdef GSM_ENABLE_N71_92INCOMINGINFO
1335 /* Enables various things like incoming SMS, call info, etc. */
1336 return N71_65_EnableFunctions (s, "\x01\x02\x06\x0A\x14\x17", 6);
1337#endif
1338 return ERR_NONE;
1339}
1340
1341static GSM_Error N7110_ReplyGetCalendarInfo(GSM_Protocol_Message msg, GSM_StateMachine *s)
1342{
1343 /* Old method 1 for accessing calendar */
1344 return N71_65_ReplyGetCalendarInfo1(msg, s, &s->Phone.Data.Priv.N7110.LastCalendar);
1345}
1346
1347#ifdef DEBUG
1348static GSM_Error N7110_ReplyGetCalendarNotePos(GSM_Protocol_Message msg, GSM_StateMachine *s)
1349{
1350 /* Old method 1 for accessing calendar */
1351 return N71_65_ReplyGetCalendarNotePos1(msg, s, &s->Phone.Data.Priv.N7110.FirstCalendarPos);
1352}
1353#endif
1354
1355static GSM_Error N7110_GetNextCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note, bool start)
1356{
1357 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);
1358 //return N71_65_GetNextCalendar2(s,Note,start,&s->Phone.Data.Priv.N7110.LastCalendarYear,&s->Phone.Data.Priv.N7110.LastCalendarPos);
1359}
1360
1361static GSM_Error N7110_GetCalendarStatus(GSM_StateMachine *s, GSM_CalendarStatus *Status)
1362{
1363 GSM_Error error;
1364
1365 /* Method 1 */
1366 error=N71_65_GetCalendarInfo1(s, &s->Phone.Data.Priv.N7110.LastCalendar);
1367 if (error!=ERR_NONE) return error;
1368 Status->Used = s->Phone.Data.Priv.N6510.LastCalendar.Number;
1369 return ERR_NONE;
1370
1371 /* Method 2 */
1372 // return GE_NOTSUPPORTED;
1373}
1374
1375static GSM_Error N7110_AddCalendar(GSM_StateMachine *s, GSM_CalendarEntry *Note)
1376{
1377 //return N71_65_AddCalendar1(s, Note, NULL);
1378 return N71_65_AddCalendar2(s,Note);
1379}
1380
1381static GSM_Error N7110_ReplyGetNetworkInfoError(GSM_Protocol_Message msg, GSM_StateMachine *s)
1382{
1383 smprintf(s, "Probably means no PIN\n");
1384 return ERR_SECURITYERROR;
1385}
1386
1387static GSM_Error N7110_SetIncomingCall(GSM_StateMachine *s, bool enable)
1388{
1389#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1390 return ERR_SOURCENOTAVAILABLE;
1391#endif
1392 return NOKIA_SetIncomingCall(s,enable);
1393}
1394
1395static GSM_Error N7110_SetIncomingUSSD(GSM_StateMachine *s, bool enable)
1396{
1397#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1398 return ERR_SOURCENOTAVAILABLE;
1399#endif
1400 return NOKIA_SetIncomingUSSD(s,enable);
1401}
1402
1403static GSM_Error N7110_SetIncomingSMS(GSM_StateMachine *s, bool enable)
1404{
1405#ifndef GSM_ENABLE_N71_92INCOMINGINFO
1406 return ERR_SOURCENOTAVAILABLE;
1407#endif
1408 return NOKIA_SetIncomingSMS(s,enable);
1409}
1410
1411GSM_Error N7110_AnswerCall(GSM_StateMachine *s, int ID, bool all)
1412{
1413 if (!all) return DCT3DCT4_AnswerCall(s,ID);
1414 return DCT3_AnswerAllCalls(s);
1415}
1416
1417GSM_Error N7110_SetCallDivert(GSM_StateMachine *s, GSM_MultiCallDivert *divert)
1418{
1419 GSM_Errorerror;
1420 int i;
1421
1422 /* No answer from phone side */
1423 i = s->ReplyNum;
1424 s->ReplyNum = 1;
1425 error = DCT3DCT4_SetCallDivert(s,divert);
1426 s->ReplyNum = i;
1427 return error;
1428}
1429
1430GSM_Error N7110_CancelAllDiverts(GSM_StateMachine *s)
1431{
1432 GSM_Errorerror;
1433 int i;
1434
1435 /* No answer from phone side */
1436 i = s->ReplyNum;
1437 s->ReplyNum = 1;
1438 error = DCT3DCT4_CancelAllDiverts(s);
1439 s->ReplyNum = i;
1440 return error;
1441}
1442
1443static GSM_Reply_Function N7110ReplyFunctions[] = {
1444 {N71_65_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
1445 {N71_65_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
1446 {N71_65_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
1447 {N71_65_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
1448 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
1449 {N71_65_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
1450 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
1451 {N71_65_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
1452 {N71_65_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
1453 {N71_65_ReplyCallInfo, "\x01",0x03,0x0B,ID_IncomingFrame },
1454 {N71_65_ReplyCallInfo, "\x01",0x03,0x0C,ID_IncomingFrame },
1455 {N71_65_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
1456 {N71_65_ReplyCallInfo, "\x01",0x03,0x53,ID_IncomingFrame },
1457 {N71_65_ReplySendDTMF, "\x01",0x03,0x59,ID_SendDTMF },
1458 {N71_65_ReplySendDTMF, "\x01",0x03,0x5E,ID_SendDTMF },
1459
1460 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
1461 {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
1462 {N7110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
1463#ifdef GSM_ENABLE_CELLBROADCAST
1464 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
1465 {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
1466 {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
1467#endif
1468 {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
1469 {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
1470 {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
1471#ifdef GSM_ENABLE_CELLBROADCAST
1472 {DCT3_ReplySetIncomingCB, "\x02",0x03,0xCA,ID_SetIncomingCB },
1473#endif
1474
1475 {N7110_ReplyGetMemoryStatus, "\x03",0x03,0x04,ID_GetMemoryStatus },
1476 {N7110_ReplyGetMemory, "\x03",0x03,0x08,ID_GetMemory },
1477 {N7110_ReplyDeleteMemory, "\x03",0x03,0x10,ID_SetMemory },
1478 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetBitmap },
1479 {N71_65_ReplyWritePhonebook, "\x03",0x03,0x0C,ID_SetMemory },
1480
1481 {N71_65_ReplyUSSDInfo, "\x06",0x03,0x03,ID_IncomingFrame },
1482 {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },
1483
1484 {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
1485 {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
1486
1487 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
1488 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetBitmap },
1489 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
1490 {N7110_ReplyGetNetworkInfoError, "\x0A",0x03,0x72,ID_GetNetworkInfo },
1491 {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x73,ID_IncomingFrame },
1492 {N71_92_ReplyGetSignalQuality, "\x0A",0x03,0x82,ID_GetSignalQuality },
1493 {N7110_ReplySetOperatorLogo, "\x0A",0x03,0xA4,ID_SetBitmap },
1494 {N7110_ReplyClearOperatorLogo, "\x0A",0x03,0xB0,ID_SetBitmap },
1495 {NoneReply, "\x0A",0x03,0xB5,ID_IncomingFrame },
1496
1497#ifdef DEBUG
1498 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x02,ID_SetCalendarNote },/*method 1*/
1499 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x04,ID_SetCalendarNote },/*method 1*/
1500 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x06,ID_SetCalendarNote },/*method 1*/
1501 {N71_65_ReplyAddCalendar1, "\x13",0x03,0x08,ID_SetCalendarNote },/*method 1*/
1502#endif
1503 {N71_65_ReplyDelCalendar, "\x13",0x03,0x0C,ID_DeleteCalendarNote },
1504 {N71_65_ReplyGetNextCalendar1, "\x13",0x03,0x1A,ID_GetCalendarNote },/*method 1*/
1505#ifdef DEBUG
1506 {N7110_ReplyGetCalendarNotePos, "\x13",0x03,0x32,ID_GetCalendarNotePos },/*method 1*/
1507#endif
1508 {N7110_ReplyGetCalendarInfo, "\x13",0x03,0x3B,ID_GetCalendarNotesInfo},/*method 1*/
1509#ifdef DEBUG
1510 {N71_65_ReplyGetNextCalendar2, "\x13",0x03,0x3F,ID_GetCalendarNote },/*method 2*/
1511#endif
1512 {N71_65_ReplyAddCalendar2, "\x13",0x03,0x41,ID_SetCalendarNote },/*method 2*/
1513
1514 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
1515 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
1516 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
1517 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetBitmap },
1518 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
1519 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
1520 {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
1521 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
1522 {N7110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
1523 {N7110_ReplySetPicture, "\x14",0x03,0x51,ID_SetBitmap },
1524 {N7110_ReplyGetSMSFolderStatus, "\x14",0x03,0x6C,ID_GetSMSFolderStatus },
1525 {N7110_ReplyGetSMSMessage, "\x14",0x03,0x6F,ID_GetSMSMessage },
1526 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7B,ID_GetSMSFolders },
1527 {N7110_ReplyGetSMSFolders, "\x14",0x03,0x7C,ID_GetSMSFolders },
1528 {N7110_ReplySaveSMSMessage, "\x14",0x03,0x84,ID_SaveSMSMessage },
1529 {N7110_ReplyGetPictureImageInfo, "\x14",0x03,0x97,ID_GetBitmap },
1530 {N7110_ReplyGetSMSFolders, "\x14",0x03,0xCA,ID_GetSMSFolders },
1531
1532 {N71_92_ReplyGetBatteryCharge, "\x17",0x03,0x03,ID_GetBatteryCharge },
1533
1534 {DCT3_ReplySetDateTime, "\x19",0x03,0x61,ID_SetDateTime },
1535 {DCT3_ReplyGetDateTime, "\x19",0x03,0x63,ID_GetDateTime },
1536 {DCT3_ReplySetAlarm, "\x19",0x03,0x6C,ID_SetAlarm },
1537 {DCT3_ReplyGetAlarm, "\x19",0x03,0x6E,ID_GetAlarm },
1538
1539 {N7110_ReplyGetRingtone, "\x1f",0x03,0x23,ID_GetRingtone },
1540 {N7110_ReplyGetRingtone, "\x1f",0x03,0x24,ID_GetRingtone },
1541
1542 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x01,ID_EnableConnectFunc },
1543 {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
1544 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x04,ID_DisableConnectFunc },
1545 {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
1546 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
1547 {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
1548 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
1549 {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
1550 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0D,ID_DeleteWAPBookmark },
1551 {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
1552 {DCT3DCT4_ReplyGetActiveConnectSet,"\x3f",0x03,0x10,ID_GetConnectSet },
1553 {DCT3DCT4_ReplySetActiveConnectSet,"\x3f",0x03,0x13,ID_SetConnectSet },
1554 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
1555 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
1556 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
1557 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
1558 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
1559 {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
1560 {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
1561
1562 {N7110_ReplyGetProfileFeature, "\x39",0x03,0x02,ID_GetProfile },
1563 {N7110_ReplySetProfileFeature, "\x39",0x03,0x04,ID_SetProfile },
1564
1565 {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
1566 {N61_71_ReplyResetPhoneSettings, "\x40",0x02,0x65,ID_ResetPhoneSettings },
1567 {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
1568 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
1569 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
1570 {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
1571 {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
1572 {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
1573 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
1574 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
1575 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
1576 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetManufactureMonth },
1577 {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
1578 {NoneReply, "\x40",0x02,0xFF,ID_IncomingFrame },
1579
1580 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_GetBitmap },
1581 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x02,ID_SetBitmap },
1582 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_GetBitmap },
1583 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x15,ID_SetBitmap },
1584 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_GetBitmap },
1585 {N71_92_ReplyPhoneSetting, "\x7a",0x04,0x17,ID_SetBitmap },
1586
1587 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
1588 {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
1589 {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
1590 {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
1591
1592 {NULL, "\x00",0x00,0x00,ID_None }
1593};
1594
1595GSM_Phone_Functions N7110Phone = {
1596 "6210|6250|7110|7190",
1597 N7110ReplyFunctions,
1598 N7110_Initialise,
1599 PHONE_Terminate,
1600 GSM_DispatchMessage,
1601 NOTSUPPORTED, /* ShowStartInfo */
1602 NOKIA_GetManufacturer,
1603 DCT3DCT4_GetModel,
1604 DCT3DCT4_GetFirmware,
1605 DCT3_GetIMEI,
1606 DCT3_GetOriginalIMEI,
1607 DCT3_GetManufactureMonth,
1608 DCT3_GetProductCode,
1609 DCT3_GetHardware,
1610 DCT3_GetPPM,
1611 NOTSUPPORTED, /* GetSIMIMSI */
1612 N71_92_GetDateTime,
1613 N71_92_SetDateTime,
1614 N7110_GetAlarm,
1615 N7110_SetAlarm,
1616 NOTSUPPORTED, /* GetLocale */
1617 NOTSUPPORTED, /* SetLocale */
1618 DCT3_PressKey,
1619 DCT3_Reset,
1620 N61_71_ResetPhoneSettings,
1621 NOTSUPPORTED, /* EnterSecurityCode*/
1622 NOTSUPPORTED, /* GetSecurityStatus*/
1623 NOTSUPPORTED, /* GetDisplayStatus*/
1624 NOTIMPLEMENTED, /* SetAutoNetworkLogin*/
1625 N71_92_GetBatteryCharge,
1626 N71_92_GetSignalQuality,
1627 DCT3_GetNetworkInfo,
1628 NOTSUPPORTED, /* GetCategory */
1629 NOTSUPPORTED, /* AddCategory */
1630 NOTSUPPORTED, /* GetCategoryStatus */
1631 N7110_GetMemoryStatus,
1632 N7110_GetMemory,
1633 NOTIMPLEMENTED, /* GetNextMemory */
1634 N7110_SetMemory,
1635 NOTIMPLEMENTED, /* AddMemory */
1636 N7110_DeleteMemory,
1637 NOTIMPLEMENTED, /* DeleteAllMemory */
1638 N7110_GetSpeedDial,
1639 NOTIMPLEMENTED, /* SetSpeedDial */
1640 DCT3_GetSMSC,
1641 DCT3_SetSMSC,
1642 N7110_GetSMSStatus,
1643 N7110_GetSMSMessage,
1644 N7110_GetNextSMSMessage,
1645 N7110_SetSMS,
1646 N7110_AddSMS,
1647 N7110_DeleteSMS,
1648 DCT3_SendSMSMessage,
1649 NOTSUPPORTED, /* SendSavedSMS */
1650 N7110_SetIncomingSMS,
1651 DCT3_SetIncomingCB,
1652 N7110_GetSMSFolders,
1653 NOTIMPLEMENTED, /* AddSMSFolder */
1654 NOTIMPLEMENTED, /* DeleteSMSFolder */
1655 DCT3_DialVoice,
1656 N7110_AnswerCall,
1657 DCT3_CancelCall,
1658 NOTIMPLEMENTED, /* HoldCall */
1659 NOTIMPLEMENTED, /* UnholdCall */
1660 NOTIMPLEMENTED, /* ConferenceCall */
1661 NOTIMPLEMENTED, /* SplitCall */
1662 NOTIMPLEMENTED, /* TransferCall */
1663 NOTIMPLEMENTED, /* SwitchCall */
1664 NOTSUPPORTED, /* GetCallDivert */
1665 N7110_SetCallDivert,
1666 N7110_CancelAllDiverts,
1667 N7110_SetIncomingCall,
1668 N7110_SetIncomingUSSD,
1669 DCT3DCT4_SendDTMF,
1670 N7110_GetRingtone,
1671 N7110_SetRingtone,
1672 NOTSUPPORTED, /* GetRingtonesInfo*/
1673 NOTSUPPORTED, /* DeleteUserRingtones*/
1674 DCT3_PlayTone,
1675 DCT3_GetWAPBookmark,
1676 DCT3_SetWAPBookmark,
1677 DCT3_DeleteWAPBookmark,
1678 DCT3_GetWAPSettings,
1679 DCT3_SetWAPSettings,
1680 NOTSUPPORTED, /* GetMMSSettings */
1681 NOTSUPPORTED, /* SetMMSSettings */
1682 NOTSUPPORTED, /* GetSyncMLSettings*/
1683 NOTSUPPORTED, /* SetSyncMLSettings*/
1684 NOTSUPPORTED, /* GetChatSettings */
1685 NOTSUPPORTED, /* SetChatSettings */
1686 N7110_GetBitmap,
1687 N7110_SetBitmap,
1688 NOTSUPPORTED, /* GetToDoStatus */
1689 NOTSUPPORTED, /* GetToDo */
1690 NOTSUPPORTED, /* GetNextToDo */
1691 NOTSUPPORTED, /* SetToDo */
1692 NOTSUPPORTED, /* AddToDo */
1693 NOTSUPPORTED, /* DeleteToDo */
1694 NOTSUPPORTED, /* DeleteAllToDo */
1695 N7110_GetCalendarStatus,
1696 NOTIMPLEMENTED, /* GetCalendar */
1697 N7110_GetNextCalendar,
1698 NOTIMPLEMENTED, /* SetCalendar */
1699 N7110_AddCalendar,
1700 N71_65_DelCalendar,
1701 NOTIMPLEMENTED, /* DeleteAllCalendar*/
1702 NOTSUPPORTED, /* GetCalendarSettings*/
1703 NOTSUPPORTED, /* SetCalendarSettings*/
1704 NOTSUPPORTED, /* GetNote */
1705 N7110_GetProfile,
1706 N7110_SetProfile,
1707 NOTSUPPORTED, /* GetFMStation */
1708 NOTSUPPORTED, /* SetFMStation */
1709 NOTSUPPORTED, /* ClearFMStations */
1710 NOTSUPPORTED, /* GetNextFileFolder*/
1711 NOTSUPPORTED, /* GetFilePart */
1712 NOTSUPPORTED, /* AddFile */
1713 NOTSUPPORTED, /* GetFileSystemStatus*/
1714 NOTSUPPORTED, /* DeleteFile */
1715 NOTSUPPORTED, /* AddFolder */
1716 NOTSUPPORTED, /* GetGPRSAccessPoint*/
1717 NOTSUPPORTED /* SetGPRSAccessPoint*/
1718};
1719
1720#endif
1721
1722/* How should editor hadle tabs in this file? Add editor commands here.
1723 * vim: noexpandtab sw=8 ts=8 sts=8:
1724 */