Gammu internals  1.38.0
n6110.c
Go to the documentation of this file.
1 /* (c) 2001-2004 by Marcin Wiacek */
2 /* 5210 calendar IDs by Frederick Ros */
3 /* based on some Markus Plail, Pavel Janik & others work from Gnokii (www.gnokii.org)
4  * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot
5  * GNU GPL version 2 or later
6  */
7 /* Due to a problem in the source code management, the names of some of
8  * the authors have unfortunately been lost. We do not mean to belittle
9  * their efforts and hope they will contact us to see their names
10  * properly added to the Copyright notice above.
11  * Having published their contributions under the terms of the GNU
12  * General Public License (GPL) [version 2], the Copyright of these
13  * authors will remain respected by adhering to the license they chose
14  * to publish their code under.
15  */
16 
17 #include <gammu-config.h>
18 
19 #ifdef GSM_ENABLE_NOKIA6110
20 
21 #include <string.h>
22 
23 #include <gammu-nokia.h>
24 #include <gammu-config.h>
25 
26 #include "../../../misc/coding/coding.h"
27 #include "../../../misc/locales.h"
28 #include "../../../gsmcomon.h"
29 #include "../../../service/gsmlogo.h"
30 #include "../../../service/gsmring.h"
31 #include "../../../service/gsmnet.h"
32 #include "../../pfunc.h"
33 #include "../nfunc.h"
34 #include "n6110.h"
35 #include "dct3func.h"
36 
37 static unsigned char N6110_MEMORY_TYPES[] = {
38  MEM_ME, 0x02,
39  MEM_SM, 0x03,
40  MEM_ON, 0x05,
41  MEM_DC, 0x07,
42  MEM_RC, 0x08,
43  MEM_MC, 0x09,
44  MEM_VM, 0x0b,
45  0x00, 0x00
46 };
47 
48 static GSM_Error N6110_ReplyGetPhoneLanguage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
49 {
51 
52  if (msg->Buffer[3] == 0x15) return ERR_NONE;
53 
54  smprintf(s, "Phone language is %02x\n",msg->Buffer[6]);
55  switch (msg->Buffer[6]) {
56  case 0x21: lang = N6110_Europe; break; /* Polish */
57  }
58  s->Phone.Data.Priv.N6110.PhoneLanguage = lang;
59  return ERR_NONE;
60 }
61 
62 static GSM_Error N6110_GetPhoneLanguage(GSM_StateMachine *s)
63 {
64  unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
65  0x00, /* Profile location */
66  0x00}; /* Feature number */
67 
68  s->Phone.Data.Priv.N6110.PhoneLanguage = N6110_Auto;
69 
70  feat_req[5] = 0;
72  feat_req[6] = 0x1E;
73  } else {
74  feat_req[6] = 0x21;
75  }
76  smprintf(s, "Getting profile feature\n");
77  return GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetLanguage);
78 }
79 
80 struct N6110_Lang_Char {
81  N6110_Language Lang;
82  unsigned char Phone;
83  unsigned char Unicode1;
84  unsigned char Unicode2;
85 };
86 
87 static struct N6110_Lang_Char N6110_Lang_Table[] = {
88 {N6110_Europe,0x13,0x01,0x04},/* Latin capital letter a with ogonek */
89 {N6110_Europe,0x14,0x01,0x05},/* Latin small letter a with ogonek */
90 {N6110_Europe,0x15,0x01,0x06},/* Latin capital letter c with acute */
91 {N6110_Europe,0x17,0x01,0x07},/* Latin small letter c with acute */
92 {N6110_Europe,0x1D,0x01,0x18},/* Latin capital letter e with ogonek */
93 {N6110_Europe,0x1E,0x01,0x19},/* Latin small letter e with ogonek */
94 {N6110_Europe,0x83,0x00,0xD3},/* Latin capital letter o with acute */
95 {N6110_Europe,0x8E,0x01,0x41},/* Latin capital letter l with stroke */
96 {N6110_Europe,0x90,0x01,0x42},/* Latin small letter l with stroke */
97 {N6110_Europe,0x92,0x01,0x43},/* Latin capital letter n with acute */
98 {N6110_Europe,0x93,0x01,0x44},/* Latin small letter n with acute */
99 {N6110_Europe,0x9A,0x00,0xF3},/* Latin small letter o with acute */
100 {N6110_Europe,0xB2,0x20,0xAC},/* euro */
101 {N6110_Europe,0xB5,0x01,0x5A},/* Latin capital letter s with acute */
102 {N6110_Europe,0xB6,0x01,0x5B},/* Latin small letter s with acute */
103 {N6110_Europe,0xE7,0x01,0x79},/* Latin capital letter z with acute */
104 {N6110_Europe,0xEE,0x01,0x7A},/* Latin small letter z with acute */
105 {N6110_Europe,0xF4,0x01,0x7C},/* Latin small letter z with dot above */
106 {N6110_Europe,0xF0,0x01,0x7B},/* Latin capital letter z with dot above */
107 {0,0,0,0}
108 };
109 
110 static void N6110_EncodeUnicode(GSM_StateMachine *s, unsigned char *dest, const unsigned char *src, int len)
111 {
112  int i_len = 0, o_len, i;
113  wchar_t wc;
114  GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
115  gboolean found;
116 
117  for (o_len = 0; i_len < len; o_len++) {
118  found = FALSE;
119  if (Priv->PhoneLanguage != N6110_Auto) {
120  i = 0;
121  while(1) {
122  if (N6110_Lang_Table[i].Lang == 0) break;
123  if (N6110_Lang_Table[i].Lang == Priv->PhoneLanguage &&
124  N6110_Lang_Table[i].Phone == src[i_len]) {
125  dest[o_len*2] = N6110_Lang_Table[i].Unicode1;
126  dest[(o_len*2)+1] = N6110_Lang_Table[i].Unicode2;
127  i_len++;
128  found = TRUE;
129  break;
130  }
131  i++;
132  }
133  }
134  if (!found) {
135  i_len += EncodeWithUnicodeAlphabet(&src[i_len], &wc);
136  dest[o_len*2] = (wc >> 8) & 0xff;
137  dest[(o_len*2)+1] = wc & 0xff;
138  }
139  }
140  dest[o_len*2] = 0;
141  dest[(o_len*2)+1] = 0;
142 }
143 
144 
145 /* Pavel Janik */
146 /* This function provides Nokia authentication protocol.
147  * Nokia authentication protocol is used in the communication between Nokia
148  * mobile phones (e.g. Nokia 6110) and Nokia Cellular Data Suite software,
149  * commercially sold by Nokia Corp.
150  * The authentication scheme is based on the token send by the phone to the
151  * software. The software does it's magic (see the function
152  * N6110_GetNokiaAuthentication) and returns the result back to the phone.
153  * If the result is correct the phone responds with the message "Accessory
154  * connected!" displayed on the LCD. Otherwise it will display "Accessory not
155  * supported" and some functions will not be available for use (?).
156  * The specification of the protocol is not publicly available, no comment.
157  */
158 static void N6110_GetNokiaAuthentication(unsigned char *Imei, unsigned char *MagicBytes, unsigned char *MagicResponse)
159 {
160  int i, j, CRC=0;
161  unsigned char Temp[16]; /* This is our temporary working area. */
162 
163  /* Here we put FAC (Final Assembly Code) and serial number into our area. */
164  Temp[0] = Imei[6]; Temp[1] = Imei[7];
165  Temp[2] = Imei[8]; Temp[3] = Imei[9];
166  Temp[4] = Imei[10]; Temp[5] = Imei[11];
167  Temp[6] = Imei[12]; Temp[7] = Imei[13];
168 
169  /* And now the TAC (Type Approval Code). */
170  Temp[8] = Imei[2]; Temp[9] = Imei[3];
171  Temp[10] = Imei[4]; Temp[11] = Imei[5];
172 
173  /* And now we pack magic bytes from the phone. */
174  Temp[12] = MagicBytes[0]; Temp[13] = MagicBytes[1];
175  Temp[14] = MagicBytes[2]; Temp[15] = MagicBytes[3];
176 
177  for (i=0; i<=11; i++) if (Temp[i + 1]& 1) Temp[i]<<=1;
178  switch (Temp[15] & 0x03) {
179  case 1:
180  case 2: j = Temp[13] & 0x07;
181  for (i=0; i<=3; i++) Temp[i+j] ^= Temp[i+12];
182  break;
183  default: j = Temp[14] & 0x07;
184  for (i=0; i<=3; i++) Temp[i + j] |= Temp[i + 12];
185  }
186  for (i=0; i<=15; i++) CRC ^= Temp[i];
187  for (i=0; i<=15; i++) {
188  switch (Temp[15 - i] & 0x06) {
189  case 0: j = Temp[i] | CRC; break;
190  case 2:
191  case 4: j = Temp[i] ^ CRC; break;
192  case 6: j = Temp[i] & CRC; break;
193  }
194  if (j == CRC) j = 0x2c;
195  if (Temp[i] == 0) j = 0;
196  MagicResponse[i] = j;
197  }
198 }
199 
200 static GSM_Error N6110_ReplyGetMagicBytes(GSM_Protocol_Message *msg, GSM_StateMachine *s)
201 {
202  GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
203  GSM_Phone_Data *Data = &s->Phone.Data;
204 
205  sprintf(Data->IMEI, "%s", msg->Buffer+9);
206  sprintf(Data->HardwareCache, "%s", msg->Buffer+39);
207  sprintf(Data->ProductCodeCache, "%s", msg->Buffer+31);
208 
209  smprintf(s, "Message: Mobile phone identification received:\n");
210  smprintf(s, "IMEI : %s\n", msg->Buffer+9);
211  smprintf(s, "Model : %s\n", msg->Buffer+25);
212  smprintf(s, "Production Code : %s\n", msg->Buffer+31);
213  smprintf(s, "HW : %s\n", msg->Buffer+39);
214  smprintf(s, "Firmware : %s\n", msg->Buffer+44);
215 
216  /* These bytes are probably the source of the "Accessory not connected"
217  * messages on the phone when trying to emulate NCDS... I hope....
218  * UPDATE: of course, now we have the authentication algorithm.
219  */
220  smprintf(s, " Magic bytes : %02x %02x %02x %02x\n", msg->Buffer[50], msg->Buffer[51], msg->Buffer[52], msg->Buffer[53]);
221 
222  Priv->MagicBytes[0]=msg->Buffer[50];
223  Priv->MagicBytes[1]=msg->Buffer[51];
224  Priv->MagicBytes[2]=msg->Buffer[52];
225  Priv->MagicBytes[3]=msg->Buffer[53];
226 
227  return ERR_NONE;
228 }
229 
230 static GSM_Error N6110_MakeAuthentication(GSM_StateMachine *s)
231 {
232  GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
233  GSM_Error error;
234  unsigned char connect4[] = {N6110_FRAME_HEADER, 0x10};
235  unsigned char magic_connect[] = {
236  N6110_FRAME_HEADER, 0x12,
237  /* The real magic goes here ... These bytes are filled in
238  * with the function N6110_GetNokiaAuthentication. */
239  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
241  /* NOKIA&GNOKII Accessory */
242  'N', 'O', 'K', 'I', 'A', '&', 'N', 'O', 'K', 'I', 'A',
243  'a', 'c', 'c', 'e', 's', 's', 'o', 'r', 'y',
244  0x00, 0x00, 0x00, 0x00};
245 
246  smprintf(s, "Getting magic bytes for authentication\n");
247  error=GSM_WaitFor (s, connect4, 4, 0x64, 4, ID_MakeAuthentication);
248  if (error!=ERR_NONE) return error;
249 
250  N6110_GetNokiaAuthentication(s->Phone.Data.IMEI, Priv->MagicBytes, magic_connect+4);
251  smprintf(s, "Sending authentication bytes\n");
252  return s->Protocol.Functions->WriteMessage(s, magic_connect, 45, 0x64);
253 }
254 
255 
256 static GSM_Error N6110_ShowStartInfo(GSM_StateMachine *s, gboolean enable UNUSED)
257 {
258  GSM_Error error=ERR_NONE;
259 
261  if (s->ConnectionType == GCT_FBUS2 ||
263  error=N6110_MakeAuthentication(s);
264  }
265  }
266  return error;
267 }
268 
269 static GSM_Error N6110_Initialise (GSM_StateMachine *s)
270 {
271 #ifdef DEBUG
273 #endif
274  N6110_GetPhoneLanguage(s);
275  return ERR_NONE;
276 }
277 
278 static GSM_Error N6110_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
279 {
280  return DCT3_GetDateTime(s, date_time, 0x11);
281 }
282 
283 static GSM_Error N6110_GetAlarm(GSM_StateMachine *s, GSM_Alarm *Alarm)
284 {
285  return DCT3_GetAlarm(s, Alarm, 0x11);
286 }
287 
288 static GSM_Error N6110_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time)
289 {
290  return DCT3_SetDateTime(s, date_time, 0x11);
291 }
292 
293 static GSM_Error N6110_SetAlarm(GSM_StateMachine *s, GSM_Alarm *Alarm)
294 {
295  return DCT3_SetAlarm(s, Alarm, 0x11);
296 }
297 
298 static GSM_Error N6110_ReplyGetMemory(GSM_Protocol_Message *msg, GSM_StateMachine *s)
299 {
300  int count;
301  GSM_Phone_Data *Data = &s->Phone.Data;
302 
303  smprintf(s, "Phonebook entry received\n");
304  switch (msg->Buffer[3]) {
305  case 0x02:
306  Data->Memory->EntriesNum = 0;
307  count=5;
308  /* If name is not empty */
309  if (msg->Buffer[count]!=0x00) {
310  if (msg->Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
311  smprintf(s, "Too long text\n");
312  return ERR_UNKNOWNRESPONSE;
313  }
317  if (Data->Memory->MemoryType==MEM_DC ||
318  Data->Memory->MemoryType==MEM_RC ||
319  Data->Memory->MemoryType==MEM_MC ||
320  Data->Memory->MemoryType==MEM_ME) {
321  N6110_EncodeUnicode(s,Data->Memory->Entries[Data->Memory->EntriesNum].Text,
322  msg->Buffer+count+1,msg->Buffer[count]);
323  } else {
325  msg->Buffer+count+1,msg->Buffer[count]);
326  }
327  } else {
328  memcpy(Data->Memory->Entries[Data->Memory->EntriesNum].Text,
329  msg->Buffer+count+1,msg->Buffer[count]);
330  Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg->Buffer[count]]=0x00;
331  Data->Memory->Entries[Data->Memory->EntriesNum].Text[msg->Buffer[count]+1]=0x00;
332  }
333  smprintf(s, "Name \"%s\"\n",
335  Data->Memory->EntriesNum++;
336  }
337  count=count+msg->Buffer[count]+1;
338 
339  /* If number is empty */
340  if (msg->Buffer[count]==0x00) return ERR_EMPTY;
341 
342  if (msg->Buffer[count]>GSM_PHONEBOOK_TEXT_LENGTH) {
343  smprintf(s, "Too long text\n");
344  return ERR_UNKNOWNRESPONSE;
345  }
348  Data->Memory->Entries[Data->Memory->EntriesNum].VoiceTag = 0;
349  Data->Memory->Entries[Data->Memory->EntriesNum].SMSList[0] = 0;
351  msg->Buffer+count+1,msg->Buffer[count]);
352  smprintf(s, "Number \"%s\"\n",
354  Data->Memory->EntriesNum++;
355  count=count+msg->Buffer[count]+1;
356 
358  if (msg->Buffer[count]<5) {
361  smprintf(s, "Caller group \"%i\"\n",msg->Buffer[count]);
362  Data->Memory->Entries[Data->Memory->EntriesNum].Number=msg->Buffer[count]+1;
363  Data->Memory->EntriesNum++;
364  }
365  }
366  count++;
367 
368  if (Data->Memory->MemoryType==MEM_DC ||
369  Data->Memory->MemoryType==MEM_RC ||
370  Data->Memory->MemoryType==MEM_MC) {
371  NOKIA_DecodeDateTime(s, msg->Buffer+count+1,&Data->Memory->Entries[Data->Memory->EntriesNum].Date, TRUE, FALSE);
374 
375  /* These values are set, when date and time unavailable in phone.
376  * Values from 3310 - in other can be different */
377  if (Data->Memory->Entries[2].Date.Day !=20 ||
378  Data->Memory->Entries[2].Date.Month !=1 ||
379  Data->Memory->Entries[2].Date.Year !=2118||
380  Data->Memory->Entries[2].Date.Hour !=3 ||
381  Data->Memory->Entries[2].Date.Minute!=14 ||
382  Data->Memory->Entries[2].Date.Second!=7)
383  Data->Memory->EntriesNum++;
384  }
385 
386  return ERR_NONE;
387  default:
388  switch (msg->Buffer[4]) {
389  case 0x6f:
390  smprintf(s, "Phone is OFF\n");
391  return ERR_PHONEOFF;
392  case 0x74:
393  /* TODO: check if not too high */
394  smprintf(s, "ERROR: Empty ????\n");
395  Data->Memory->EntriesNum = 0;
396  return ERR_EMPTY;
397  case 0x7d:
398  smprintf(s, "ERROR: Invalid memory type\n");
399  return ERR_NOTSUPPORTED;
400  case 0x8d:
401  smprintf(s, "ERROR: no PIN\n");
402  return ERR_SECURITYERROR;
403  default:
404  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
405  }
406  }
407  return ERR_UNKNOWNRESPONSE;
408 }
409 
410 static GSM_Error N6110_GetMemory (GSM_StateMachine *s, GSM_MemoryEntry *entry)
411 {
412  unsigned char req[] = {N6110_FRAME_HEADER, 0x01,
413  0x00, /* memory type */
414  0x00, /* location */
415  0x00};
416 
417  if (entry->Location > 255) return ERR_INVALIDLOCATION;
418 
419  req[4] = NOKIA_GetMemoryType(s, entry->MemoryType,N6110_MEMORY_TYPES);
420  if (req[4]==0xff) return ERR_NOTSUPPORTED;
421 
422  req[5] = entry->Location;
423  if (entry->MemoryType==MEM_DC || entry->MemoryType==MEM_RC || entry->MemoryType==MEM_MC) req[5]--;
424 
425  s->Phone.Data.Memory=entry;
426  smprintf(s, "Getting phonebook entry\n");
427  return GSM_WaitFor (s, req, 7, 0x03, 4, ID_GetMemory);
428 }
429 
430 static GSM_Error N6110_ReplyGetMemoryStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
431 {
432  GSM_Phone_Data *Data = &s->Phone.Data;
433 
434  smprintf(s, "Memory status received\n");
435  switch (msg->Buffer[3]) {
436  case 0x08:
437  smprintf(s, "Memory type: %i\n",msg->Buffer[4]);
438 
439  smprintf(s, "Free : %i\n",msg->Buffer[5]);
440  Data->MemoryStatus->MemoryFree=msg->Buffer[5];
441 
442  smprintf(s, "Used : %i\n",msg->Buffer[6]);
443  Data->MemoryStatus->MemoryUsed=msg->Buffer[6];
444 
445  return ERR_NONE;
446  case 0x09:
447  switch (msg->Buffer[4]) {
448  case 0x6f:
449  smprintf(s, "Phone is probably powered off.\n");
450  return ERR_TIMEOUT;
451  case 0x7d:
452  smprintf(s, "Memory type not supported by phone model.\n");
453  return ERR_NOTSUPPORTED;
454  case 0x8d:
455  smprintf(s, "Waiting for security code.\n");
456  return ERR_SECURITYERROR;
457  default:
458  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
459  return ERR_UNKNOWNRESPONSE;
460  }
461  default:
462  return ERR_UNKNOWNRESPONSE;
463  }
464 }
465 
466 static GSM_Error N6110_GetMemoryStatus(GSM_StateMachine *s, GSM_MemoryStatus *Status)
467 {
468  unsigned char req[] = {N6110_FRAME_HEADER, 0x07,
469  0x00}; /* memory type */
470 
471  req[4] = NOKIA_GetMemoryType(s, Status->MemoryType,N6110_MEMORY_TYPES);
472  if (req[4]==0xff) return ERR_NOTSUPPORTED;
473 
474  s->Phone.Data.MemoryStatus=Status;
475  smprintf(s, "Getting memory status\n");
476  return GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetMemoryStatus);
477 }
478 
479 static GSM_Error N6110_ReplyGetSMSStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
480 {
481  GSM_Phone_Data *Data = &s->Phone.Data;
482 
483  smprintf(s, "SMS status received\n");
484  switch (msg->Buffer[3]) {
485  case 0x37:
486  smprintf(s, "SIM size : %i\n",msg->Buffer[7]);
487  smprintf(s, "Used in SIM : %i\n",msg->Buffer[10]);
488  smprintf(s, "Unread in SIM : %i\n",msg->Buffer[11]);
489  Data->SMSStatus->SIMUsed = msg->Buffer[10];
490  Data->SMSStatus->SIMUnRead = msg->Buffer[11];
491  Data->SMSStatus->SIMSize = msg->Buffer[7];
492  Data->SMSStatus->PhoneUsed = 0;
493  Data->SMSStatus->PhoneUnRead = 0;
494  Data->SMSStatus->PhoneSize = 0;
495  Data->SMSStatus->TemplatesUsed = 0;
496  return ERR_NONE;
497  case 0x38:
498  smprintf(s, "Error. No PIN ?\n");
499  return ERR_SECURITYERROR;
500  }
501  return ERR_UNKNOWNRESPONSE;
502 }
503 
504 GSM_Error N6110_ReplyGetSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
505 {
506  GSM_Phone_Data *Data = &s->Phone.Data;
507 
508  smprintf(s, "SMS Message received\n");
509  switch(msg->Buffer[3]) {
510  case 0x08:
512  Data->GetSMSMessage->Number = 1;
513  Data->GetSMSMessage->SMS[0].Name[0] = 0;
514  Data->GetSMSMessage->SMS[0].Name[1] = 0;
515  Data->GetSMSMessage->SMS[0].Memory = MEM_SM;
516  NOKIA_DecodeSMSState(s, msg->Buffer[4], &Data->GetSMSMessage->SMS[0]);
517  switch (msg->Buffer[7]) {
518  case 0x00: case 0x01: /* Report or SMS_Deliver */
519  Data->GetSMSMessage->SMS[0].Folder = 0x01;
520  Data->GetSMSMessage->SMS[0].InboxFolder = TRUE;
521  break;
522  case 0x02: /* SMS_Submit */
523  Data->GetSMSMessage->SMS[0].Folder = 0x02;
524  Data->GetSMSMessage->SMS[0].InboxFolder = FALSE;
525  break;
526  default:
527  return ERR_UNKNOWNRESPONSE;
528  }
529  return DCT3_DecodeSMSFrame(s, &Data->GetSMSMessage->SMS[0],msg->Buffer+8);
530  case 0x09:
531  switch (msg->Buffer[4]) {
532  case 0x00:
533  smprintf(s, "Unknown. Probably phone too busy\n");
534  return ERR_UNKNOWN;
535  case 0x02:
536  smprintf(s, "Too high location ?\n");
537  return ERR_INVALIDLOCATION;
538  case 0x06:
539  smprintf(s, "Phone is OFF\n");
540  return ERR_PHONEOFF;
541  case 0x07:
542  smprintf(s, "Empty\n");
543  return ERR_EMPTY;
544  case 0x0c:
545  smprintf(s, "Access error. No PIN ?\n");
546  return ERR_SECURITYERROR;
547  default:
548  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
549  }
550  }
551  return ERR_UNKNOWNRESPONSE;
552 }
553 
554 static GSM_Error N6110_GetSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
555 {
556  unsigned char req[] = {N6110_FRAME_HEADER, 0x07, 0x02,
557  0x00, /* Location */
558  0x01, 0x64};
559 
560  if (sms->SMS[0].Folder!=0x00) return ERR_NOTSUPPORTED;
561 
562  req[5] = sms->SMS[0].Location;
563 
564  s->Phone.Data.GetSMSMessage=sms;
565  smprintf(s, "Getting sms\n");
566  return GSM_WaitFor (s, req, 8, 0x02, 4, ID_GetSMSMessage);
567 }
568 
569 static GSM_Error N6110_GetNextSMSMessage(GSM_StateMachine *s, GSM_MultiSMSMessage *sms, gboolean start)
570 {
571  GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
572  GSM_Error error;
573 
574  if (start) {
575  error=s->Phone.Functions->GetSMSStatus(s,&Priv->LastSMSStatus);
576  if (error!=ERR_NONE) return error;
577  Priv->LastSMSRead=0;
578  sms->SMS[0].Location=0;
579  }
580  while (TRUE) {
581  sms->SMS[0].Location++;
583  error=s->Phone.Functions->GetSMS(s, sms);
584  if (error==ERR_NONE) {
585  Priv->LastSMSRead++;
586  break;
587  }
588  if (error != ERR_EMPTY) return error;
589  }
590  return error;
591 }
592 
593 static GSM_Error N6110_ReplyGetStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
594 {
595  GSM_Phone_Data *Data = &s->Phone.Data;
596 
597 #ifdef DEBUG
598  smprintf(s, "Phone status received :\n");
599  smprintf(s, "Mode : ");
600  switch (msg->Buffer[4]) {
601  case 0x01: smprintf(s, "registered within the network\n"); break;
602  case 0x02: smprintf(s, "call in progress\n"); break; /* ringing or already answered call */
603  case 0x03: smprintf(s, "waiting for security code\n"); break;
604  case 0x04: smprintf(s, "powered off\n"); break;
605  default : smprintf(s, "unknown\n");
606  }
607  smprintf(s, "Power source : ");
608  switch (msg->Buffer[7]) {
609  case 0x01: smprintf(s, "AC/DC\n"); break;
610  case 0x02: smprintf(s, "battery\n"); break;
611  default : smprintf(s, "unknown\n");
612  }
613  smprintf(s, "Battery Level : %d\n", msg->Buffer[8]);
614  smprintf(s, "Signal strength : %d\n", msg->Buffer[5]);
615 #endif
616 
617  switch (Data->RequestID) {
618  case ID_GetBatteryCharge:
619  Data->BatteryCharge->BatteryPercent = ((int)msg->Buffer[8])*25;
620  switch (msg->Buffer[7]) {
621  case 0x01: Data->BatteryCharge->ChargeState = GSM_BatteryConnected; break;
622  case 0x02: Data->BatteryCharge->ChargeState = GSM_BatteryPowered; break;
623  default : Data->BatteryCharge->ChargeState = 0;
624  }
625  return ERR_NONE;
626  case ID_GetSignalQuality:
627  Data->SignalQuality->SignalPercent = ((int)msg->Buffer[5])*25;
628  return ERR_NONE;
629  default:
630  return ERR_UNKNOWNRESPONSE;
631  }
632 }
633 
634 static GSM_Error N6110_GetStatus(GSM_StateMachine *s, int ID)
635 {
636  unsigned char req[] = {N6110_FRAME_HEADER, 0x01};
637 
638  return GSM_WaitFor (s, req, 4, 0x04, 4, ID);
639 }
640 
641 static GSM_Error N6110_GetSignalQuality(GSM_StateMachine *s, GSM_SignalQuality *sig)
642 {
643  char value[100];
644  GSM_Error error;
645 
646  sig->BitErrorRate = -1;
647  sig->SignalStrength = -1; /* TODO for netmon */
648 
649  smprintf(s, "Getting network level\n");
651  error = DCT3_Netmonitor(s, 1, value);
652  if (error!=ERR_NONE) return error;
653  sig->SignalPercent = 100;
654  if (value[4]!='-') {
655  if (value[5]=='9' && value[6]>'4') sig->SignalPercent = 25;
656  if (value[5]=='9' && value[6]<'5') sig->SignalPercent = 50;
657  if (value[5]=='8' && value[6]>'4') sig->SignalPercent = 75;
658  } else sig->SignalPercent = 0;
659  return ERR_NONE;
660  } else {
661  s->Phone.Data.SignalQuality = sig;
662  return N6110_GetStatus(s, ID_GetSignalQuality);
663  }
664 }
665 
666 static GSM_Error N6110_GetBatteryCharge(GSM_StateMachine *s, GSM_BatteryCharge *bat)
667 {
668  char value[100];
669  GSM_Error error;
670 
671  smprintf(s, "Getting battery level\n");
674  error = DCT3_Netmonitor(s, 23, value);
675  if (error!=ERR_NONE) return error;
676  bat->BatteryPercent = 100;
677  bat->ChargeState = 0;
678  if (value[29]=='7') bat->BatteryPercent = 75;
679  if (value[29]=='5') bat->BatteryPercent = 50;
680  if (value[29]=='2') bat->BatteryPercent = 25;
681  return ERR_NONE;
682  } else {
683  s->Phone.Data.BatteryCharge = bat;
684  return N6110_GetStatus(s, ID_GetBatteryCharge);
685  }
686 }
687 
688 static GSM_Error N6110_ReplySaveSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
689 {
690  GSM_Phone_Data *Data = &s->Phone.Data;
691 
692  smprintf(s, "SMS message saving status\n");
693  switch (msg->Buffer[3]) {
694  case 0x05:
695  smprintf(s, "Saved at location %i\n",msg->Buffer[5]);
696  Data->SaveSMSMessage->Location=msg->Buffer[5];
697  return ERR_NONE;
698  case 0x06:
699  switch (msg->Buffer[4]) {
700  case 0x02:
701  smprintf(s, "All locations busy\n");
702  return ERR_FULL;
703  case 0x03:
704  smprintf(s, "Too high ?\n");
705  return ERR_INVALIDLOCATION;
706  default:
707  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
708  }
709  }
710  return ERR_UNKNOWNRESPONSE;
711 }
712 
713 static GSM_Error N6110_PrivSetSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
714 {
715  int length;
716  GSM_Error error;
717  unsigned char req[256] = {N6110_FRAME_HEADER, 0x04,
718  0x00, /* SMS status */
719  0x02,
720  0x00, /* SMS location */
721  0x02}; /* SMS type */
722 
723  req[6] = sms->Location;
724  if (sms->Folder==1) { /* Inbox */
725  req[4] = 1; /* SMS status - GSM_Read */
726  req[7] = 0x00; /* SMS type */
727  sms->PDU = SMS_Deliver;
728  error=PHONE_EncodeSMSFrame(s,sms,req+8,PHONE_SMSDeliver,&length,TRUE);
729  } else { /* Outbox */
730  req[4] = 5; /* SMS status - GSM_Sent */
731  req[7] = 0x02; /* SMS type */
732  sms->PDU = SMS_Submit;
733  error=PHONE_EncodeSMSFrame(s,sms,req+8,PHONE_SMSSubmit,&length,TRUE);
734  }
735  if (error != ERR_NONE) return error;
736 
737  /* SMS State - GSM_Read -> GSM_Unread and GSM_Sent -> GSM_UnSent */
738  if (sms->State == SMS_UnSent || sms->State == SMS_UnRead) req[4] |= 0x02;
739 
740  sms->Memory = MEM_SM;
741 
742  s->Phone.Data.SaveSMSMessage=sms;
743  smprintf(s, "Saving sms\n");
744  return GSM_WaitFor (s, req, 8+length, 0x14, 4, ID_SaveSMSMessage);
745 }
746 
747 static GSM_Error N6110_SetSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
748 {
749  if (sms->Location == 0) return ERR_INVALIDLOCATION;
750  return N6110_PrivSetSMSMessage(s, sms);
751 }
752 
753 static GSM_Error N6110_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
754 {
755  sms->Location = 0;
756  return N6110_PrivSetSMSMessage(s, sms);
757 }
758 
759 static GSM_Error N6110_ReplySetRingtone(GSM_Protocol_Message *msg, GSM_StateMachine *s)
760 {
761  switch (msg->Buffer[3]) {
762  case 0x37:
763  smprintf(s, "Ringtone set OK\n");
764  return ERR_NONE;
765  case 0x38:
766  smprintf(s, "Error setting ringtone\n");
767  switch (msg->Buffer[4]) {
768  case 0x7d:
769  smprintf(s, "Too high location ?\n");
770  return ERR_INVALIDLOCATION;
771  default:
772  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
773  }
774  }
775  return ERR_UNKNOWNRESPONSE;
776 }
777 
778 static GSM_Error N6110_ReplySetBinRingtone(GSM_Protocol_Message *msg, GSM_StateMachine *s)
779 {
780  switch (msg->Buffer[4]) {
781  case 0x00:
782  smprintf(s, "Set at location %i\n",msg->Buffer[3]+1);
783  return ERR_NONE;
784  default:
785  smprintf(s, "Invalid location. Too high ?\n");
786  return ERR_INVALIDLOCATION;
787  }
788 }
789 
790 static GSM_Error N6110_SetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, int *maxlength)
791 {
792  GSM_NetworkInfo NetInfo;
793  GSM_Error error;
794  size_t size=200,current=8;
795  GSM_UDHHeader UDHHeader;
796  unsigned char req[1000] = {N6110_FRAME_HEADER, 0x36,
797  0x00, /* Location */
798  0x00,0x78};
799  unsigned char reqBin[1000] = {0x00,0x01,0xa0,0x00,0x00,0x0c,0x01,0x2c};
800 
802  if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
803 
804  switch (Ringtone->Format) {
805  case RING_NOTETONE:
806  if (Ringtone->Location==255) {
807  /* Only 6110, 6130 and 6150 support it */
808  if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 ||
809  strcmp(s->Phone.Data.Model,"NSM-1") == 0) {
810  req[0] = 0x0c;
811  req[1] = 0x01;
812  UDHHeader.Type = UDH_NokiaRingtone;
813  GSM_EncodeUDHHeader(&(s->di), &UDHHeader);
814  /* We copy UDH now */
815  memcpy(req+2,UDHHeader.Text,UDHHeader.Length);
816  *maxlength=GSM_EncodeNokiaRTTLRingtone(Ringtone, req+2+UDHHeader.Length, &size);
817  error = s->Protocol.Functions->WriteMessage(s, req, 2+UDHHeader.Length+size, 0x12);
818  if (error!=ERR_NONE) return error;
819  sleep(1);
820  /* We have to make something (not important, what) now */
821  /* no answer from phone*/
822  return DCT3_GetNetworkInfo(s,&NetInfo);
823  } else {
824  return ERR_NOTSUPPORTED;
825  }
826  }
827  *maxlength=GSM_EncodeNokiaRTTLRingtone(Ringtone, req+7, &size);
828  req[4] = Ringtone->Location - 1;
829  smprintf(s, "Setting ringtone\n");
830  return GSM_WaitFor (s, req, 7 + size, 0x05, 4, ID_SetRingtone);
831  case RING_NOKIABINARY:
832  error=DCT3_EnableSecurity (s, 0x01);
833  if (error!=ERR_NONE) return error;
834  memcpy(reqBin+current,DecodeUnicodeString(Ringtone->Name),UnicodeLength(Ringtone->Name));
835  current += UnicodeLength(Ringtone->Name);
836  reqBin[current++] = 0x00;
837  reqBin[current++] = 0x00;
838  reqBin[current++] = 0x00;/*xxx*/
839  memcpy(reqBin+current,Ringtone->NokiaBinary.Frame,Ringtone->NokiaBinary.Length);
840  current=current+Ringtone->NokiaBinary.Length;
841  reqBin[3]=Ringtone->Location-1;
842  if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) reqBin[5]=0x10;
843  smprintf(s, "Setting binary ringtone\n");
844  return GSM_WaitFor (s, reqBin, current, 0x40, 4, ID_SetRingtone);
845  case RING_MIDI:
846  case RING_MMF:
847  return ERR_NOTSUPPORTED;
848  }
849  return ERR_NOTSUPPORTED;
850 }
851 
852 static GSM_Error N6110_ReplyGetOpLogo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
853 {
854  int count=5;
855  GSM_Phone_Data *Data = &s->Phone.Data;
856 
857  smprintf(s, "Operator logo received\n");
859  count = count + 3;
860  smprintf(s, "Network code : %s\n", Data->Bitmap->NetworkCode);
861  smprintf(s, "Network name for Gammu : %s ",
864 
865  count = count + 3; /* We ignore size */
866  Data->Bitmap->BitmapWidth = msg->Buffer[count++];
867  Data->Bitmap->BitmapHeight = msg->Buffer[count++];
868  count++;
870  return ERR_NONE;
871 }
872 
873 static GSM_Error N6110_ReplyGetStartup(GSM_Protocol_Message *msg, GSM_StateMachine *s)
874 {
875  int i, count = 5;
876  GSM_Phone_Data *Data = &s->Phone.Data;
877 
878  smprintf(s, "Startup logo & notes received\n");
879  for (i=0;i<msg->Buffer[4];i++) {
880  switch (msg->Buffer[count++]) {
881  case 0x01:
882  smprintf(s, "Startup logo\n");
883  if (Data->Bitmap->Type == GSM_StartupLogo) {
884  Data->Bitmap->BitmapHeight = msg->Buffer[count++];
885  Data->Bitmap->BitmapWidth = msg->Buffer[count++];
887  } else {
888  count = count + 2;
889  }
890  count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0);
891  break;
892  case 0x02:
893  smprintf(s, "Welcome note\n");
894  if (Data->Bitmap->Type == GSM_WelcomeNote_Text) {
895  EncodeUnicode(Data->Bitmap->Text,msg->Buffer+count, msg->Buffer[count]);
896  smprintf(s, "Text is \"%s\"\n",Data->Bitmap->Text);
897  }
898  count = count + msg->Buffer[count] + 1;
899  break;
900  case 0x03:
901  smprintf(s, "Dealer welcome note\n");
902  if (Data->Bitmap->Type == GSM_DealerNote_Text) {
903  EncodeUnicode(Data->Bitmap->Text,msg->Buffer+count, msg->Buffer[count]);
904  smprintf(s, "Text is \"%s\"\n",Data->Bitmap->Text);
905  }
906  count = count + msg->Buffer[count] + 1;
907  break;
908  default:
909  smprintf(s, "Unknown block\n");
910  return ERR_UNKNOWNRESPONSE;
911  }
912  }
913  return ERR_NONE;
914 }
915 
916 static GSM_Error N6110_ReplyGetCallerLogo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
917 {
918  int count;
919  GSM_Phone_Data *Data = &s->Phone.Data;
920 
921  switch (msg->Buffer[3]) {
922  case 0x11:
923  smprintf(s, "Caller group info received\n");
924  EncodeUnicode(Data->Bitmap->Text,msg->Buffer+6,msg->Buffer[5]);
925  smprintf(s, "Name : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
926  Data->Bitmap->DefaultName = FALSE;
927  if (msg->Buffer[5] == 0x00) Data->Bitmap->DefaultName = TRUE;
928  count = msg->Buffer[5] + 6;
929  Data->Bitmap->RingtoneID = msg->Buffer[count++];
930  Data->Bitmap->DefaultRingtone = FALSE;
931  Data->Bitmap->FileSystemPicture = FALSE;
933  if (Data->Bitmap->RingtoneID == 16) Data->Bitmap->DefaultRingtone = TRUE;
934  smprintf(s, "Ringtone ID: %02x\n",Data->Bitmap->RingtoneID);
935  Data->Bitmap->BitmapEnabled=(msg->Buffer[count++]==1);
936 #ifdef DEBUG
937  smprintf(s, "Caller group logo ");
938  if (Data->Bitmap->BitmapEnabled) {
939  smprintf(s, "enabled\n");
940  } else {
941  smprintf(s, "disabled\n");
942  }
943 #endif
944  count = count + 3; /* We ignore size */
945  Data->Bitmap->BitmapWidth = msg->Buffer[count++];
946  Data->Bitmap->BitmapHeight = msg->Buffer[count++];
947  count++;
949  Data->Bitmap->DefaultBitmap = FALSE;
950  return ERR_NONE;
951  case 0x12:
952  smprintf(s, "Error getting caller group info\n");
953  return ERR_INVALIDLOCATION;
954  }
955  return ERR_UNKNOWNRESPONSE;
956 }
957 
958 static GSM_Error N6110_ReplyGetSetPicture(GSM_Protocol_Message *msg, GSM_StateMachine *s)
959 {
960  int count = 5, i;
961  GSM_Phone_Data *Data = &s->Phone.Data;
962  GSM_Error error;
963  size_t pos;
964 
965  switch (msg->Buffer[3]) {
966  case 0x02:
967  smprintf(s, "Picture Image received\n");
968  if (msg->Buffer[count]!=0) {
969  pos = 5;
970  error = GSM_UnpackSemiOctetNumber(&(s->di), Data->Bitmap->Sender, msg->Buffer, &pos, msg->Length, TRUE);
971  if (error != ERR_NONE) {
972  return error;
973  }
974  /* Convert number of semioctets to number of chars */
975  i = msg->Buffer[5];
976  if (i % 2) i++;
977  i=i / 2 + 1;
978  count = count + i + 1;
979  } else {
980  Data->Bitmap->Sender[0] = 0x00;
981  Data->Bitmap->Sender[1] = 0x00;
982  count+=2;
983  }
984  smprintf(s, "Sender : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Sender));
986  (!strcmp(Data->Model,"NHM-5") && Data->VerNum < 5.79)) {
987  count++;
988  EncodeUnicode(Data->Bitmap->Text,msg->Buffer+count+1,msg->Buffer[count]);
989  count += UnicodeLength(Data->Bitmap->Text) + 1;
990  } else {
991  if (!strcmp(Data->Model,"NHM-5")) {
992  i = msg->Buffer[count] * 256 + msg->Buffer[count+1];
993  } else {
994  /* 3410 4.26 */
995  i = msg->Buffer[count] * 256 + msg->Buffer[count+1] - 2;
996  count += 2;
997  }
998  memcpy(Data->Bitmap->Text,msg->Buffer+count+2,i);
999  Data->Bitmap->Text[i] = 0;
1000  Data->Bitmap->Text[i+1] = 0;
1001  count += i + 2;
1002  }
1003  smprintf(s, "Text : \"%s\"\n",DecodeUnicodeString(Data->Bitmap->Text));
1004  Data->Bitmap->BitmapWidth = msg->Buffer[count++];
1005  Data->Bitmap->BitmapHeight = msg->Buffer[count++];
1006  PHONE_DecodeBitmap(GSM_NokiaPictureImage, msg->Buffer + count + 2, Data->Bitmap);
1007 #ifdef DEBUG
1010 #endif
1011  return ERR_NONE;
1012  case 0x04:
1013  smprintf(s, "Picture Image set OK\n");
1014  return ERR_NONE;
1015  case 0x05:
1016  smprintf(s, "Can't set Picture Image - invalid location ?\n");
1017  return ERR_INVALIDLOCATION;
1018  case 0x06:
1019  smprintf(s, "Can't get Picture Image - invalid location ?\n");
1020  return ERR_INVALIDLOCATION;
1021  }
1022  return ERR_UNKNOWNRESPONSE;
1023 }
1024 
1025 static GSM_Error N6110_GetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1026 {
1027  GSM_Error error;
1028  unsigned char req[10] = {N6110_FRAME_HEADER};
1029 
1030  s->Phone.Data.Bitmap=Bitmap;
1031  switch (Bitmap->Type) {
1032  case GSM_StartupLogo:
1033  case GSM_WelcomeNote_Text:
1034  case GSM_DealerNote_Text:
1036  req[3] = 0x16;
1037  return GSM_WaitFor (s, req, 4, 0x05, 4, ID_GetBitmap);
1038  case GSM_CallerGroupLogo:
1040  req[3] = 0x10;
1041  req[4] = Bitmap->Location - 1;
1042  error = GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetBitmap);
1043  if (error==ERR_NONE) NOKIA_GetDefaultCallerGroupName(Bitmap);
1044  return error;
1045  case GSM_OperatorLogo:
1046  req[3] = 0x33;
1047  req[4] = 0x01;
1048  return GSM_WaitFor (s, req, 5, 0x05, 4, ID_GetBitmap);
1049  case GSM_PictureImage:
1051  req[3] = 0x01;
1052  req[4] = Bitmap->Location - 1;
1053  return GSM_WaitFor (s, req, 5, 0x47, 4, ID_GetBitmap);
1054  default:
1055  break;
1056  }
1057  return ERR_NOTSUPPORTED;
1058 }
1059 
1060 static GSM_Error N6110_ReplySetProfileFeature(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1061 {
1062  switch (msg->Buffer[3]) {
1063  case 0x11:
1064  smprintf(s, "Feature of profile set\n");
1065  return ERR_NONE;
1066  case 0x12:
1067  smprintf(s, "Error setting profile feature\n");
1068  return ERR_NOTSUPPORTED;
1069  }
1070  return ERR_UNKNOWNRESPONSE;
1071 }
1072 
1073 static GSM_Error N6110_SetProfileFeature(GSM_StateMachine *s, unsigned char profile, unsigned char feature, unsigned char value)
1074 {
1075  unsigned char req[] = {N6110_FRAME_HEADER, 0x10, 0x01,
1076  0x00, /* Profile */
1077  0x00, /* Feature */
1078  0x00}; /* Value */
1079 
1080  req[5]=profile;
1081  req[6]=feature;
1082  req[7]=value;
1083  smprintf(s, "Setting profile feature\n");
1084  return GSM_WaitFor (s, req, 8, 0x05, 4, ID_SetProfile);
1085 }
1086 
1087 static GSM_Error N6110_ReplySetStartup(GSM_Protocol_Message *msg UNUSED, GSM_StateMachine *s)
1088 {
1089  smprintf(s, "Startup logo set OK\n");
1090  return ERR_NONE;
1091 }
1092 
1093 static GSM_Error N6110_ReplySetCallerLogo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1094 {
1095  switch (msg->Buffer[3]) {
1096  case 0x14:
1097  smprintf(s, "Caller group set OK\n");
1098  return ERR_NONE;
1099  case 0x15:
1100  smprintf(s, "Error setting caller group\n");
1101  return ERR_INVALIDLOCATION;
1102  }
1103  return ERR_UNKNOWNRESPONSE;
1104 }
1105 
1106 static GSM_Error N6110_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
1107 {
1108  unsigned char reqPreview[1000] = {0x0c,0x01};
1109  unsigned char req[600] = {N6110_FRAME_HEADER};
1110  GSM_UDH UDHType = UDH_NokiaOperatorLogo;
1111  size_t count = 0, textlen, Width, Height;
1112  GSM_UDHHeader UDHHeader;
1113  GSM_NetworkInfo NetInfo;
1114  GSM_Error error;
1115 
1116  switch (Bitmap->Type) {
1117  case GSM_CallerGroupLogo:
1118  case GSM_OperatorLogo:
1119  if (Bitmap->Location == 255) {
1120  /* Only 6110, 6130 and 6150 support it */
1121  if (strcmp(s->Phone.Data.Model,"NSE-3") == 0 || strcmp(s->Phone.Data.Model,"NSK-3") == 0 ||
1122  strcmp(s->Phone.Data.Model,"NSM-1") == 0) {
1123  if (Bitmap->Type==GSM_CallerGroupLogo) UDHType = UDH_NokiaCallerLogo;
1124  UDHHeader.Type = UDHType;
1125  GSM_EncodeUDHHeader(&(s->di), &UDHHeader);
1126  /* We copy UDH now */
1127  memcpy(reqPreview+2,UDHHeader.Text,UDHHeader.Length);
1128  count = count + UDHHeader.Length;
1129  if (Bitmap->Type == GSM_OperatorLogo) {
1130  NOKIA_EncodeNetworkCode(reqPreview+count,Bitmap->NetworkCode);
1131  count = count + 3;
1132  } else {
1133  if (Bitmap->DefaultBitmap) {
1134  Bitmap->BitmapWidth = 72;
1135  Bitmap->BitmapHeight = 14;
1136  GSM_ClearBitmap(Bitmap);
1137  }
1138  }
1139  NOKIA_CopyBitmap(GSM_NokiaOperatorLogo,Bitmap,reqPreview, &count);
1140  reqPreview[count]=0x00;
1141  error = s->Protocol.Functions->WriteMessage(s, reqPreview, count + 1, 0x12);
1142  if (error!=ERR_NONE) return error;
1143  sleep(1);
1144  /* We have to make something (not important, what) now */
1145  /* no answer from phone*/
1146  return DCT3_GetNetworkInfo(s,&NetInfo);
1147  } else {
1148  smprintf(s, "%s\n",s->Phone.Data.Model);
1149  return ERR_NOTSUPPORTED;
1150  }
1151  }
1152  break;
1153  default:
1154  break;
1155  }
1156 
1157  count = 3;
1158 
1159  switch (Bitmap->Type) {
1160  case GSM_StartupLogo:
1162  if (Bitmap->Location != 1) {
1164  }
1166  if (!strcmp(s->Phone.Data.ModelInfo->model,"3210")) {
1167  error = N6110_SetProfileFeature(s,0,0x2e,((unsigned char)(Bitmap->Location-1)));
1168  } else {
1169  error = N6110_SetProfileFeature(s,0,0x29,((unsigned char)(Bitmap->Location-1)));
1170  }
1171  if (error == ERR_NOTSUPPORTED) error = ERR_SECURITYERROR;
1172  if (error != ERR_NONE) return error;
1173  if (Bitmap->Location != 1) return ERR_NONE;
1174  }
1175  req[count++] = 0x18;
1176  req[count++] = 0x01; /* One block */
1177  req[count++] = 0x01;
1179  req[count++] = Height;
1180  req[count++] = Width;
1181  PHONE_EncodeBitmap(GSM_NokiaStartupLogo, req + count, Bitmap);
1182  count = count + PHONE_GetBitmapSize(GSM_NokiaStartupLogo,0,0);
1183  return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
1184  case GSM_WelcomeNote_Text:
1185  case GSM_DealerNote_Text:
1186  req[count++] = 0x18;
1187  req[count++] = 0x01; /* One block */
1188  if (Bitmap->Type == GSM_WelcomeNote_Text) {
1189  req[count++] = 0x02;
1190  } else {
1191  req[count++] = 0x03;
1192  }
1193  textlen = UnicodeLength(Bitmap->Text);
1194  req[count++] = textlen;
1195  memcpy(req + count,DecodeUnicodeString(Bitmap->Text),textlen);
1196  count += textlen;
1197  return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
1198  case GSM_CallerGroupLogo:
1200  req[count++] = 0x13;
1201  req[count++] = Bitmap->Location - 1;
1202  if (Bitmap->DefaultName) {
1203  req[count++] = 0;
1204  } else {
1205  textlen = UnicodeLength(Bitmap->Text);
1206  req[count++] = textlen;
1207  memcpy(req+count,DecodeUnicodeString(Bitmap->Text),textlen);
1208  count += textlen;
1209  }
1210  if (Bitmap->DefaultRingtone) {
1211  req[count++] = 16;
1212  } else {
1213  req[count++] = Bitmap->RingtoneID;
1214  }
1215  /* Value here is number of phone menu connected
1216  * with caller logo in Nokia 61x0: 0x00 = Off, 0x01 = On,
1217  * 0x02 = View Graphics, 0x03 = Send Graphics,
1218  * 0x04 = Send via IR. For higher menu option connected with
1219  * caller logo is not displayed
1220  */
1221  if (Bitmap->DefaultBitmap) {
1222  Bitmap->BitmapWidth = 72;
1223  Bitmap->BitmapHeight = 14;
1224  GSM_ClearBitmap(Bitmap);
1225  req[count++] = 0;
1226  } else {
1227  if (Bitmap->BitmapEnabled) req[count++] = 0x01; else req[count++] = 0x00;
1228  }
1229  req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) / 256;
1230  req[count++] = (PHONE_GetBitmapSize(GSM_NokiaCallerLogo,0,0) + 4) % 256;
1231  NOKIA_CopyBitmap(GSM_NokiaCallerLogo, Bitmap, req, &count);
1232  return GSM_WaitFor (s, req, count, 0x03, 4, ID_SetBitmap);
1233  case GSM_OperatorLogo:
1234  req[count++] = 0x30;
1235  req[count++] = 0x01;
1236  NOKIA_EncodeNetworkCode(req+count, Bitmap->NetworkCode);
1237  count = count + 3;
1238  req[count++] = (PHONE_GetBitmapSize(GSM_NokiaOperatorLogo,0,0) + 4) / 256;
1239  req[count++] = (PHONE_GetBitmapSize(GSM_NokiaOperatorLogo,0,0) + 4) % 256;
1240  NOKIA_CopyBitmap(GSM_NokiaOperatorLogo, Bitmap, req, &count);
1241  return GSM_WaitFor (s, req, count, 0x05, 4, ID_SetBitmap);
1242  case GSM_PictureImage:
1244  req[count++] = 0x03;
1245  req[count++] = Bitmap->Location - 1;
1246  if (Bitmap->Sender[0]!=0 || Bitmap->Sender[1]!=0) {
1247  req[count]=GSM_PackSemiOctetNumber(Bitmap->Sender, req+count+1,TRUE);
1248  /* Convert number of semioctets to number of chars and add count */
1249  textlen = req[count];
1250  if (textlen % 2) textlen++;
1251  count += textlen / 2 + 1;
1252  count++;
1253  } else {
1254  req[count++] = 0x00;
1255  req[count++] = 0x00;
1256  }
1257  req[count++] = 0x00;
1259  (!strcmp(s->Phone.Data.Model,"NHM-5") && s->Phone.Data.VerNum < 5.79)) {
1260  textlen = UnicodeLength(Bitmap->Text);
1261  req[count++] = textlen;
1262  memcpy(req+count,DecodeUnicodeString(Bitmap->Text),textlen);
1263  count += textlen;
1264  } else {
1265  textlen = UnicodeLength(Bitmap->Text)*2;
1266  if (!strcmp(s->Phone.Data.Model,"NHM-5")) {
1267  req[count++] = textlen;
1268  } else {
1269  /* 3410 4.26 */
1270  req[count++] = textlen+2;
1271  req[count++] = 0x00;
1272  req[count++] = 0x1e;
1273  }
1274  memcpy(req+count,Bitmap->Text,textlen);
1275  count += textlen;
1276  }
1277  NOKIA_CopyBitmap(GSM_NokiaPictureImage, Bitmap, req, &count);
1278  return GSM_WaitFor (s, req, count, 0x47, 4, ID_SetBitmap);
1279  default:
1280  break;
1281  }
1282  return ERR_NOTSUPPORTED;
1283 }
1284 
1285 static GSM_Error N6110_ReplyCallInfo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1286 {
1287  GSM_Phone_Data *Data = &s->Phone.Data;
1288  int tmp, count;
1289  GSM_Call call;
1290 
1291  call.CallIDAvailable = TRUE;
1292  call.Status = 0;
1293  smprintf(s, "Call info, ");
1294  switch (msg->Buffer[3]) {
1295  case 0x02:
1296  smprintf(s, "Call established, waiting for answer\n");
1298  break;
1299  case 0x03:
1300  smprintf(s, "Call started\n");
1301  /* no phone number in frame */
1302  call.Status = GSM_CALL_CallStart;
1303  break;
1304  case 0x04:
1305  smprintf(s, "Remote end hang up\n");
1306  smprintf(s, "CC : %i\n",msg->Buffer[6]);
1308  call.StatusCode = msg->Buffer[6];
1309  break;
1310  case 0x05:
1311  smprintf(s, "Incoming call\n");
1312  smprintf(s, "Number : \"");
1313  count=msg->Buffer[6];
1314  for (tmp=0; tmp <count; tmp++) smprintf(s, "%c", msg->Buffer[7+tmp]);
1315  smprintf(s, "\"\nName : \"");
1316  for (tmp=0; tmp<msg->Buffer[7+count]; tmp++) smprintf(s, "%c", msg->Buffer[8+count+tmp]);
1317  smprintf(s, "\"\n");
1318 
1320  EncodeUnicode(call.PhoneNumber, msg->Buffer+7, msg->Buffer[6]);
1321  break;
1322  case 0x07:
1323  smprintf(s, "Call answer initiated\n");
1324  break;
1325  case 0x09:
1326  smprintf(s, "Call released\n");
1328  break;
1329  case 0x0a:
1330  smprintf(s, "Call is being released\n");
1331  break;
1332  case 0x23:
1333  smprintf(s, "Call held\n");
1334  call.Status = GSM_CALL_CallHeld;
1335  break;
1336  case 0x25:
1337  smprintf(s, "Call resumed\n");
1339  break;
1340  case 0x27:
1341  smprintf(s, "Call switched\n");
1342  /* incorrect call id in frame - 6150 5.22 */
1343  call.CallIDAvailable = FALSE;
1345  break;
1346  case 0x29:
1347  smprintf(s, "Joining call to the conference (conference)\n");
1348  break;
1349  case 0x2A:
1350  smprintf(s, "Removing call from the conference (split)\n");
1351  break;
1352  }
1353  if (call.CallIDAvailable) smprintf(s, "Call ID : %d\n",msg->Buffer[4]);
1354  if (Data->EnableIncomingCall && s->User.IncomingCall!=NULL && call.Status != 0) {
1355  if (call.CallIDAvailable) call.CallID = msg->Buffer[4];
1356  s->User.IncomingCall(s, &call, s->User.IncomingCallUserData);
1357  }
1358  if (s->Phone.Data.RequestID == ID_CancelCall) {
1359  if (msg->Buffer[3] == 0x09) {
1360  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1361  /* when we canceled call and see frame about other
1362  * call releasing, we don't give ERR_NONE for "our"
1363  * call release command
1364  */
1365  return ERR_NEEDANOTHERANSWER;
1366  }
1367  }
1368  if (s->Phone.Data.RequestID == ID_AnswerCall) {
1369  if (msg->Buffer[3] == 0x07) {
1370  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1371  return ERR_NEEDANOTHERANSWER;
1372  }
1373  }
1374  if (s->Phone.Data.RequestID == ID_UnholdCall) {
1375  if (msg->Buffer[3] == 0x25) {
1376  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1377  return ERR_NEEDANOTHERANSWER;
1378  }
1379  }
1380  if (s->Phone.Data.RequestID == ID_HoldCall) {
1381  if (msg->Buffer[3] == 0x23) {
1382  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1383  return ERR_NEEDANOTHERANSWER;
1384  }
1385  }
1386  if (s->Phone.Data.RequestID == ID_ConferenceCall) {
1387  if (msg->Buffer[3] == 0x29) {
1388  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1389  return ERR_NEEDANOTHERANSWER;
1390  }
1391  }
1392  if (s->Phone.Data.RequestID == ID_SplitCall) {
1393  if (msg->Buffer[3] == 0x2B) {
1394  if (s->Phone.Data.CallID == msg->Buffer[4]) return ERR_NONE;
1395  return ERR_NEEDANOTHERANSWER;
1396  }
1397  }
1398  return ERR_NONE;
1399 }
1400 
1401 static GSM_Error N6110_DeleteSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
1402 {
1403  unsigned char req[] = {N6110_FRAME_HEADER, 0x0a, 0x02,
1404  0x00}; /* Location */
1405 
1406  if (sms->Folder!=0x00) return ERR_NOTSUPPORTED;
1407 
1408  req[5]=sms->Location;
1409 
1410  smprintf(s, "Deleting sms\n");
1411  return GSM_WaitFor (s, req, 6, 0x14, 4, ID_DeleteSMSMessage);
1412 }
1413 
1414 static GSM_Error N6110_ReplySetMemory(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1415 {
1416  smprintf(s, "Reply for writing memory\n");
1417  switch (msg->Buffer[3]) {
1418  case 0x05:
1419  smprintf(s, "Done OK\n");
1420  return ERR_NONE;
1421  case 0x06:
1422  smprintf(s, "Error\n");
1423  switch (msg->Buffer[4]) {
1424  case 0x7d:
1425  smprintf(s, "Too high location ?\n");
1426  return ERR_INVALIDLOCATION;
1427  case 0x90:
1428  smprintf(s, "Too long name...or other error\n");
1429  return ERR_NOTSUPPORTED;
1430  default:
1431  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
1432  }
1433  }
1434  return ERR_UNKNOWNRESPONSE;
1435 }
1436 
1437 static GSM_Error N6110_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1438 {
1439  int current, Group, Name, Number, i;
1440  unsigned char req[128] = {N6110_FRAME_HEADER, 0x04,
1441  0x00, /* memory type */
1442  0x00}; /* location */
1443 
1444  if (entry->Location == 0) return ERR_NOTSUPPORTED;
1445  if (entry->Location > 255) return ERR_INVALIDLOCATION;
1446 
1447  GSM_PhonebookFindDefaultNameNumberGroup(entry, &Name, &Number, &Group);
1448 
1449  req[4] = NOKIA_GetMemoryType(s, entry->MemoryType,N6110_MEMORY_TYPES);
1450  req[5] = entry->Location;
1451 
1452  current = 7;
1453 
1454  for (i=0;i<entry->EntriesNum;i++) {
1455  entry->Entries[i].AddError = ERR_NOTSUPPORTED;
1456  }
1457 
1459  if (Name != -1) {
1460  req[6] = UnicodeLength(entry->Entries[Name].Text);
1461  memcpy(req+current,DecodeUnicodeString(entry->Entries[Name].Text),UnicodeLength(entry->Entries[Name].Text));
1462  current += UnicodeLength(entry->Entries[Name].Text);
1463  entry->Entries[Name].AddError = ERR_NONE;
1464  } else req[6] = 0;
1465  } else {
1466  if (Name != -1) {
1467  req[6] = UnicodeLength(entry->Entries[Name].Text)*2+2;
1468  memcpy(req+current,entry->Entries[Name].Text,UnicodeLength(entry->Entries[Name].Text)*2);
1469  current += UnicodeLength(entry->Entries[Name].Text)*2;
1470  entry->Entries[Name].AddError = ERR_NONE;
1471  } else req[6] = 0;
1472  req[current++]=0x00;
1473  req[current++]=0x00;
1474  }
1475 
1476  if (Number != -1) {
1477  req[current++]=UnicodeLength(entry->Entries[Number].Text);
1478  memcpy(req+current,DecodeUnicodeString(entry->Entries[Number].Text),UnicodeLength(entry->Entries[Number].Text));
1479  current += UnicodeLength(entry->Entries[Number].Text);
1480  entry->Entries[Number].AddError = ERR_NONE;
1481  } else req[current++] = 0;
1482 
1483  /* This allow to save 14 characters name into SIM memory, when
1484  * no caller group is selected. */
1485  if (Group == -1) {
1486  req[current++] = 0xff;
1487  } else {
1488  req[current++] = entry->Entries[Group].Number-1;
1489  entry->Entries[Group].AddError = ERR_NONE;
1490  }
1491 
1492  smprintf(s, "Writing phonebook entry\n");
1493  return GSM_WaitFor (s, req, current, 0x03, 4, ID_SetMemory);
1494 }
1495 
1496 static GSM_Error N6110_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
1497 {
1498  GSM_MemoryEntry dwa;
1499 
1500  dwa.Location = entry->Location;
1501  dwa.MemoryType = entry->MemoryType;
1502  dwa.EntriesNum = 0;
1503 
1504  return N6110_SetMemory(s, &dwa);
1505 }
1506 
1507 GSM_Error N6110_ReplyGetRingtone(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1508 {
1509  GSM_Phone_Data *Data = &s->Phone.Data;
1510  char buffer[2000];
1511  GSM_Error error;
1512  size_t i,end,start;
1513 
1514  smprintf(s, "Ringtone received\n");
1515  switch (msg->Buffer[4]) {
1516  case 0x00:
1517  switch (Data->Ringtone->Format) {
1518  case RING_NOTETONE:
1519  memcpy(buffer,msg->Buffer,msg->Length);
1520  i=7;
1521  if (buffer[9]==0x4a && buffer[10]==0x3a) i=8;
1522  buffer[i]=0x02;
1523  error=GSM_DecodeNokiaRTTLRingtone(Data->Ringtone, buffer+i, msg->Length-i);
1524  if (error!=ERR_NONE) return ERR_EMPTY;
1525  return ERR_NONE;
1526  case RING_NOKIABINARY:
1527  i=8;
1528  while (msg->Buffer[i]!=0) {
1529  i++;
1530  if (i >= GSM_MAX_RINGTONE_NAME_LENGTH) {
1531  smprintf(s, "Ringtone name too long!\n");
1532  return ERR_MOREMEMORY;
1533  }
1534  if (i > msg->Length) {
1535  return ERR_EMPTY;
1536  }
1537  }
1538  EncodeUnicode(Data->Ringtone->Name,msg->Buffer+8,i-8);
1539  smprintf(s, "Name \"%s\"\n",DecodeUnicodeString(Data->Ringtone->Name));
1540  /* Looking for start && end */
1541  end=0;start=0;i=0;
1542  while (TRUE) {
1543  if (start!=0) {
1544  if (msg->Buffer[i]==0x07 && msg->Buffer[i+1]==0x0b) {
1545  end=i+2; break;
1546  }
1547  if (msg->Buffer[i]==0x0e && msg->Buffer[i+1]==0x0b) {
1548  end=i+2; break;
1549  }
1550  } else {
1551  if (msg->Buffer[i]==0x02 && msg->Buffer[i+1]==0xfc && msg->Buffer[i+2]==0x09) {
1552  start = i;
1553  }
1554  }
1555  i++;
1556  if (i==msg->Length-3) return ERR_EMPTY;
1557  }
1558  /* Copying frame */
1559  memcpy(Data->Ringtone->NokiaBinary.Frame,msg->Buffer+start,end-start);
1560  Data->Ringtone->NokiaBinary.Length=end-start;
1561 #ifdef DEBUG
1562  if (s->di.dl == DL_TEXTALL || s->di.dl == DL_TEXTALLDATE) DumpMessage(&s->di, Data->Ringtone->NokiaBinary.Frame, Data->Ringtone->NokiaBinary.Length);
1563 #endif
1564  return ERR_NONE;
1565  case RING_MIDI:
1566  case RING_MMF:
1567  return ERR_NOTSUPPORTED;
1568  }
1569  smprintf(s, "Ringtone format is %i\n",Data->Ringtone->Format);
1570  break;
1571  default:
1572  smprintf(s, "Invalid location. Too high ?\n");
1573  return ERR_INVALIDLOCATION;
1574  }
1575  return ERR_UNKNOWNRESPONSE;
1576 }
1577 
1578 static GSM_Error N6110_GetRingtone(GSM_StateMachine *s, GSM_Ringtone *Ringtone, gboolean PhoneRingtone)
1579 {
1580  GSM_Error error;
1581  unsigned char req[] = {0x00, 0x01, 0x9e,
1582  0x00}; /* location */
1583 
1584  if (PhoneRingtone) return ERR_NOTSUPPORTED;
1586  if (Ringtone->Location == 0) return ERR_INVALIDLOCATION;
1587 
1588  if (Ringtone->Format == 0x00) {
1590  Ringtone->Format = RING_NOTETONE;
1591  } else {
1592  Ringtone->Format = RING_NOKIABINARY;
1593  }
1594  }
1595 
1596  switch (Ringtone->Format) {
1597  case RING_NOTETONE:
1599  break;
1600  case RING_NOKIABINARY:
1602  break;
1603  case RING_MIDI:
1604  case RING_MMF:
1605  return ERR_NOTSUPPORTED;
1606  }
1607 
1608  error=DCT3_EnableSecurity (s, 0x01);
1609  if (error!=ERR_NONE) return error;
1610 
1611  req[3]=Ringtone->Location-1;
1612  s->Phone.Data.Ringtone=Ringtone;
1613  smprintf(s, "Getting (binary) ringtone\n");
1614  return GSM_WaitFor (s, req, 4, 0x40, 4, ID_GetRingtone);
1615 }
1616 
1617 static GSM_Error N6110_ReplyGetSecurityStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1618 {
1619  *s->Phone.Data.SecurityStatus = msg->Buffer[4];
1620 
1621 #ifdef DEBUG
1622  smprintf(s, "Security code status\n");
1623  switch(msg->Buffer[4]) {
1624  case SEC_SecurityCode: smprintf(s, "waiting for Security Code.\n"); break;
1625  case SEC_Pin : smprintf(s, "waiting for PIN.\n"); break;
1626  case SEC_Pin2 : smprintf(s, "waiting for PIN2.\n"); break;
1627  case SEC_Puk : smprintf(s, "waiting for PUK.\n"); break;
1628  case SEC_Puk2 : smprintf(s, "waiting for PUK2.\n"); break;
1629  case SEC_None : smprintf(s, "nothing to enter.\n"); break;
1630  default : smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
1631  return ERR_UNKNOWNRESPONSE;
1632  }
1633 #endif
1634  return ERR_NONE;
1635 }
1636 
1637 static GSM_Error N6110_GetSecurityStatus(GSM_StateMachine *s, GSM_SecurityCodeType *Status)
1638 {
1639  unsigned char req[4] = {N6110_FRAME_HEADER, 0x07};
1640 
1641  s->Phone.Data.SecurityStatus=Status;
1642  smprintf(s, "Getting security code status\n");
1643  return GSM_WaitFor (s, req, 4, 0x08, 2, ID_GetSecurityStatus);
1644 }
1645 
1646 static GSM_Error N6110_ReplyEnterSecurityCode(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1647 {
1648  switch (msg->Buffer[3]) {
1649  case 0x0b:
1650  smprintf(s, "Security code OK\n");
1651  return ERR_NONE;
1652  case 0x0c:
1653  switch (msg->Buffer[4]) {
1654  case 0x88:
1655  smprintf(s, "Wrong code\n");
1656  return ERR_SECURITYERROR;
1657  case 0x8b:
1658  smprintf(s, "Not required\n");
1659  return ERR_NONE;
1660  default:
1661  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
1662  }
1663  }
1664  return ERR_UNKNOWNRESPONSE;
1665 }
1666 
1667 static GSM_Error N6110_EnterSecurityCode(GSM_StateMachine *s, GSM_SecurityCode *Code)
1668 {
1669  int len = 0;
1670  unsigned char req[15] = {N6110_FRAME_HEADER, 0x0a,
1671  0x00}; /* Type of code to enter */
1672 
1673  req[4]=Code->Type;
1674 
1675  len = strlen(Code->Code);
1676  memcpy(req+5,Code->Code,len);
1677  req[5+len]=0x00;
1678  req[6+len]=0x00;
1679 
1680  smprintf(s, "Entering security code\n");
1681  return GSM_WaitFor (s, req, 7+len, 0x08, 4, ID_EnterSecurityCode);
1682 }
1683 
1684 static GSM_Error N6110_ReplyGetSpeedDial(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1685 {
1686  GSM_Phone_Data *Data = &s->Phone.Data;
1687 
1688  switch (msg->Buffer[3]) {
1689  case 0x17:
1690  smprintf(s, "Speed dial received\n");
1691  switch (msg->Buffer[4]) {
1692  case 0x02:
1693  Data->SpeedDial->MemoryType = MEM_ME;
1694  smprintf(s, "ME ");
1695  break;
1696  case 0x03:
1697  Data->SpeedDial->MemoryType = MEM_SM;
1698  smprintf(s, "SIM ");
1699  break;
1700  default:
1701  smprintf(s, "ERROR: unknown %i\n",msg->Buffer[4]);
1702  return ERR_UNKNOWNRESPONSE;
1703  }
1704  Data->SpeedDial->MemoryLocation = msg->Buffer[5];
1705  if (msg->Buffer[5] == 0x00) Data->SpeedDial->MemoryLocation = Data->SpeedDial->Location;
1706  Data->SpeedDial->MemoryNumberID = 2;
1707  smprintf(s, "location %i\n",Data->SpeedDial->MemoryLocation);
1708  return ERR_NONE;
1709  case 0x18:
1710  smprintf(s, "Error getting speed dial. Invalid location\n");
1711  return ERR_INVALIDLOCATION;
1712  }
1713  return ERR_UNKNOWNRESPONSE;
1714 }
1715 
1716 static GSM_Error N6110_GetSpeedDial(GSM_StateMachine *s, GSM_SpeedDial *SpeedDial)
1717 {
1718  unsigned char req[] = {N6110_FRAME_HEADER, 0x16,
1719  0x01}; /* location */
1720 
1721  req[4] = SpeedDial->Location;
1722 
1723  s->Phone.Data.SpeedDial=SpeedDial;
1724  smprintf(s, "Getting speed dial\n");
1725  return GSM_WaitFor (s, req, 5, 0x03, 4, ID_GetSpeedDial);
1726 }
1727 
1728 static GSM_Error N6110_ReplySendDTMF(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1729 {
1730  switch (msg->Buffer[3]) {
1731  case 0x40:
1732  smprintf(s, "During sending DTMF\n");
1733  return ERR_NONE;
1734  case 0x51:
1735  smprintf(s, "DTMF sent OK\n");
1736  return ERR_NONE;
1737  }
1738  return ERR_UNKNOWNRESPONSE;
1739 }
1740 
1741 static GSM_Error N6110_ReplyGetDisplayStatus(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1742 {
1743  int i;
1744  GSM_Phone_Data *Data = &s->Phone.Data;
1745 
1746  smprintf(s, "Display status received\n");
1747  if (Data->RequestID == ID_GetDisplayStatus) Data->DisplayFeatures->Number=0;
1748  for (i=0;i<msg->Buffer[4];i++) {
1749  if (msg->Buffer[2*i+6] == 0x02) {
1750 #ifdef DEBUG
1751  switch (msg->Buffer[2*i+5]) {
1752  case 0x01: smprintf(s, "Call in progress\n"); break;
1753  case 0x02: smprintf(s, "Unknown\n"); break;
1754  case 0x03: smprintf(s, "Unread SMS\n"); break;
1755  case 0x04: smprintf(s, "Voice call\n"); break;
1756  case 0x05: smprintf(s, "Fax call active\n"); break;
1757  case 0x06: smprintf(s, "Data call active\n"); break;
1758  case 0x07: smprintf(s, "Keyboard lock\n"); break;
1759  case 0x08: smprintf(s, "SMS storage full\n"); break;
1760  }
1761 #endif
1762  if (Data->RequestID == ID_GetDisplayStatus) {
1763  switch (msg->Buffer[2*i+5]) {
1764  case 0x01: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_CallActive;
1765  break;
1766  case 0x03: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_UnreadSMS;
1767  break;
1768  case 0x04: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_VoiceCall;
1769  break;
1770  case 0x05: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_FaxCall;
1771  break;
1772  case 0x06: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_DataCall;
1773  break;
1774  case 0x07: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_KeypadLocked;
1775  break;
1776  case 0x08: Data->DisplayFeatures->Feature[Data->DisplayFeatures->Number] = GSM_SMSMemoryFull;
1777  break;
1778  }
1779  if (msg->Buffer[2*i+5]!=0x02) Data->DisplayFeatures->Number++;
1780  }
1781  }
1782  }
1783  return ERR_NONE;
1784 }
1785 
1786 static GSM_Error N6110_GetDisplayStatus(GSM_StateMachine *s, GSM_DisplayFeatures *features)
1787 {
1788  unsigned char req[] = {N6110_FRAME_HEADER, 0x51};
1789 
1791 
1793  smprintf(s, "Getting display status\n");
1794  return GSM_WaitFor (s, req, 4, 0x0d, 4, ID_GetDisplayStatus);
1795 }
1796 
1797 static GSM_Profile_PhoneTableValue Profile6110[] = {
1801  {Profile_KeypadTone, PROFILE_KEYPAD_OFF, 0x00,0xff},
1802  {Profile_Lights, PROFILE_LIGHTS_OFF, 0x01,0x00},
1803  {Profile_Lights, PROFILE_LIGHTS_AUTO, 0x01,0x01},
1810  /* Ringtone ID */
1825  /* Caller groups */
1828  {0x00, 0x00, 0x00,0x00}
1829 };
1830 
1831 static GSM_Profile_PhoneTableValue Profile3310[] = {
1835  {Profile_KeypadTone, PROFILE_KEYPAD_OFF, 0x00,0xff},
1841  /* Ringtone ID */
1858  {Profile_ScreenSaver, PROFILE_SAVER_OFF, 0x07,0x00},
1859  {Profile_ScreenSaver, PROFILE_SAVER_ON, 0x07,0x01},
1866  {0x00, 0x00, 0x00,0x00}
1867 };
1868 
1869 static GSM_Error N6110_ReplyGetProfileFeature(GSM_Protocol_Message *msg, GSM_StateMachine *s)
1870 {
1871  GSM_Phone_Data *Data = &s->Phone.Data;
1872 
1873  switch (msg->Buffer[3]) {
1874  case 0x0d: /* Maybe this is handled completely wrong */
1875  case 0x14:
1876  smprintf(s, "Profile feature %02x with value %02x\n",msg->Buffer[6],msg->Buffer[8]);
1878  switch (msg->Buffer[6]) {
1879  case 0x02:
1880  smprintf(s, "Ringtone ID\n");
1882  Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg->Buffer[8];
1883  Data->Profile->FeaturesNumber++;
1884  break;
1885  case 0x09 :
1886  smprintf(s, "screen saver number\n");
1888  Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg->Buffer[8] + 1;
1889  Data->Profile->FeaturesNumber++;
1890  break;
1891  case 0x24:
1892  smprintf(s, "selected profile\n");
1893  if (msg->Buffer[8] + 1 == Data->Profile->Location) Data->Profile->Active = TRUE;
1894  break;
1895  default:
1896  NOKIA_FindFeatureValue(s, Profile3310,msg->Buffer[6],msg->Buffer[8],Data,FALSE);
1897  }
1898  return ERR_NONE;
1899  }
1900  switch (msg->Buffer[6]) {
1901  case 0x01: /* Lights */
1902  if (Data->Profile->CarKitProfile) {
1903  NOKIA_FindFeatureValue(s, Profile6110,msg->Buffer[6],msg->Buffer[8],Data,FALSE);
1904  }
1905  break;
1906  case 0x03:
1907  smprintf(s, "Ringtone ID\n");
1909  Data->Profile->FeatureValue [Data->Profile->FeaturesNumber] = msg->Buffer[8];
1910  Data->Profile->FeaturesNumber++;
1911  break;
1912  case 0x08: /* Caller groups */
1914  NOKIA_FindFeatureValue(s, Profile6110,msg->Buffer[6],msg->Buffer[8],Data,TRUE);
1915  }
1916  break;
1917  case 0x09: /* Autoanswer */
1918  if (Data->Profile->CarKitProfile || Data->Profile->HeadSetProfile) {
1919  NOKIA_FindFeatureValue(s, Profile6110,msg->Buffer[6],msg->Buffer[8],Data,FALSE);
1920  }
1921  break;
1922  case 0x2A:
1923  smprintf(s, "selected profile\n");
1924  if (msg->Buffer[8] + 1 == Data->Profile->Location) Data->Profile->Active = TRUE;
1925  break;
1926  default:
1927  NOKIA_FindFeatureValue(s, Profile6110,msg->Buffer[6],msg->Buffer[8],Data,FALSE);
1928  }
1929  return ERR_NONE;
1930  case 0x15:
1931  smprintf(s, "Invalid profile location\n");
1932  return ERR_INVALIDLOCATION;
1933  case 0x1b:
1934  Data->Profile->Name[0] = 0;
1935  Data->Profile->Name[1] = 0;
1937  EncodeUnicode(Data->Profile->Name,msg->Buffer+10,msg->Buffer[9]);
1938  } else {
1939  if (msg->Length > 0x0A) {
1940  CopyUnicodeString(Data->Profile->Name,msg->Buffer+10);
1941  }
1942  }
1943  smprintf(s, "Profile name: \"%s\"\n",Data->Profile->Name);
1944  Data->Profile->DefaultName = FALSE;
1945  if (msg->Buffer[9]==0x00) Data->Profile->DefaultName = TRUE;
1946  return ERR_NONE;
1947  }
1948  return ERR_UNKNOWNRESPONSE;
1949 }
1950 
1951 static GSM_Error N6110_GetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
1952 {
1953  GSM_Error error;
1954  int i,j;
1955  unsigned char name_req[] = {N6110_FRAME_HEADER, 0x1a, 0x00};
1956  unsigned char feat_req[] = {N6110_FRAME_HEADER, 0x13, 0x01,
1957  0x00, /* Profile location */
1958  0x00}; /* Feature number */
1959 
1960  s->Phone.Data.Profile=Profile;
1961 
1962  smprintf(s, "Getting profile name\n");
1963  error = GSM_WaitFor (s, name_req, 5, 0x05, 4, ID_GetProfile);
1964  if (error!=ERR_NONE) return error;
1965  if (Profile->DefaultName) {
1966  NOKIA_GetDefaultProfileName(Profile);
1968  switch(Profile->Location) {
1969  case 1: EncodeUnicode(Profile->Name,_("Personal"),strlen(_("Personal")));
1970  break;
1971  case 2: EncodeUnicode(Profile->Name,_("Car"),strlen(_("Car")));
1972  break;
1973  case 3: EncodeUnicode(Profile->Name,_("Headset"),strlen(_("Headset")));
1974  break;
1975  }
1976  }
1978  switch(Profile->Location) {
1979  case 1: EncodeUnicode(Profile->Name,_("General"),strlen(_("General")));
1980  break;
1981  case 2: EncodeUnicode(Profile->Name,_("Silent"),strlen(_("Silent")));
1982  break;
1983  case 3: EncodeUnicode(Profile->Name,_("Discreet"),strlen(_("Discreet")));
1984  break;
1985  case 4: EncodeUnicode(Profile->Name,_("Loud"),strlen(_("Loud")));
1986  break;
1987  case 5: EncodeUnicode(Profile->Name,_("My style"),strlen(_("My style")));
1988  break;
1989  case 6: Profile->Name[0] = 0; Profile->Name[1] = 0;
1990  break;
1991  }
1992  }
1993  }
1994 
1995  Profile->FeaturesNumber = 0;
1996 
1997  Profile->CarKitProfile = FALSE;
1998  Profile->HeadSetProfile = FALSE;
1999  if (Profile->Location == 6) Profile->CarKitProfile = TRUE;
2000  if (Profile->Location == 7) Profile->HeadSetProfile = TRUE;
2002  if (Profile->Location == 2) Profile->CarKitProfile = TRUE;
2003  if (Profile->Location == 3) Profile->HeadSetProfile = TRUE;
2004  }
2006  Profile->HeadSetProfile = FALSE; /* fixme */
2007  Profile->CarKitProfile = FALSE;
2008  }
2009 
2010  for (i = 0x00; i <= 0x09; i++) {
2011  feat_req[5] = Profile->Location - 1;
2012  feat_req[6] = i;
2013  smprintf(s, "Getting profile feature\n");
2014  error = GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetProfile);
2015  if (error!=ERR_NONE) return error;
2016  }
2017 
2018  for (i=0;i<Profile->FeaturesNumber;i++) {
2019  if (Profile->FeatureID[i] == Profile_CallAlert &&
2021  for (j=0;j<5;j++) Profile->CallerGroups[j] = TRUE;
2022  }
2023  }
2024 
2025  Profile->Active = FALSE;
2026  feat_req[5] = 0;
2028  feat_req[6] = 0x24;
2029  } else {
2030  feat_req[6] = 0x2A;
2031  }
2032  smprintf(s, "Getting profile feature\n");
2033  error = GSM_WaitFor (s, feat_req, 7, 0x05, 4, ID_GetProfile);
2034 
2035  return error;
2036 }
2037 
2038 static GSM_Error N6110_SetProfile(GSM_StateMachine *s, GSM_Profile *Profile)
2039 {
2040  int i;
2041  gboolean found;
2042  unsigned char ID,Value;
2043  GSM_Error error;
2044  GSM_Profile_PhoneTableValue *ProfilePhone = Profile6110;
2045 
2046  if (GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_PROFILES33)) ProfilePhone = Profile3310;
2047 
2048  for (i=0;i<Profile->FeaturesNumber;i++) {
2049  found = FALSE;
2050  if (ProfilePhone == Profile3310) {
2051  switch (Profile->FeatureID[i]) {
2052  case Profile_RingtoneID:
2053  ID = 0x02;
2054  Value = Profile->FeatureValue[i];
2055  found = TRUE;
2056  break;
2058  ID = 0x09;
2059  Value = Profile->FeatureValue[i];
2060  found = TRUE;
2061  break;
2062  default:
2064  s,
2065  ProfilePhone,
2066  Profile->FeatureID[i],Profile->FeatureValue[i],
2067  &ID,&Value);
2068  }
2069  }
2070  if (ProfilePhone == Profile6110) {
2071  switch (Profile->FeatureID[i]) {
2072  case Profile_RingtoneID:
2073  ID = 0x03;
2074  Value = Profile->FeatureValue[i];
2075  found = TRUE;
2076  break;
2077  default:
2079  s,
2080  ProfilePhone,
2081  Profile->FeatureID[i],Profile->FeatureValue[i],
2082  &ID,&Value);
2083  }
2084  }
2085  if (found) {
2086  error=N6110_SetProfileFeature (s,((unsigned char)(Profile->Location-1)),ID,Value);
2087  if (error!=ERR_NONE) return error;
2088  }
2089  }
2090  return ERR_NONE;
2091 }
2092 
2093 static GSM_Error N6110_ReplyIncomingSMS(GSM_Protocol_Message *msg, GSM_StateMachine *s)
2094 {
2095  GSM_Phone_Data *Data = &s->Phone.Data;
2096  GSM_SMSMessage sms;
2097 
2098 #ifdef DEBUG
2099  smprintf(s, "SMS message received\n");
2100  sms.State = SMS_UnRead;
2101  sms.InboxFolder = TRUE;
2102  DCT3_DecodeSMSFrame(s, &sms,msg->Buffer+7);
2103 #endif
2104  if (Data->EnableIncomingSMS && s->User.IncomingSMS!=NULL) {
2105  sms.State = SMS_UnRead;
2106  sms.InboxFolder = TRUE;
2107  DCT3_DecodeSMSFrame(s, &sms,msg->Buffer+7);
2108 
2109  s->User.IncomingSMS(s, &sms, s->User.IncomingSMSUserData);
2110  }
2111  return ERR_NONE;
2112 }
2113 
2114 static GSM_Error N6110_ReplyAddCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
2115 {
2116  smprintf(s, "Writing calendar note: ");
2117  switch (msg->Buffer[4]) {
2118  case 0x01:
2119  smprintf(s, "OK\n");
2120  return ERR_NONE;
2121  case 0x02:
2122  smprintf(s, "OK, but text was shortened\n");
2123  return ERR_NONE;
2124  case 0x73:
2125  case 0x7d:
2126  smprintf(s, "error\n");
2127  return ERR_UNKNOWN;
2128  case 0x81:
2129  smprintf(s,"during editing notes in phone menu\n");
2130  return ERR_INSIDEPHONEMENU;
2131  default:
2132  smprintf(s, "unknown ERROR %i\n",msg->Buffer[4]);
2133  }
2134  return ERR_UNKNOWNRESPONSE;
2135 }
2136 
2137 static GSM_Error N6110_AddCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2138 {
2139  gboolean Reminder3310 = FALSE;
2140  int Text, Time, Alarm, Phone, EndTime, Location, i, current, j;
2141  unsigned char req[200] = {N6110_FRAME_HEADER, 0x64, 0x01, 0x10,
2142  0x00, /* Length of the rest of the frame */
2143  0x00, /* Calendar note type */
2144  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2145  0x00, 0x00, 0x00, 0x01, 0x00, 0x66, 0x01};
2146 
2148 
2149  GSM_CalendarFindDefaultTextTimeAlarmPhone(Note, &Text, &Time, &Alarm, &Phone, &EndTime, &Location);
2150 
2152  switch(Note->Type) {
2153  case GSM_CAL_REMINDER: req[7]=0x01; break;
2154  case GSM_CAL_CALL : req[7]=0x02; break;
2155  case GSM_CAL_MEETING : req[7]=0x03; break;
2156  case GSM_CAL_BIRTHDAY: req[7]=0x04; break;
2157  case GSM_CAL_T_ATHL : req[7]=0x05; break;
2158  case GSM_CAL_T_BALL : req[7]=0x06; break;
2159  case GSM_CAL_T_CYCL : req[7]=0x07; break;
2160  case GSM_CAL_T_BUDO : req[7]=0x08; break;
2161  case GSM_CAL_T_DANC : req[7]=0x09; break;
2162  case GSM_CAL_T_EXTR : req[7]=0x0a; break;
2163  case GSM_CAL_T_FOOT : req[7]=0x0b; break;
2164  case GSM_CAL_T_GOLF : req[7]=0x0c; break;
2165  case GSM_CAL_T_GYM : req[7]=0x0d; break;
2166  case GSM_CAL_T_HORS : req[7]=0x0e; break;
2167  case GSM_CAL_T_HOCK : req[7]=0x0f; break;
2168  case GSM_CAL_T_RACE : req[7]=0x10; break;
2169  case GSM_CAL_T_RUGB : req[7]=0x11; break;
2170  case GSM_CAL_T_SAIL : req[7]=0x12; break;
2171  case GSM_CAL_T_STRE : req[7]=0x13; break;
2172  case GSM_CAL_T_SWIM : req[7]=0x14; break;
2173  case GSM_CAL_T_TENN : req[7]=0x15; break;
2174  case GSM_CAL_T_TRAV : req[7]=0x16; break;
2175  case GSM_CAL_T_WINT : req[7]=0x17; break;
2176  default : req[7]=0x01; break;
2177  }
2178  } else {
2179  switch(Note->Type) {
2180  case GSM_CAL_CALL : req[7]=0x02; break;
2181  case GSM_CAL_MEETING : req[7]=0x03; break;
2182  case GSM_CAL_BIRTHDAY: req[7]=0x04; break;
2183  case GSM_CAL_REMINDER:
2184  default : req[7]=0x01; break;
2185  }
2186  }
2187 
2188  if (Time == -1) return ERR_UNKNOWN;
2189  NOKIA_EncodeDateTime(s, req+8, &Note->Entries[Time].Date);
2190  req[14] = Note->Entries[Time].Date.Second;
2191 
2192  if (Alarm != -1) {
2193  NOKIA_EncodeDateTime(s, req+15, &Note->Entries[Alarm].Date);
2194  req[21] = Note->Entries[Alarm].Date.Second;
2195  }
2196 
2197  current = 23;
2198 
2199  if (Text != -1) {
2202  req[22] = UnicodeLength(Note->Entries[Text].Text)*2;
2203  memcpy(req+current,Note->Entries[Text].Text,UnicodeLength(Note->Entries[Text].Text)*2);
2204  current += UnicodeLength(Note->Entries[Text].Text)*2;
2205  } else {
2206  req[22] = UnicodeLength(Note->Entries[Text].Text);
2208  Reminder3310 = TRUE;
2209  if (!strcmp(s->Phone.Data.ModelInfo->model,"3310") && s->Phone.Data.VerNum<5.11) {
2210  if (Note->Type!=GSM_CAL_REMINDER) Reminder3310 = FALSE;
2211  }
2212  if (!strcmp(s->Phone.Data.ModelInfo->model,"3330") && s->Phone.Data.VerNum<=4.50) {
2213  if (Note->Type!=GSM_CAL_REMINDER) Reminder3310 = FALSE;
2214  }
2215  if (Reminder3310) {
2216  req[22]++; /* one additional char */
2217  req[current++] = 0x01; /* we use now subset 1 */
2218  for (i=0;i<((int)UnicodeLength(Note->Entries[Text].Text));i++) {
2219  j = EncodeWithUTF8Alphabet(Note->Entries[Text].Text[i*2]*256+Note->Entries[Text].Text[i*2+1],req+current);
2220  if (j > 1) {
2221  req[23]= 0x03; /* use subset 3 */
2222  req[22]+=j-1; /* few additional chars */
2223  current+=j;
2224  } else {
2225  current+=DecodeWithUnicodeAlphabet(((wchar_t)(Note->Entries[Text].Text[i*2]*256+Note->Entries[Text].Text[i*2+1])),req+current);
2226  }
2227  }
2228  }
2229  }
2230  if (!Reminder3310) {
2231  memcpy(req+current,DecodeUnicodeString(Note->Entries[Text].Text),UnicodeLength(Note->Entries[Text].Text));
2232  current += UnicodeLength(Note->Entries[Text].Text);
2233  }
2234  }
2235  } else req[22] = 0x00;
2236 
2237  if (Note->Type == GSM_CAL_CALL) {
2238  if (Phone != -1) {
2239  req[current++] = UnicodeLength(Note->Entries[Phone].Text);
2240  memcpy(req+current,DecodeUnicodeString(Note->Entries[Phone].Text),UnicodeLength(Note->Entries[Phone].Text));
2241  current += UnicodeLength(Note->Entries[Phone].Text);
2242  } else req[current++] = 0x00;
2243  }
2244 
2245  req[6] = current - 8;
2246 
2247  smprintf(s, "Writing calendar note\n");
2248  return GSM_WaitFor (s, req, current, 0x13, 4, ID_SetCalendarNote);
2249 }
2250 
2251 static GSM_Error N6110_ReplyDeleteCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
2252 {
2253  smprintf(s, "Deleting calendar note: ");
2254  switch (msg->Buffer[4]) {
2255  case 0x01:
2256  smprintf(s, "done OK\n");
2257  return ERR_NONE;
2258  case 0x81:
2259  smprintf(s,"during editing notes in phone menu\n");
2260  return ERR_INSIDEPHONEMENU;
2261  case 0x93:
2262  smprintf(s, "Can't be done - too high location ?\n");
2263  return ERR_INVALIDLOCATION;
2264  default:
2265  smprintf(s, "unknown ERROR %i\n",msg->Buffer[4]);
2266  return ERR_UNKNOWNRESPONSE;
2267  }
2268 }
2269 
2270 static GSM_Error N6110_DeleteCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note)
2271 {
2272  unsigned char req[] = {N6110_FRAME_HEADER, 0x68,
2273  0x00}; /* Location */
2274 
2276 
2277  req[4] = Note->Location;
2278 
2279  smprintf(s, "Deleting calendar note\n");
2280  return GSM_WaitFor (s, req, 5, 0x13, 5, ID_DeleteCalendarNote);
2281 }
2282 
2283 /* for example: "Euro_char" text */
2284 static void Decode3310Subset3(int j, GSM_Protocol_Message *msg, GSM_Phone_Data *Data)
2285 {
2286  wchar_t wc;
2287  int len = 0,i,w;
2288  GSM_CalendarEntry *Entry = Data->Cal;
2289 
2290  i = j;
2291  while (i!=msg->Buffer[23]) {
2292  w = DecodeWithUTF8Alphabet(msg->Buffer+24+i,&wc,msg->Buffer[23]-i);
2293  if (w>1) {
2294  i+=w;
2295  } else {
2296  EncodeWithUnicodeAlphabet(msg->Buffer+24+i,&wc);
2297  }
2298  Entry->Entries[Entry->EntriesNum].Text[len++] = (wc >> 8) & 0xff;
2299  Entry->Entries[Entry->EntriesNum].Text[len++] = wc & 0xff;
2300  i++;
2301  }
2302  Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
2303  Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
2304 }
2305 
2306 /* For example: "a with : above" char */
2307 static void Decode3310Subset2(int j, GSM_Protocol_Message *msg, GSM_Phone_Data *Data)
2308 {
2309  int len = 0;
2310  int i;
2311  GSM_CalendarEntry *Entry = Data->Cal;
2312 
2313  i = j;
2314  while (i!=msg->Buffer[23]) {
2315  Entry->Entries[Entry->EntriesNum].Text[len++] = 0x00;
2316  Entry->Entries[Entry->EntriesNum].Text[len++] = msg->Buffer[24+i];
2317  i++;
2318  }
2319  Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
2320  Entry->Entries[Entry->EntriesNum].Text[len++] = 0;
2321 }
2322 
2323 static GSM_Error N6110_ReplyGetNextCalendar(GSM_Protocol_Message *msg, GSM_StateMachine *s)
2324 {
2325  int i = 0;
2326  gboolean SpecialSubSet = FALSE;
2327  GSM_CalendarEntry *Entry = s->Phone.Data.Cal;
2328 
2329  switch (msg->Buffer[4]) {
2330  case 0x01:
2331  smprintf(s, "Calendar note received\n");
2332  switch (msg->Buffer[8]) {
2333  case 0x01: Entry->Type = GSM_CAL_REMINDER; break;
2334  case 0x02: Entry->Type = GSM_CAL_CALL; break;
2335  case 0x03: Entry->Type = GSM_CAL_MEETING; break;
2336  case 0x04: Entry->Type = GSM_CAL_BIRTHDAY; break;
2337  case 0x05: Entry->Type = GSM_CAL_T_ATHL; break;
2338  case 0x06: Entry->Type = GSM_CAL_T_BALL; break;
2339  case 0x07: Entry->Type = GSM_CAL_T_CYCL; break;
2340  case 0x08: Entry->Type = GSM_CAL_T_BUDO; break;
2341  case 0x09: Entry->Type = GSM_CAL_T_DANC; break;
2342  case 0x0a: Entry->Type = GSM_CAL_T_EXTR; break;
2343  case 0x0b: Entry->Type = GSM_CAL_T_FOOT; break;
2344  case 0x0c: Entry->Type = GSM_CAL_T_GOLF; break;
2345  case 0x0d: Entry->Type = GSM_CAL_T_GYM; break;
2346  case 0x0e: Entry->Type = GSM_CAL_T_HORS; break;
2347  case 0x0f: Entry->Type = GSM_CAL_T_HOCK; break;
2348  case 0x10: Entry->Type = GSM_CAL_T_RACE; break;
2349  case 0x11: Entry->Type = GSM_CAL_T_RUGB; break;
2350  case 0x12: Entry->Type = GSM_CAL_T_SAIL; break;
2351  case 0x13: Entry->Type = GSM_CAL_T_STRE; break;
2352  case 0x14: Entry->Type = GSM_CAL_T_SWIM; break;
2353  case 0x15: Entry->Type = GSM_CAL_T_TENN; break;
2354  case 0x16: Entry->Type = GSM_CAL_T_TRAV; break;
2355  case 0x17: Entry->Type = GSM_CAL_T_WINT; break;
2356  default :
2357  smprintf(s, "Unknown note type %i\n",msg->Buffer[8]);
2358  return ERR_UNKNOWNRESPONSE;
2359  }
2360 #ifdef DEBUG
2361  switch (msg->Buffer[8]) {
2362  case 0x01: smprintf(s, "Reminder\n"); break;
2363  case 0x02: smprintf(s, "Call\n"); break;
2364  case 0x03: smprintf(s, "Meeting\n"); break;
2365  case 0x04: smprintf(s, "Birthday\n"); break;
2366  }
2367 #endif
2368  Entry->EntriesNum = 0;
2369 
2370  NOKIA_DecodeDateTime(s, msg->Buffer+9, &Entry->Entries[0].Date, TRUE, FALSE);
2371  smprintf(s, "Time : %02i-%02i-%04i %02i:%02i:%02i\n",
2372  Entry->Entries[0].Date.Day,Entry->Entries[0].Date.Month,Entry->Entries[0].Date.Year,
2373  Entry->Entries[0].Date.Hour,Entry->Entries[0].Date.Minute,Entry->Entries[0].Date.Second);
2374  Entry->Entries[0].EntryType = CAL_START_DATETIME;
2375  Entry->EntriesNum++;
2376 
2377  NOKIA_DecodeDateTime(s, msg->Buffer+16, &Entry->Entries[1].Date, TRUE, FALSE);
2378  if (Entry->Entries[1].Date.Year!=0) {
2379  smprintf(s, "Alarm : %02i-%02i-%04i %02i:%02i:%02i\n",
2380  Entry->Entries[1].Date.Day,Entry->Entries[1].Date.Month,Entry->Entries[1].Date.Year,
2381  Entry->Entries[1].Date.Hour,Entry->Entries[1].Date.Minute,Entry->Entries[1].Date.Second);
2383  Entry->EntriesNum++;
2384  } else {
2385  smprintf(s, "No alarm\n");
2386  }
2387 
2388  if (Entry->Type == GSM_CAL_BIRTHDAY) {
2390  Entry->Entries[Entry->EntriesNum].Number = 1;
2391  Entry->EntriesNum++;
2392  Entry->Entries[Entry->EntriesNum].EntryType = CAL_REPEAT_DAY;
2393  Entry->Entries[Entry->EntriesNum].Number = Entry->Entries[0].Date.Day;
2394  Entry->EntriesNum++;
2395  Entry->Entries[Entry->EntriesNum].EntryType = CAL_REPEAT_MONTH;
2396  Entry->Entries[Entry->EntriesNum].Number = Entry->Entries[0].Date.Month;
2397  Entry->EntriesNum++;
2398  }
2399 
2402  memcpy(Entry->Entries[Entry->EntriesNum].Text,msg->Buffer+24,msg->Buffer[23]);
2403  Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[23] ]=0;
2404  Entry->Entries[Entry->EntriesNum].Text[msg->Buffer[23]+1]=0;
2405  } else {
2407  /* first char is subset for 33xx and reminders */
2408  if (Entry->Type == GSM_CAL_REMINDER) {
2409  i=1;
2410  smprintf(s, "Subset %i in reminder note !\n",msg->Buffer[24]);
2411  }
2412  SpecialSubSet = TRUE;
2413  switch (msg->Buffer[24]) {
2414  case 2 : Decode3310Subset2(i,msg,&s->Phone.Data); break;
2415  case 3 : Decode3310Subset3(i,msg,&s->Phone.Data); break;
2416  default : SpecialSubSet = FALSE; break;
2417  }
2418  }
2419  if (!SpecialSubSet) {
2420  N6110_EncodeUnicode(s,Entry->Entries[Entry->EntriesNum].Text,msg->Buffer+24+i,msg->Buffer[23]-i);
2421  }
2422  }
2423  smprintf(s, "Text \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
2424  if (msg->Buffer[23] != 0x00) {
2425  Entry->Entries[Entry->EntriesNum].EntryType = CAL_TEXT;
2426  Entry->EntriesNum++;
2427  }
2428 
2429  if (Entry->Type == GSM_CAL_CALL) {
2430  EncodeUnicode(Entry->Entries[Entry->EntriesNum].Text,msg->Buffer+24+msg->Buffer[23]+1,msg->Buffer[24+msg->Buffer[23]]);
2431  smprintf(s, "Phone : \"%s\"\n",DecodeUnicodeString(Entry->Entries[Entry->EntriesNum].Text));
2432  if (msg->Buffer[24+msg->Buffer[23]] != 0x00) {
2433  Entry->Entries[Entry->EntriesNum].EntryType = CAL_PHONE;
2434  Entry->EntriesNum++;
2435  }
2436  }
2437  return ERR_NONE;
2438  case 0x93:
2439  smprintf(s, "Can't get calendar note - too high location?\n");
2440  return ERR_INVALIDLOCATION;
2441  }
2442  return ERR_UNKNOWNRESPONSE;
2443 }
2444 
2445 static GSM_Error N6110_GetNextCalendarNote(GSM_StateMachine *s, GSM_CalendarEntry *Note, gboolean start)
2446 {
2447  int Text, Time, Alarm, Phone, EndTime, Location;
2448  GSM_Error error;
2449  GSM_DateTime date_time;
2450  GSM_Phone_N6110Data *Priv = &s->Phone.Data.Priv.N6110;
2451  unsigned char req[] = {N6110_FRAME_HEADER, 0x66,
2452  0x00}; /* Location */
2453 
2455 
2456  if (start) {
2457  Priv->LastCalendarPos = 1;
2458  } else {
2459  Priv->LastCalendarPos++;
2460  }
2461 
2462  Note->Location = Priv->LastCalendarPos;
2463  req[4] = Priv->LastCalendarPos;
2464 
2465  s->Phone.Data.Cal=Note;
2466  smprintf(s, "Getting calendar note\n");
2467  error=GSM_WaitFor (s, req, 5, 0x13, 4, ID_GetCalendarNote);
2468 
2469  GSM_CalendarFindDefaultTextTimeAlarmPhone(Note, &Text, &Time, &Alarm, &Phone, &EndTime, &Location);
2470  /* 2090 year is set for example in 3310 */
2471  if (error == ERR_NONE && Note->Entries[Time].Date.Year == 2090) {
2472  error=N6110_GetDateTime(s, &date_time);
2473  if (error == ERR_NONE) Note->Entries[Time].Date.Year = date_time.Year;
2474  }
2475  if (error == ERR_INVALIDLOCATION) error = ERR_EMPTY;
2476  return error;
2477 }
2478 
2479 GSM_Error N6110_ReplyUSSDInfo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
2480 {
2481  unsigned char buffer[2000];
2482  int tmp;
2483  GSM_USSDMessage ussd;
2484 
2485  tmp=GSM_UnpackEightBitsToSeven(0, msg->Buffer[7], 82, msg->Buffer+8, buffer);
2486  buffer[tmp] = 0;
2487 
2488  smprintf(s, "USSD reply: \"%s\"\n",buffer);
2489 
2490  if (s->Phone.Data.EnableIncomingUSSD && s->User.IncomingUSSD!=NULL) {
2491  EncodeUnicode(ussd.Text,buffer,strlen(buffer));
2495  ussd.Status = USSD_Unknown;
2496  s->User.IncomingUSSD(s, &ussd, s->User.IncomingUSSDUserData);
2497  }
2498 
2499  return ERR_NONE;
2500 }
2501 
2502 GSM_Error N6110_AnswerCall(GSM_StateMachine *s, int ID, gboolean all)
2503 {
2504  GSM_Error error;
2505  unsigned char req1[] = {N6110_FRAME_HEADER, 0x42, 0x05, 0x01,
2506  0x07, 0xa2, 0x88, 0x81, 0x21, 0x15, 0x63, 0xa8,
2507  0x00, 0x00, 0x07, 0xa3, 0xb8, 0x81, 0x20, 0x15,
2508  0x63, 0x80};
2509 
2510  if (!all) {
2511  smprintf(s, "Answering call part 1\n");
2512  error = GSM_WaitFor (s, req1, 24, 0x01, 5, ID_AnswerCall);
2513  if (error != ERR_NONE) return error;
2514  return DCT3DCT4_AnswerCall(s,ID);
2515  }
2516 
2517  return DCT3_AnswerAllCalls(s);
2518 }
2519 
2520 static GSM_Error N6110_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
2521 {
2522  unsigned int pos = 4;
2523  unsigned char req[100] = {N6110_FRAME_HEADER,0x01,
2524  0x0c}; /* Length of number */
2525 
2526  if (ShowNumber == GSM_CALL_DefaultNumberPresence) return DCT3_DialVoice(s,number,ShowNumber);
2527 
2528  req[pos++] = strlen(number);
2529  memcpy(req+pos,number,strlen(number));
2530  pos += strlen(number);
2531  req[pos++] = 0x05; /* call type: voice - 0x05, data - 0x01 */
2532  req[pos++] = 0x01;
2533  req[pos++] = 0x01;
2534  req[pos++] = 0x05;
2535  req[pos++] = 0x81;
2536  switch (ShowNumber) {
2537  case GSM_CALL_HideNumber:
2538  req[pos++] = 0x02;
2539  break;
2540  case GSM_CALL_ShowNumber:
2541  req[pos++] = 0x03;
2542  break;
2544  req[pos++] = 0x01;
2545  break;
2546  }
2547  req[pos++] = 0x00;
2548  req[pos++] = 0x00;
2549 
2550  smprintf(s, "Making voice call\n");
2551  return GSM_WaitFor (s, req, pos, 0x01, 4, ID_DialVoice);
2552 }
2553 
2554 GSM_Error N6110_UnholdCall(GSM_StateMachine *s, int ID)
2555 {
2556  unsigned char req[] = {N6110_FRAME_HEADER, 0x24, 0x00, 0x02};
2557 
2558  req[4] = (unsigned char)ID;
2559  s->Phone.Data.CallID = ID;
2560 
2561  smprintf(s, "Unholding call\n");
2562  return GSM_WaitFor (s, req, 6, 0x01, 4, ID_UnholdCall);
2563 }
2564 
2565 GSM_Error N6110_HoldCall(GSM_StateMachine *s, int ID)
2566 {
2567  unsigned char req[] = {N6110_FRAME_HEADER, 0x22, 0x00, 0x00};
2568 
2569  req[4] = (unsigned char)ID;
2570  s->Phone.Data.CallID = ID;
2571 
2572  smprintf(s, "Unholding call\n");
2573  return GSM_WaitFor (s, req, 6, 0x01, 4, ID_HoldCall);
2574 }
2575 
2576 /* Joining selected call to current (and making conference) */
2577 GSM_Error N6110_ConferenceCall(GSM_StateMachine *s, int ID)
2578 {
2579  unsigned char req[] = {N6110_FRAME_HEADER, 0x28, 0x00, 0x01};
2580 
2581  req[4] = (unsigned char)ID;
2582  s->Phone.Data.CallID = ID;
2583 
2584  smprintf(s, "Conference call\n");
2585  return GSM_WaitFor (s, req, 6, 0x01, 4, ID_ConferenceCall);
2586 }
2587 
2588 /* Removing selected call from conference and making private call with it
2589  * (conference call is on hold) */
2590 GSM_Error N6110_SplitCall(GSM_StateMachine *s, int ID)
2591 {
2592  unsigned char req[] = {N6110_FRAME_HEADER, 0x2A, 0x00, 0x01};
2593 
2594  req[4] = (unsigned char)ID;
2595  s->Phone.Data.CallID = ID;
2596 
2597  smprintf(s, "Split call\n");
2598  return GSM_WaitFor (s, req, 6, 0x01, 4, ID_SplitCall);
2599 }
2600 
2601 /* This probably need more investigation */
2602 GSM_Error N6110_SwitchCall(GSM_StateMachine *s, int ID, gboolean next)
2603 {
2604 /* unsigned char req[] = {N6110_FRAME_HEADER, 0x20}; calls info */
2605  unsigned char req[] = {N6110_FRAME_HEADER, 0x26, 0x00};
2606 
2607  s->Phone.Data.CallID = ID;
2608 
2609  if (next) {
2610  smprintf(s, "Switch call\n");
2611  return GSM_WaitFor (s, req, 4, 0x01, 4, ID_SwitchCall);
2612  } else {
2613  req[4] = (unsigned char)ID;
2614 
2615  smprintf(s, "Switch call\n");
2616  return GSM_WaitFor (s, req, 5, 0x01, 4, ID_SwitchCall);
2617  }
2618 }
2619 
2620 /* This probably need more investigation */
2621 GSM_Error N6110_TransferCall(GSM_StateMachine *s, int ID, gboolean next)
2622 {
2623  unsigned char req[] = {N6110_FRAME_HEADER, 0x2C, 0x00};
2624 
2625  s->Phone.Data.CallID = ID;
2626 
2627  if (next) {
2628  smprintf(s, "Transfer call\n");
2629  return GSM_WaitFor (s, req, 4, 0x01, 4, ID_TransferCall);
2630  } else {
2631  req[4] = (unsigned char)ID;
2632 
2633  smprintf(s, "Transfer call\n");
2634  return GSM_WaitFor (s, req, 5, 0x01, 4, ID_TransferCall);
2635  }
2636 }
2637 
2638 static GSM_Reply_Function N6110ReplyFunctions[] = {
2639  {N6110_ReplyCallInfo, "\x01",0x03,0x02,ID_IncomingFrame },
2640  {N6110_ReplyCallInfo, "\x01",0x03,0x03,ID_IncomingFrame },
2641  {N6110_ReplyCallInfo, "\x01",0x03,0x04,ID_IncomingFrame },
2642  {N6110_ReplyCallInfo, "\x01",0x03,0x05,ID_IncomingFrame },
2643  {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_AnswerCall },
2644  {N6110_ReplyCallInfo, "\x01",0x03,0x07,ID_IncomingFrame },
2645  {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_CancelCall },
2646  {N6110_ReplyCallInfo, "\x01",0x03,0x09,ID_IncomingFrame },
2647  {N6110_ReplyCallInfo, "\x01",0x03,0x0A,ID_IncomingFrame },
2648  {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_HoldCall },
2649  {N6110_ReplyCallInfo, "\x01",0x03,0x23,ID_IncomingFrame },
2650  {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_UnholdCall },
2651  {N6110_ReplyCallInfo, "\x01",0x03,0x25,ID_IncomingFrame },
2652  {N6110_ReplyCallInfo, "\x01",0x03,0x27,ID_IncomingFrame },
2653  {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_ConferenceCall },
2654  {N6110_ReplyCallInfo, "\x01",0x03,0x29,ID_IncomingFrame },
2655  {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_SplitCall },
2656  {N6110_ReplyCallInfo, "\x01",0x03,0x2B,ID_IncomingFrame },
2657  {N6110_ReplySendDTMF, "\x01",0x03,0x40,ID_SendDTMF },
2658  {NoneReply, "\x01",0x03,0x40,ID_DialVoice },
2659  {NoneReply, "\x01",0x03,0x40,ID_IncomingFrame },
2660  {NoneReply, "\x01",0x03,0x43,ID_AnswerCall },
2661  {N6110_ReplySendDTMF, "\x01",0x03,0x51,ID_SendDTMF },
2662 
2663  {DCT3_ReplySendSMSMessage, "\x02",0x03,0x02,ID_IncomingFrame },
2664  {DCT3_ReplySendSMSMessage, "\x02",0x03,0x03,ID_IncomingFrame },
2665  {N6110_ReplyIncomingSMS, "\x02",0x03,0x10,ID_IncomingFrame },
2666 #ifdef GSM_ENABLE_CELLBROADCAST
2667  {DCT3_ReplySetIncomingCB, "\x02",0x03,0x21,ID_SetIncomingCB },
2668  {DCT3_ReplySetIncomingCB, "\x02",0x03,0x22,ID_SetIncomingCB },
2669  {DCT3_ReplyIncomingCB, "\x02",0x03,0x23,ID_IncomingFrame },
2670 #endif
2671  {DCT3_ReplySetSMSC, "\x02",0x03,0x31,ID_SetSMSC },
2672  {DCT3_ReplyGetSMSC, "\x02",0x03,0x34,ID_GetSMSC },
2673  {DCT3_ReplyGetSMSC, "\x02",0x03,0x35,ID_GetSMSC },
2674  {DCT3_ReplyWaitSMSC, "\x02",0x03,0xc9,ID_IncomingFrame },
2675 
2676  {N6110_ReplyGetMemory, "\x03",0x03,0x02,ID_GetMemory },
2677  {N6110_ReplyGetMemory, "\x03",0x03,0x03,ID_GetMemory },
2678  {N6110_ReplySetMemory, "\x03",0x03,0x05,ID_SetMemory },
2679  {N6110_ReplySetMemory, "\x03",0x03,0x06,ID_SetMemory },
2680  {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x08,ID_GetMemoryStatus },
2681  {N6110_ReplyGetMemoryStatus, "\x03",0x03,0x09,ID_GetMemoryStatus },
2682  {N6110_ReplyGetCallerLogo, "\x03",0x03,0x11,ID_GetBitmap },
2683  {N6110_ReplyGetCallerLogo, "\x03",0x03,0x12,ID_GetBitmap },
2684  {N6110_ReplySetCallerLogo, "\x03",0x03,0x14,ID_SetBitmap },
2685  {N6110_ReplySetCallerLogo, "\x03",0x03,0x15,ID_SetBitmap },
2686  {N6110_ReplyGetSpeedDial, "\x03",0x03,0x17,ID_GetSpeedDial },
2687  {N6110_ReplyGetSpeedDial, "\x03",0x03,0x18,ID_GetSpeedDial },
2688  /* 0x1A, 0x1B - reply set speed dial */
2689 
2690  {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetSignalQuality },
2691  {N6110_ReplyGetStatus, "\x04",0x03,0x02,ID_GetBatteryCharge },
2692 
2693  {N6110_ReplyGetProfileFeature, "\x05",0x03,0x0d,ID_GetProfile },
2694  {N6110_ReplySetProfileFeature, "\x05",0x03,0x11,ID_SetProfile },
2695  {N6110_ReplySetProfileFeature, "\x05",0x03,0x12,ID_SetProfile },
2696  {N6110_ReplyGetProfileFeature, "\x05",0x03,0x14,ID_GetProfile },
2697  {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x14,ID_GetLanguage },
2698  {N6110_ReplyGetProfileFeature, "\x05",0x03,0x15,ID_GetProfile },
2699  {N6110_ReplyGetPhoneLanguage, "\x05",0x03,0x15,ID_GetLanguage },
2700  {N6110_ReplyGetStartup, "\x05",0x03,0x17,ID_GetBitmap },
2701  {N6110_ReplySetStartup, "\x05",0x03,0x19,ID_SetBitmap },
2702  {N6110_ReplyGetProfileFeature, "\x05",0x03,0x1b,ID_GetProfile },
2703  {N61_91_ReplySetOpLogo, "\x05",0x03,0x31,ID_SetBitmap },
2704  {N61_91_ReplySetOpLogo, "\x05",0x03,0x32,ID_SetBitmap },
2705  {N6110_ReplyGetOpLogo, "\x05",0x03,0x34,ID_GetBitmap },
2706  {N6110_ReplySetRingtone, "\x05",0x03,0x37,ID_SetRingtone },
2707  {N6110_ReplySetRingtone, "\x05",0x03,0x38,ID_SetRingtone },
2708 
2709  {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x02,ID_Divert },
2710  {DCT3DCT4_ReplyCallDivert, "\x06",0x03,0x03,ID_Divert },
2711  {N6110_ReplyUSSDInfo, "\x06",0x03,0x05,ID_IncomingFrame },
2712  {NoneReply, "\x06",0x03,0x06,ID_IncomingFrame },/* incoming call divert info */
2713 
2714  {N6110_ReplyGetSecurityStatus, "\x08",0x03,0x08,ID_GetSecurityStatus },
2715  {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0b,ID_EnterSecurityCode },
2716  {N6110_ReplyEnterSecurityCode, "\x08",0x03,0x0c,ID_EnterSecurityCode },
2717 
2718  {DCT3_ReplySIMLogin, "\x09",0x03,0x80,ID_IncomingFrame },
2719  {DCT3_ReplySIMLogout, "\x09",0x03,0x81,ID_IncomingFrame },
2720 
2721  {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_GetNetworkInfo },
2722  {DCT3_ReplyGetNetworkInfo, "\x0A",0x03,0x71,ID_IncomingFrame },
2723 
2724  {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_GetDisplayStatus },
2725  {N6110_ReplyGetDisplayStatus, "\x0D",0x03,0x52,ID_IncomingFrame },
2726 
2727  {DCT3_ReplySetDateTime, "\x11",0x03,0x61,ID_SetDateTime },
2728  {DCT3_ReplyGetDateTime, "\x11",0x03,0x63,ID_GetDateTime },
2729  {DCT3_ReplySetAlarm, "\x11",0x03,0x6C,ID_SetAlarm },
2730  {DCT3_ReplyGetAlarm, "\x11",0x03,0x6E,ID_GetAlarm },
2731 
2732  {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_SetCalendarNote },
2733  {N6110_ReplyAddCalendar, "\x13",0x03,0x65,ID_IncomingFrame },
2734  {N6110_ReplyGetNextCalendar, "\x13",0x03,0x67,ID_GetCalendarNote },
2735  {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_DeleteCalendarNote },
2736  {N6110_ReplyDeleteCalendar, "\x13",0x03,0x69,ID_IncomingFrame },
2737 
2738  {N6110_ReplySaveSMSMessage, "\x14",0x03,0x05,ID_SaveSMSMessage },
2739  {N6110_ReplySaveSMSMessage, "\x14",0x03,0x06,ID_SaveSMSMessage },
2740  {N6110_ReplyGetSMSMessage, "\x14",0x03,0x08,ID_GetSMSMessage },
2741  {N6110_ReplyGetSMSMessage, "\x14",0x03,0x09,ID_GetSMSMessage },
2742  {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0B,ID_DeleteSMSMessage },
2743  {DCT3_ReplyDeleteSMSMessage, "\x14",0x03,0x0C,ID_DeleteSMSMessage },
2744  {N6110_ReplyGetSMSStatus, "\x14",0x03,0x37,ID_GetSMSStatus },
2745  {N6110_ReplyGetSMSStatus, "\x14",0x03,0x38,ID_GetSMSStatus },
2746 
2748  {DCT3DCT4_ReplyEnableConnectFunc, "\x3f",0x03,0x02,ID_EnableConnectFunc },
2750  {DCT3DCT4_ReplyDisableConnectFunc,"\x3f",0x03,0x05,ID_DisableConnectFunc },
2751  {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x07,ID_GetWAPBookmark },
2752  {DCT3_ReplyGetWAPBookmark, "\x3f",0x03,0x08,ID_GetWAPBookmark },
2753  {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0A,ID_SetWAPBookmark },
2754  {DCT3DCT4_ReplySetWAPBookmark, "\x3f",0x03,0x0B,ID_SetWAPBookmark },
2756  {DCT3DCT4_ReplyDelWAPBookmark, "\x3f",0x03,0x0E,ID_DeleteWAPBookmark },
2759  {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x16,ID_GetConnectSet },
2760  {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x17,ID_GetConnectSet },
2761  {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x19,ID_SetConnectSet },
2762  {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1A,ID_SetConnectSet },
2763  {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1C,ID_GetConnectSet },
2764  {DCT3_ReplyGetWAPSettings, "\x3f",0x03,0x1D,ID_GetConnectSet },
2765  {DCT3_ReplySetWAPSettings, "\x3f",0x03,0x1F,ID_SetConnectSet },
2766 
2767  {DCT3_ReplyEnableSecurity, "\x40",0x02,0x64,ID_EnableSecurity },
2769  {DCT3_ReplyGetIMEI, "\x40",0x02,0x66,ID_GetIMEI },
2770  {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_DialVoice },
2771  {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_CancelCall },
2772  {DCT3_ReplyDialCommand, "\x40",0x02,0x7C,ID_AnswerCall },
2773  {DCT3_ReplyNetmonitor, "\x40",0x02,0x7E,ID_Netmonitor },
2774  {DCT3_ReplyPlayTone, "\x40",0x02,0x8F,ID_PlayTone },
2775  {N6110_ReplyGetRingtone, "\x40",0x02,0x9E,ID_GetRingtone },
2776  {N6110_ReplySetBinRingtone, "\x40",0x02,0xA0,ID_SetRingtone },
2777  {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetHardware },
2778  {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xC8,ID_GetPPM },
2779  {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCA,ID_GetProductCode },
2781  {NOKIA_ReplyGetPhoneString, "\x40",0x02,0xCC,ID_GetOriginalIMEI },
2782 
2783  {N6110_ReplyGetSetPicture, "\x47",0x03,0x02,ID_GetBitmap },
2784  {N6110_ReplyGetSetPicture, "\x47",0x03,0x04,ID_SetBitmap },
2785  {N6110_ReplyGetSetPicture, "\x47",0x03,0x05,ID_SetBitmap },
2786  {N6110_ReplyGetSetPicture, "\x47",0x03,0x06,ID_GetBitmap },
2787 
2788  {N6110_ReplyGetMagicBytes, "\x64",0x00,0x00,ID_MakeAuthentication },
2789 
2790  {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetModel },
2791  {DCT3DCT4_ReplyGetModelFirmware, "\xD2",0x02,0x00,ID_GetFirmware },
2792  {DCT3_ReplyPressKey, "\xD2",0x02,0x46,ID_PressKey },
2793  {DCT3_ReplyPressKey, "\xD2",0x02,0x47,ID_PressKey },
2794 
2795  {NULL, "\x00",0x00,0x00,ID_None }
2796 };
2797 
2798 GSM_Phone_Functions N6110Phone = {
2799  "2100|3210|3310|3330|3390|3390b|3410|3610|5110|5110i|5130|5190|5210|5510|6110|6130|6150|6190|8210|8250|8290|8850|8855|8890",
2800  N6110ReplyFunctions,
2801  NOTSUPPORTED, /* Install */
2802  N6110_Initialise,
2805  N6110_ShowStartInfo,
2809  DCT3_GetIMEI,
2814  DCT3_GetPPM,
2815  NOTSUPPORTED, /* GetSIMIMSI */
2816  N6110_GetDateTime,
2817  N6110_SetDateTime,
2818  N6110_GetAlarm,
2819  N6110_SetAlarm,
2820  NOTSUPPORTED, /* GetLocale */
2821  NOTSUPPORTED, /* SetLocale */
2822  DCT3_PressKey,
2823  DCT3_Reset,
2825  N6110_EnterSecurityCode,
2826  N6110_GetSecurityStatus,
2827  N6110_GetDisplayStatus,
2828  NOTIMPLEMENTED, /* SetAutoNetworkLogin */
2829  N6110_GetBatteryCharge,
2830  N6110_GetSignalQuality,
2832  NOTSUPPORTED, /* GetCategory */
2833  NOTSUPPORTED, /* AddCategory */
2834  NOTSUPPORTED, /* GetCategoryStatus */
2835  N6110_GetMemoryStatus,
2836  N6110_GetMemory,
2837  NOTIMPLEMENTED, /* GetNextMemory */
2838  N6110_SetMemory,
2839  NOTIMPLEMENTED, /* AddMemory */
2840  N6110_DeleteMemory,
2841  NOTIMPLEMENTED, /* DeleteAllMemory */
2842  N6110_GetSpeedDial,
2843  NOTIMPLEMENTED, /* SetSpeedDial */
2844  DCT3_GetSMSC,
2845  DCT3_SetSMSC,
2847  N6110_GetSMSMessage,
2848  N6110_GetNextSMSMessage,
2849  N6110_SetSMS,
2850  N6110_AddSMS,
2851  N6110_DeleteSMSMessage,
2853  NOTSUPPORTED, /* SendSavedSMS */
2854  NOTSUPPORTED, /* SetFastSMSSending */
2858  NOTSUPPORTED, /* AddSMSFolder */
2859  NOTSUPPORTED, /* DeleteSMSFolder */
2860  N6110_DialVoice,
2861  NOTIMPLEMENTED, /* DialService */
2862  N6110_AnswerCall,
2864  N6110_HoldCall,
2865  N6110_UnholdCall,
2866  N6110_ConferenceCall,
2867  N6110_SplitCall,
2868  N6110_TransferCall,
2869  N6110_SwitchCall,
2876  N6110_GetRingtone,
2877  N6110_SetRingtone,
2878  NOTSUPPORTED, /* GetRingtonesInfo */
2879  NOTSUPPORTED, /* DeleteUserRingtones */
2880  DCT3_PlayTone,
2886  NOTSUPPORTED, /* GetSyncMLSettings */
2887  NOTSUPPORTED, /* SetSyncMLSettings */
2888  NOTSUPPORTED, /* GetChatSettings */
2889  NOTSUPPORTED, /* SetChatSettings */
2890  NOTSUPPORTED, /* GetMMSSettings */
2891  NOTSUPPORTED, /* SetMMSSettings */
2892  NOTSUPPORTED, /* GetMMSFolders */
2893  NOTSUPPORTED, /* GetNextMMSFileInfo */
2894  N6110_GetBitmap,
2895  N6110_SetBitmap,
2896  NOTSUPPORTED, /* GetToDoStatus */
2897  NOTSUPPORTED, /* GetToDo */
2898  NOTSUPPORTED, /* GetNextToDo */
2899  NOTSUPPORTED, /* SetToDo */
2900  NOTSUPPORTED, /* AddToDo */
2901  NOTSUPPORTED, /* DeleteToDo */
2902  NOTSUPPORTED, /* DeleteAllToDo */
2903  NOTIMPLEMENTED, /* GetCalendarStatus */
2904  NOTIMPLEMENTED, /* GetCalendar */
2905  N6110_GetNextCalendarNote,
2906  NOTIMPLEMENTED, /* SetCalendar */
2907  N6110_AddCalendarNote,
2908  N6110_DeleteCalendarNote,
2909  NOTIMPLEMENTED, /* DeleteAllCalendar */
2910  NOTSUPPORTED, /* GetCalendarSettings */
2911  NOTSUPPORTED, /* SetCalendarSettings */
2912  NOTSUPPORTED, /* GetNoteStatus */
2913  NOTSUPPORTED, /* GetNote */
2914  NOTSUPPORTED, /* GetNextNote */
2915  NOTSUPPORTED, /* SetNote */
2916  NOTSUPPORTED, /* AddNote */
2917  NOTSUPPORTED, /* DeleteNote */
2918  NOTSUPPORTED, /* DeleteAllNotes */
2919  N6110_GetProfile,
2920  N6110_SetProfile,
2921  NOTSUPPORTED, /* GetFMStation */
2922  NOTSUPPORTED, /* SetFMStation */
2923  NOTSUPPORTED, /* ClearFMStations */
2924  NOTSUPPORTED, /* GetNextFileFolder */
2925  NOTSUPPORTED, /* GetFolderListing */
2926  NOTSUPPORTED, /* GetNextRootFolder */
2927  NOTSUPPORTED, /* SetFileAttributes */
2928  NOTSUPPORTED, /* GetFilePart */
2929  NOTSUPPORTED, /* AddFile */
2930  NOTSUPPORTED, /* SendFilePart */
2931  NOTSUPPORTED, /* GetFileSystemStatus */
2932  NOTSUPPORTED, /* DeleteFile */
2933  NOTSUPPORTED, /* AddFolder */
2934  NOTSUPPORTED, /* DeleteFolder */
2935  NOTSUPPORTED, /* GetGPRSAccessPoint */
2936  NOTSUPPORTED, /* SetGPRSAccessPoint */
2937  NOTSUPPORTED, /* GetScreenshot */
2938  NOTSUPPORTED, /* SetPower */
2939  NOTSUPPORTED, /* PostConnect */
2940  NONEFUNCTION /* PreAPICall */
2941 };
2942 
2943 #endif
2944 
2945 /* How should editor hadle tabs in this file? Add editor commands here.
2946  * vim: noexpandtab sw=8 ts=8 sts=8:
2947  */
GSM_SMSMessageType PDU
unsigned char MagicBytes[4]
Definition: n6110.h:16
GSM_SecurityCodeType * SecurityStatus
Definition: gsmstate.h:601
gboolean EnableIncomingUSSD
Definition: gsmstate.h:671
GSM_Error DCT3DCT4_ReplyGetActiveConnectSet(GSM_Protocol_Message *msg, GSM_StateMachine *s)
unsigned char Name[(GSM_MAX_RINGTONE_NAME_LENGTH+1) *2]
void GSM_SetDefaultReceivedSMSData(GSM_SMSMessage *SMS)
Definition: gsmsms.c:1092
gboolean DefaultRingtone
Definition: gammu-bitmap.h:134
GSM_Error DCT3_EnableSecurity(GSM_StateMachine *s, unsigned char status)
GSM_Profile_Feat_ID FeatureID[15]
GSM_ChargeState ChargeState
Definition: gammu-info.h:244
char HardwareCache[50]
Definition: gsmstate.h:466
const unsigned char * GSM_GetNetworkName(const char *NetworkCode)
Definition: gsmnet.c:2420
IncomingUSSDCallback IncomingUSSD
Definition: gsmstate.h:1384
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
void GSM_PhonebookFindDefaultNameNumberGroup(const GSM_MemoryEntry *entry, int *Name, int *Number, int *Group)
Definition: gsmpbk.c:78
void DumpMessage(GSM_Debug_Info *d, const unsigned char *message, const size_t messagesize)
Definition: debug.c:314
size_t PHONE_GetBitmapSize(GSM_Phone_Bitmap_Types Type, size_t Width, size_t Height)
Definition: gsmlogo.c:44
GSM_RingtoneFormat Format
GSM_Error DCT3DCT4_GetModel(GSM_StateMachine *s)
void CopyUnicodeString(unsigned char *Dest, const unsigned char *Source)
Definition: coding.c:1192
void NOKIA_DecodeSMSState(GSM_StateMachine *s, unsigned char state, GSM_SMSMessage *sms)
GSM_CallStatus Status
Definition: gammu-call.h:86
GSM_Error N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message *msg, GSM_StateMachine *s)
void * IncomingCallUserData
Definition: gsmstate.h:1386
GSM_Error DCT3_CancelCall(GSM_StateMachine *s, int ID, gboolean all)
GSM_Error NOKIA_SetIncomingUSSD(GSM_StateMachine *s, gboolean enable)
GSM_Error DCT3_PressKey(GSM_StateMachine *s, GSM_KeyCode Key, gboolean Press)
GSM_SMS_State State
GSM_MemoryType MemoryType
Definition: gammu-memory.h:415
void * IncomingUSSDUserData
Definition: gsmstate.h:1389
#define GSM_PHONEBOOK_TEXT_LENGTH
Definition: gammu-limits.h:91
GSM_Error DCT3_GetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
GSM_Error DCT3_ReplyGetWAPSettings(GSM_Protocol_Message *msg, GSM_StateMachine *s)
gboolean FileSystemRingtone
Definition: gammu-bitmap.h:139
GSM_Bitmap_Types Type
Definition: gammu-bitmap.h:107
int GSM_PackSemiOctetNumber(const unsigned char *Number, unsigned char *Output, gboolean semioctet)
Definition: coding.c:1125
char Code[GSM_SECURITY_CODE_LEN+1]
GSM_ConnectionType ConnectionType
Definition: gsmstate.h:1402
#define NOTSUPPORTED
Definition: gsmcomon.h:14
GSM_Error DCT3_ReplyGetIMEI(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_MemoryEntry * Memory
Definition: gsmstate.h:497
GSM_Error DCT3_ReplyGetDateTime(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_DialVoice(GSM_StateMachine *s, char *number, GSM_CallShowNumber ShowNumber)
GSM_Error DCT3_ReplyPlayTone(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_DecodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer)
#define N6110_FRAME_HEADER
Definition: ncommon.h:8
GSM_Error DCT3_ReplySIMLogin(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_MemoryType NOKIA_GetMemoryType(GSM_StateMachine *s, GSM_MemoryType memory_type, unsigned char *ID)
GSM_SMSMemoryStatus * SMSStatus
Definition: gsmstate.h:517
GSM_Error DCT3_GetPPM(GSM_StateMachine *s, char *value)
GSM_MultiSMSMessage * GetSMSMessage
Definition: gsmstate.h:509
unsigned char Sender[2 *(GSM_MAX_NUMBER_LENGTH+1)]
Definition: gammu-bitmap.h:164
gboolean HeadSetProfile
void NOKIA_EncodeDateTime(GSM_StateMachine *s UNUSED, unsigned char *buffer, GSM_DateTime *datetime)
Definition: nfunc.c:1007
GSM_Error DCT3_ReplyDialCommand(GSM_Protocol_Message *msg, GSM_StateMachine *s)
int DecodeWithUTF8Alphabet(const unsigned char *src, wchar_t *dest, size_t len)
Definition: coding.c:1866
GSM_Error DCT3_ReplyEnableSecurity(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error GSM_DispatchMessage(GSM_StateMachine *s)
Definition: gsmstate.c:1131
#define NONEFUNCTION
Definition: gsmcomon.h:12
GSM_Error
Definition: gammu-error.h:23
GSM_Error DCT3_GetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
#define GSM_MAX_RINGTONE_NAME_LENGTH
Definition: gammu-limits.h:232
void PHONE_EncodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:197
GSM_Error DCT3DCT4_ReplyEnableConnectFunc(GSM_Protocol_Message *msg, GSM_StateMachine *s)
gboolean FileSystemPicture
Definition: gammu-bitmap.h:144
void NOKIA_FindFeatureValue(GSM_StateMachine *s, GSM_Profile_PhoneTableValue ProfileTable[], unsigned char ID, unsigned char Value, GSM_Phone_Data *Data, gboolean CallerGroups)
FILE * df
Definition: debug.h:36
GSM_Debug_Info di
Definition: gsmstate.h:1412
const char * model
Definition: gammu-info.h:764
GSM_CallShowNumber
Definition: gammu-call.h:192
GSM_Error(* GetSMSStatus)(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
Definition: gsmstate.h:938
GSM_Error NoneReply(GSM_Protocol_Message *msg UNUSED, GSM_StateMachine *s)
Definition: pfunc.c:188
GSM_Error DCT3DCT4_ReplyDisableConnectFunc(GSM_Protocol_Message *msg, GSM_StateMachine *s)
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
GSM_SMSMessageLayout PHONE_SMSDeliver
Definition: pfunc.c:16
gboolean EnableIncomingCall
Definition: gsmstate.h:659
int LastCalendarPos
Definition: n6110.h:17
void PHONE_DecodeBitmap(GSM_Phone_Bitmap_Types Type, char *buffer, GSM_Bitmap *Bitmap)
Definition: gsmlogo.c:141
GSM_Error PHONE_Terminate(GSM_StateMachine *s)
Definition: pfunc.c:79
GSM_Error DCT3_Reset(GSM_StateMachine *s, gboolean hard)
GSM_Bitmap * Bitmap
Definition: gsmstate.h:573
const char features[]
Definition: feature_tests.c:2
GSM_Error DCT3_SetDateTime(GSM_StateMachine *s, GSM_DateTime *date_time, unsigned char msgtype)
unsigned char Location
Definition: gammu-bitmap.h:112
GSM_Error(* WriteMessage)(GSM_StateMachine *s, unsigned const char *buffer, int length, int type)
Definition: gsmstate.h:347
char IMEI[GSM_MAX_IMEI_LENGTH+1]
Definition: gsmstate.h:437
GSM_Error DCT3_ReplyDeleteSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_ReplySetAlarm(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error NOKIA_SetIncomingCall(GSM_StateMachine *s, gboolean enable)
GSM_SMSMemoryStatus LastSMSStatus
Definition: n6110.h:20
char Name[40 *2]
GSM_Error DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message *msg, GSM_StateMachine *s)
unsigned char GSM_EncodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t *maxlength)
Definition: gsmring.c:992
GSM_PhoneModel * ModelInfo
Definition: gsmstate.h:449
GSM_EntryType EntryType
Definition: gammu-memory.h:372
GSM_Error DCT3_AnswerAllCalls(GSM_StateMachine *s)
GSM_Error DCT3_ReplySetSMSC(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_SignalQuality * SignalQuality
Definition: gsmstate.h:533
GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *settings)
void NOKIA_CopyBitmap(GSM_Phone_Bitmap_Types Type, GSM_Bitmap *Bitmap, char *Buffer, size_t *Length)
Definition: gsmlogo.c:1132
unsigned char Text[GSM_MAX_UDH_LENGTH]
char NetworkCode[10]
Definition: gammu-bitmap.h:160
GSM_Error DCT3_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
unsigned char RingtoneID
Definition: gammu-bitmap.h:138
void GSM_CalendarFindDefaultTextTimeAlarmPhone(GSM_CalendarEntry *entry, int *Text, int *Time, int *Alarm, int *Phone, int *EndTime, int *Location)
Definition: gsmcal.c:279
GSM_Error DCT3DCT4_GetFirmware(GSM_StateMachine *s)
GSM_Error DCT3DCT4_ReplySetActiveConnectSet(GSM_Protocol_Message *msg, GSM_StateMachine *s)
int StatusCode
Definition: gammu-call.h:98
void GSM_ClearBatteryCharge(GSM_BatteryCharge *bat)
Definition: gsmmisc.c:784
GSM_Error N61_71_ResetPhoneSettings(GSM_StateMachine *s, GSM_ResetSettingsType Type)
unsigned char Text[(GSM_PHONEBOOK_TEXT_LENGTH+1) *2]
Definition: gammu-memory.h:399
void NOKIA_DecodeNetworkCode(const unsigned char *buffer, char *output)
Definition: gsmnet.c:2473
int gboolean
Definition: gammu-types.h:23
GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc)
void GSM_PrintBitmap(FILE *file, GSM_Bitmap *bitmap)
Definition: gsmlogo.c:257
GSM_CalendarNoteType Type
GSM_Debug_Info GSM_global_debug
Definition: debug.c:33
GSM_Error DCT3DCT4_SetCallDivert(GSM_StateMachine *s, GSM_CallDivert *divert)
void EncodeUnicode(unsigned char *dest, const char *src, size_t len)
Definition: coding.c:301
unsigned char Name[(GSM_MAX_SMS_NAME_LENGTH+1) *2]
gboolean InboxFolder
GSM_Phone Phone
Definition: gsmstate.h:1431
#define FALSE
Definition: gammu-types.h:25
GSM_Error DCT3_ReplySetWAPSettings(GSM_Protocol_Message *msg, GSM_StateMachine *s)
struct GSM_Phone_Data::@2 Priv
GSM_SecurityCodeType
gboolean NOKIA_FindPhoneFeatureValue(GSM_StateMachine *s, GSM_Profile_PhoneTableValue ProfileTable[], GSM_Profile_Feat_ID FeatureID, GSM_Profile_Feat_Value FeatureValue, unsigned char *PhoneID, unsigned char *PhoneValue)
GSM_NokiaBinaryRingtone NokiaBinary
GSM_Error DCT3_ReplyPressKey(GSM_Protocol_Message *msg, GSM_StateMachine *s)
void NOKIA_GetDefaultCallerGroupName(GSM_Bitmap *Bitmap)
Definition: nfunc.c:956
GSM_Error GSM_WaitFor(GSM_StateMachine *s, unsigned const char *buffer, size_t length, int type, int timeout, GSM_Phone_RequestID request)
Definition: gsmstate.c:1029
unsigned char Frame[50000]
GSM_Error DCT3_GetIMEI(GSM_StateMachine *s)
unsigned char Text[2 *(GSM_MAX_USSD_LENGTH+1)]
GSM_Ringtone * Ringtone
Definition: gsmstate.h:545
GSM_Error DCT3_ReplyGetAlarm(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_SetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
GSM_Phone_RequestID RequestID
Definition: gsmstate.h:685
GSM_Error DCT3_PlayTone(GSM_StateMachine *s, int Herz, unsigned char Volume, gboolean start)
GSM_Error DCT3_ReplySIMLogout(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error N61_91_ReplySetOpLogo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3DCT4_ReplyCallDivert(GSM_Protocol_Message *msg, GSM_StateMachine *s)
gboolean BitmapEnabled
Definition: gammu-bitmap.h:122
GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *Alarm, unsigned char msgtype)
GSM_Error DCT3_SetIncomingCB(GSM_StateMachine *s, gboolean enable)
GSM_Profile_Feat_Value FeatureValue[15]
GSM_SMSMessage SMS[GSM_MAX_MULTI_SMS]
GSM_CalendarType EntryType
IncomingCallCallback IncomingCall
Definition: gsmstate.h:1381
GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms)
GSM_Error DCT3DCT4_ReplyDelWAPBookmark(GSM_Protocol_Message *msg, GSM_StateMachine *s)
#define NOTIMPLEMENTED
Definition: gsmcomon.h:13
GSM_MemoryType MemoryType
Definition: gammu-memory.h:447
gboolean CarKitProfile
GSM_Protocol Protocol
Definition: gsmstate.h:1430
GSM_BatteryCharge * BatteryCharge
Definition: gsmstate.h:537
unsigned char PhoneNumber[(GSM_MAX_NUMBER_LENGTH+1) *2]
Definition: gammu-call.h:102
gboolean DefaultBitmap
Definition: gammu-bitmap.h:130
N6110_Language
Definition: n6110.h:10
GSM_Error PHONE_GetSMSFolders(GSM_StateMachine *s UNUSED, GSM_SMSFolders *folders)
Definition: pfunc.c:38
GSM_DateTime Date
Definition: gammu-memory.h:380
GSM_Error DCT3DCT4_CancelAllDiverts(GSM_StateMachine *s)
gboolean CallerGroups[5]
void NOKIA_EncodeNetworkCode(unsigned char *buffer, const char *input)
Definition: gsmnet.c:2467
int CallID
Definition: gammu-call.h:90
GSM_UDH
gboolean CallIDAvailable
Definition: gammu-call.h:94
GSM_Error DCT3DCT4_ReplySetWAPBookmark(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3DCT4_GetCallDivert(GSM_StateMachine *s, GSM_CallDivert *reqest, GSM_MultiCallDivert *response)
GSM_Error GSM_DecodeNokiaRTTLRingtone(GSM_Ringtone *ringtone, unsigned char *package, size_t maxlength UNUSED)
Definition: gsmring.c:1128
int EncodeWithUnicodeAlphabet(const unsigned char *src, wchar_t *dest)
Definition: coding.c:198
GSM_Error DCT3_GetProductCode(GSM_StateMachine *s, char *value)
GSM_Phone_Data Data
Definition: gsmstate.h:1369
GSM_Error GSM_UnpackSemiOctetNumber(GSM_Debug_Info *di, unsigned char *retval, const unsigned char *Number, size_t *pos, size_t bufferlength, gboolean semioctet)
Definition: coding.c:1028
GSM_SubCalendarEntry Entries[GSM_CALENDAR_ENTRIES]
int GSM_UnpackEightBitsToSeven(size_t offset, size_t in_length, size_t out_length, const unsigned char *input, unsigned char *output)
Definition: coding.c:953
GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message *msg, GSM_StateMachine *s)
N6110_Language PhoneLanguage
Definition: n6110.h:23
GSM_Error DCT3DCT4_ReplyGetModelFirmware(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_MemoryType MemoryType
Definition: gammu-memory.h:131
void GSM_ClearBitmap(GSM_Bitmap *bmp)
Definition: gsmlogo.c:247
double VerNum
Definition: gsmstate.h:462
gboolean GSM_IsPhoneFeatureAvailable(GSM_PhoneModel *model, GSM_Feature feature)
Definition: gsmphones.c:1026
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373
gboolean DefaultName
Definition: gammu-bitmap.h:126
GSM_Error NOKIA_ReplyGetPhoneString(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_SMSMessageLayout PHONE_SMSSubmit
Definition: pfunc.c:23
void PHONE_GetBitmapWidthHeight(GSM_Phone_Bitmap_Types Type, size_t *width, size_t *height)
Definition: gsmlogo.c:23
GSM_Error(* GetSMS)(GSM_StateMachine *s, GSM_MultiSMSMessage *sms)
Definition: gsmstate.h:942
GSM_EntryLocation Location
Definition: gammu-memory.h:376
size_t BitmapHeight
Definition: gammu-bitmap.h:152
GSM_Error DCT3_GetHardware(GSM_StateMachine *s, char *value)
void GSM_EncodeUDHHeader(GSM_Debug_Info *di, GSM_UDHHeader *UDH)
Definition: gsmsms.c:1151
GSM_Error DCT3_GetAlarm(GSM_StateMachine *s, GSM_Alarm *Alarm, unsigned char msgtype)
void * IncomingSMSUserData
Definition: gsmstate.h:1387
#define _(x)
Definition: locales.h:21
gboolean DefaultName
size_t BitmapWidth
Definition: gammu-bitmap.h:156
GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
unsigned char Text[2 *(GSM_BITMAP_TEXT_LENGTH+1)]
Definition: gammu-bitmap.h:118
GSM_Protocol_Functions * Functions
Definition: gsmstate.h:424
GSM_Error NOKIA_GetManufacturer(GSM_StateMachine *s)
#define TRUE
Definition: gammu-types.h:28
GSM_MemoryStatus * MemoryStatus
Definition: gsmstate.h:501
GSM_SecurityCodeType Type
GSM_SMSMessage * SaveSMSMessage
Definition: gsmstate.h:513
void NOKIA_DecodeDateTime(GSM_StateMachine *s, unsigned char *buffer, GSM_DateTime *datetime, gboolean seconds, gboolean DayMonthReverse)
Definition: nfunc.c:976
GSM_Error DCT3_ReplyWaitSMSC(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_Error DCT3_GetOriginalIMEI(GSM_StateMachine *s, char *value)
GSM_Error NOKIA_SetIncomingSMS(GSM_StateMachine *s, gboolean enable)
GSM_Profile * Profile
Definition: gsmstate.h:605
int EncodeWithUTF8Alphabet(unsigned long src, unsigned char *ret)
Definition: coding.c:1752
GSM_Error DCT3_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
gboolean EnableIncomingSMS
Definition: gsmstate.h:663
GSM_Error PHONE_EncodeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *SMS, unsigned char *buffer, GSM_SMSMessageLayout Layout, int *length, gboolean clear)
Definition: pfunc.c:58
unsigned char * Buffer
Definition: protocol.h:22
GSM_DisplayFeatures * DisplayFeatures
Definition: gsmstate.h:613
GSM_Error DCT3_Netmonitor(GSM_StateMachine *s, int testnumber, char *value)
#define UNUSED
Definition: gammu-misc.h:105
GSM_DisplayFeature Feature[7]
Definition: gammu-info.h:304
GSM_Error DCT3_GetNetworkInfo(GSM_StateMachine *s, GSM_NetworkInfo *netinfo)
GSM_Error DCT3DCT4_AnswerCall(GSM_StateMachine *s, int ID)
GSM_Error DCT3_GetSMSStatus(GSM_StateMachine *s, GSM_SMSMemoryStatus *status)
char Model[GSM_MAX_MODEL_LENGTH+1]
Definition: gsmstate.h:445
GSM_SpeedDial * SpeedDial
Definition: gsmstate.h:485
int DecodeWithUnicodeAlphabet(wchar_t src, unsigned char *dest)
Definition: coding.c:210
Debug_Level dl
Definition: debug.h:35
GSM_Error DCT3_ReplySetDateTime(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_MemoryType Memory
IncomingSMSCallback IncomingSMS
Definition: gsmstate.h:1382
GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message *msg, GSM_StateMachine *s)
GSM_USSDStatus Status
unsigned char Text[(GSM_MAX_CALENDAR_TEXT_LENGTH+1) *2]
void NOKIA_GetDefaultProfileName(GSM_Profile *Profile)
GSM_Error DCT3DCT4_SendDTMF(GSM_StateMachine *s, char *sequence)
const unsigned char * GSM_GetCountryName(const char *CountryCode)
Definition: gsmnet.c:2452
char ProductCodeCache[50]
Definition: gsmstate.h:470
int smprintf(GSM_StateMachine *s, const char *format,...)
Definition: debug.c:261
gboolean Active
GSM_Error DCT3_GetManufactureMonth(GSM_StateMachine *s, char *value)
GSM_CalendarEntry * Cal
Definition: gsmstate.h:549
GSM_SubMemoryEntry Entries[GSM_PHONEBOOK_ENTRIES]
Definition: gammu-memory.h:427