2 #include <string.h> /* memcpy only */
6 #include "../../../gsmstate.h"
7 #include "../../../misc/coding/coding.h"
8 #include "../../../service/sms/gsmsms.h"
9 #include "../../pfunc.h"
13 #ifdef GSM_ENABLE_NOKIA_DCT3
15 GSM_Error
DCT3_ReplyPressKey(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
17 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
19 switch (msg
.Buffer
[2]) {
21 smprintf(s
, "Pressing key OK\n");
22 if (Data
->PressKey
) return GE_NONE
;
25 smprintf(s
, "Releasing key OK\n");
26 if (!Data
->PressKey
) return GE_NONE
;
29 return GE_UNKNOWNRESPONSE
;
32 GSM_Error
DCT3_PressKey(GSM_StateMachine
*s
, GSM_KeyCode Key
, bool Press
)
34 unsigned char PressReq
[] = {
35 0x00, 0x01, 0x46, 0x00, 0x01,
37 unsigned char ReleaseReq
[] = {0x00, 0x01, 0x47, 0x00, 0x01, 0x0c};
41 s
->Phone
.Data
.PressKey
= true;
42 smprintf(s
, "Pressing key\n");
43 return GSM_WaitFor (s
, PressReq
, 6, 0xd1, 4, ID_PressKey
);
45 s
->Phone
.Data
.PressKey
= false;
46 smprintf(s
, "Releasing key\n");
47 return GSM_WaitFor (s
, ReleaseReq
, 6, 0xd1, 4, ID_PressKey
);
51 GSM_Error
DCT3_ReplyPlayTone(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
53 smprintf(s
, "Tone played\n");
57 GSM_Error
DCT3_PlayTone(GSM_StateMachine
*s
, int Herz
, unsigned char Volume
, bool start
)
60 unsigned char req
[] = {
67 error
=DCT3_EnableSecurity (s
, 0x01);
68 if (error
!=GE_NONE
) return error
;
71 /* For Herz==255*255 we have silent */
82 return GSM_WaitFor (s
, req
, 6, 0x40, 4, ID_PlayTone
);
85 #ifdef GSM_ENABLE_CELLBROADCAST
87 GSM_Error
DCT3_ReplyIncomingCB(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
93 smprintf(s
, "CB received\n");
94 CB
.Channel
= msg
.Buffer
[7];
95 i
=GSM_UnpackEightBitsToSeven(0, msg
.Buffer
[9], msg
.Buffer
[9], msg
.Buffer
+10, Buffer
);
96 i
= msg
.Buffer
[9] - 1;
98 if (Buffer
[i
] == 13) i
= i
- 1; else break;
100 DecodeDefault(CB
.Text
, Buffer
, i
+ 1, false, NULL
);
101 smprintf(s
, "Channel %i, text \"%s\"\n",CB
.Channel
,DecodeUnicodeString(CB
.Text
));
102 if (s
->Phone
.Data
.EnableIncomingCB
&& s
->User
.IncomingCB
!=NULL
) {
103 s
->User
.IncomingCB(s
->CurrentConfig
->Device
,CB
);
108 GSM_Error
DCT3_ReplySetIncomingCB(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
110 switch (msg
.Buffer
[3]) {
112 smprintf(s
, "CB set\n");
115 smprintf(s
, "CB not set\n");
118 smprintf(s
, "No network and no CB\n");
119 return GE_SECURITYERROR
;
121 return GE_UNKNOWNRESPONSE
;
126 GSM_Error
DCT3_SetIncomingCB(GSM_StateMachine
*s
, bool enable
)
128 #ifdef GSM_ENABLE_CELLBROADCAST
129 unsigned char reqOn
[] = {
130 N6110_FRAME_HEADER
, 0x20, 0x01,
131 0x01, 0x00, 0x00, 0x01, 0x01};
132 unsigned char reqOff
[] = {
133 N6110_FRAME_HEADER
, 0x20, 0x00,
134 0x00, 0x00, 0x00, 0x00, 0x00};
136 if (s
->Phone
.Data
.EnableIncomingCB
!=enable
) {
137 s
->Phone
.Data
.EnableIncomingCB
= enable
;
139 smprintf(s
, "Enabling incoming CB\n");
140 return GSM_WaitFor(s
, reqOn
, 10, 0x02, 4, ID_SetIncomingCB
);
142 smprintf(s
, "Disabling incoming CB\n");
143 return GSM_WaitFor(s
, reqOff
, 10, 0x02, 4, ID_SetIncomingCB
);
148 return GE_SOURCENOTAVAILABLE
;
152 GSM_Error
DCT3_ReplySetSMSC(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
154 smprintf(s
, "SMSC set\n");
158 GSM_Error
DCT3_SetSMSC(GSM_StateMachine
*s
, GSM_SMSC
*smsc
)
160 unsigned char req
[64] = {
161 N6110_FRAME_HEADER
, 0x30, 0x64,
164 0x00, /* SMS Message Format */
167 0,0,0,0,0,0,0,0,0,0,0,0, /* Default recipient number */
168 0,0,0,0,0,0,0,0,0,0,0,0}; /* Message Center Number */
170 req
[5] = smsc
->Location
;
171 switch (smsc
->Format
) {
172 case GSMF_Text
: req
[7] = 0x00; break;
173 case GSMF_Fax
: req
[7] = 0x22; break;
174 case GSMF_Pager
: req
[7] = 0x26; break;
175 case GSMF_Email
: req
[7] = 0x32; break;
177 req
[9] = smsc
->Validity
.Relative
;
178 req
[10] = GSM_PackSemiOctetNumber(smsc
->DefaultNumber
, req
+11, true);
179 req
[22] = GSM_PackSemiOctetNumber(smsc
->Number
, req
+23, false);
180 memcpy (req
+ 34, DecodeUnicodeString(smsc
->Name
),UnicodeLength(smsc
->Name
));
181 smprintf(s
, "Setting SMSC\n");
182 return GSM_WaitFor (s
, req
, 35+UnicodeLength(smsc
->Name
), 0x02, 4, ID_SetSMSC
);
185 GSM_Error
DCT3_ReplyEnableSecurity(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
187 smprintf(s
, "State of security commands set\n");
191 /* If you set make some things (for example, change Security Code from
192 * phone's menu, disable and enable phone), it won't answer for 0x40 frames
193 * and you won't be able to play tones, get netmonitor, etc.
194 * This function do thing called "Enabling extended security commands"
195 * and it enables 0x40 frame functions.
196 * This frame can also some other things - see below
198 GSM_Error
DCT3_EnableSecurity (GSM_StateMachine
*s
, unsigned char status
)
200 unsigned char req
[4] =
202 0x01}; /* 0x01 - on, 0x00 - off,
203 * 0x03 & 0x04 - soft & hard reset,
204 * 0x06 - CONTACT SERVICE */
206 /* 0x06 MAKES CONTACT SERVICE! BE CAREFULL! */
207 /* When use 0x03 and had during session changed time & date
208 * some phones (like 6150 or 6210) can ask for time & date after reset
209 * or disable clock on the screen
211 if (status
!=0x06) req
[3] = status
;
212 smprintf(s
, "Setting state of security commands\n");
213 return GSM_WaitFor (s
, req
, 4, 0x40, 4, ID_EnableSecurity
);
216 GSM_Error
DCT3_ReplyGetIMEI(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
218 memcpy(s
->Phone
.Data
.IMEI
,msg
.Buffer
+ 4, 16);
219 smprintf(s
, "Received IMEI %s\n",s
->Phone
.Data
.IMEI
);
223 GSM_Error
DCT3_GetIMEI (GSM_StateMachine
*s
)
225 unsigned char req
[4] = {0x00, 0x01, 0x66, 0x00};
228 if (strlen(s
->Phone
.Data
.IMEI
)!=0) return GE_NONE
;
230 error
=DCT3_EnableSecurity (s
, 0x01);
231 if (error
!=GE_NONE
) return error
;
233 smprintf(s
, "Getting IMEI\n");
234 return GSM_WaitFor (s
, req
, 4, 0x40, 2, ID_GetIMEI
);
237 GSM_Error
DCT3_ReplySIMLogin(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
239 smprintf(s
, "SIM card login\n");
243 GSM_Error
DCT3_ReplySIMLogout(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
245 smprintf(s
, "SIM card logout\n");
249 GSM_Error
DCT3_ReplyGetDateTime(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
251 smprintf(s
, "Date & time received\n");
252 if (msg
.Buffer
[4]==0x01) {
253 NOKIA_DecodeDateTime(s
, msg
.Buffer
+8, s
->Phone
.Data
.DateTime
);
256 smprintf(s
, "Not set in phone\n");
260 GSM_Error
DCT3_GetDateTime(GSM_StateMachine
*s
, GSM_DateTime
*date_time
, unsigned char msgtype
)
262 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x62};
264 s
->Phone
.Data
.DateTime
=date_time
;
265 smprintf(s
, "Getting date & time\n");
266 return GSM_WaitFor (s
, req
, 4, msgtype
, 4, ID_GetDateTime
);
269 GSM_Error
DCT3_ReplyGetAlarm(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
271 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
273 smprintf(s
, "Alarm received\n");
274 if (msg
.Buffer
[8]==0x02) {
275 smprintf(s
, " Alarm: %02d:%02d\n", msg
.Buffer
[9], msg
.Buffer
[10]);
276 Data
->Alarm
->Repeating
= true;
277 Data
->Alarm
->Text
[0] = 0;
278 Data
->Alarm
->Text
[1] = 0;
279 Data
->Alarm
->DateTime
.Hour
= msg
.Buffer
[9];
280 Data
->Alarm
->DateTime
.Minute
= msg
.Buffer
[10];
281 Data
->Alarm
->DateTime
.Second
= 0;
284 smprintf(s
, " Not set in phone\n");
288 GSM_Error
DCT3_GetAlarm(GSM_StateMachine
*s
, GSM_Alarm
*alarm
, unsigned char msgtype
)
290 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x6d};
292 if (alarm
->Location
!=1) return GE_NOTSUPPORTED
;
294 s
->Phone
.Data
.Alarm
=alarm
;
295 smprintf(s
, "Getting alarm\n");
296 return GSM_WaitFor (s
, req
, 4, msgtype
, 4, ID_GetAlarm
);
299 GSM_Error
DCT3_ReplySetDateTime(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
301 smprintf(s
, "Date & time set\n");
302 if (msg
.Buffer
[4]==0x01) {
303 smprintf(s
, "Set OK\n");
306 smprintf(s
, "Error\n");
310 GSM_Error
DCT3_SetDateTime(GSM_StateMachine
*s
, GSM_DateTime
*date_time
, unsigned char msgtype
)
312 unsigned char req
[] = {
313 N6110_FRAME_HEADER
, 0x60, 0x01, 0x01, 0x07,
314 0x00, 0x00, /* Year (0x07cf = 1999) */
315 0x00, 0x00, /* Month & Day */
316 0x00, 0x00, /* Hours & Minutes */
317 0x00}; /* Can't be seconds. Try 59 and wait 1 sec. */
319 NOKIA_EncodeDateTime(s
, req
+7, date_time
);
320 smprintf(s
, "Setting date & time\n");
321 return GSM_WaitFor (s
, req
, 14, msgtype
, 4, ID_SetDateTime
);
324 GSM_Error
DCT3_ReplySetAlarm(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
326 smprintf(s
, "Alarm set\n");
327 if (msg
.Buffer
[4]==0x01) {
328 smprintf(s
, "Set OK\n");
331 smprintf(s
, "Error\n");
335 GSM_Error
DCT3_SetAlarm(GSM_StateMachine
*s
, GSM_Alarm
*alarm
, unsigned char msgtype
)
337 unsigned char req
[] = {
338 N6110_FRAME_HEADER
, 0x6b, 0x01, 0x20, 0x03,
339 0x02, /* should be alarm on/off, but it doesn't work */
340 0x00, 0x00, /* Hours Minutes */
341 0x00}; /* Can't be seconds. Try 59 and wait 1 sec. */
343 if (alarm
->Location
!= 1) return GE_NOTSUPPORTED
;
345 req
[8] = alarm
->DateTime
.Hour
;
346 req
[9] = alarm
->DateTime
.Minute
;
348 smprintf(s
, "Setting alarm\n");
349 return GSM_WaitFor (s
, req
, 11, msgtype
, 4, ID_SetAlarm
);
352 GSM_Error
DCT3_ReplyGetSMSC(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
355 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
357 smprintf(s
, "SMSC received\n");
358 switch (msg
.Buffer
[3]) {
360 Data
->SMSC
->Format
= GSMF_Text
;
361 switch (msg
.Buffer
[6]) {
362 case 0x00: Data
->SMSC
->Format
= GSMF_Text
; break;
363 case 0x22: Data
->SMSC
->Format
= GSMF_Fax
; break;
364 case 0x26: Data
->SMSC
->Format
= GSMF_Pager
; break;
365 case 0x32: Data
->SMSC
->Format
= GSMF_Email
; break;
367 Data
->SMSC
->Validity
.VPF
= GSM_RelativeFormat
;
368 Data
->SMSC
->Validity
.Relative
= msg
.Buffer
[8];
371 while (msg
.Buffer
[i
]!=0) {i
++;}
373 if (i
>GSM_MAX_SMSC_NAME_LENGTH
) {
374 smprintf(s
, "Too long name\n");
375 return GE_UNKNOWNRESPONSE
;
377 EncodeUnicode(Data
->SMSC
->Name
,msg
.Buffer
+33,i
);
378 smprintf(s
, " Name \"%s\"\n", DecodeUnicodeString(Data
->SMSC
->Name
));
380 GSM_UnpackSemiOctetNumber(Data
->SMSC
->DefaultNumber
,msg
.Buffer
+9,true);
381 smprintf(s
, " Default number \"%s\"\n", DecodeUnicodeString(Data
->SMSC
->DefaultNumber
));
382 GSM_UnpackSemiOctetNumber(Data
->SMSC
->Number
,msg
.Buffer
+21,false);
383 smprintf(s
, " Number \"%s\"\n", DecodeUnicodeString(Data
->SMSC
->Number
));
387 smprintf(s
, "Getting SMSC failed\n");
388 return GE_INVALIDLOCATION
;
390 return GE_UNKNOWNRESPONSE
;
393 GSM_Error
DCT3_GetSMSC(GSM_StateMachine
*s
, GSM_SMSC
*smsc
)
395 unsigned char req
[] = {
396 N6110_FRAME_HEADER
, 0x33, 0x64,
397 0x00}; /* SMS Center Number. */
399 if (smsc
->Location
==0x00) return GE_INVALIDLOCATION
;
401 req
[5]=smsc
->Location
;
403 s
->Phone
.Data
.SMSC
=smsc
;
404 smprintf(s
, "Getting SMSC\n");
405 return GSM_WaitFor (s
, req
, 6, 0x02, 4, ID_GetSMSC
);
408 GSM_Error
DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
411 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
413 GSM_NetworkInfo NetInfo
;
416 smprintf(s
, "Network info received\n");
417 smprintf(s
, " Status : ");
418 switch (msg
.Buffer
[8]) {
419 case 0x01: smprintf(s
, "home network selected"); break;
420 case 0x02: smprintf(s
, "roaming network"); break;
421 case 0x03: smprintf(s
, "requesting network"); break;
422 case 0x04: smprintf(s
, "not registered in the network"); break;
423 default : smprintf(s
, "unknown");
426 smprintf(s
, " Network selection : %s\n", msg
.Buffer
[9]==1?"manual":"automatic");
427 if (msg
.Buffer
[8]<0x03) {
428 NOKIA_DecodeNetworkCode(msg
.Buffer
+14,NetInfo
.NetworkCode
);
429 sprintf(NetInfo
.CellID
, "%02x%02x", msg
.Buffer
[10], msg
.Buffer
[11]);
430 sprintf(NetInfo
.LAC
, "%02x%02x", msg
.Buffer
[12], msg
.Buffer
[13]);
431 smprintf(s
, " CellID : %s\n", NetInfo
.CellID
);
432 smprintf(s
, " LAC : %s\n", NetInfo
.LAC
);
433 smprintf(s
, " Network code : %s\n", NetInfo
.NetworkCode
);
434 smprintf(s
, " Network name for Gammu : %s ",
435 DecodeUnicodeString(GSM_GetNetworkName(NetInfo
.NetworkCode
)));
436 smprintf(s
, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo
.NetworkCode
)));
438 if (msg
.Buffer
[18]==0x00) {
439 /* In 6210 name is in "normal" Unicode */
440 memcpy(name
,msg
.Buffer
+18,msg
.Buffer
[17]*2);
441 name
[msg
.Buffer
[17]*2] =0x00;
442 name
[msg
.Buffer
[17]*2+1]=0x00;
443 smprintf(s
, " Network name for phone : %s\n",DecodeUnicodeString(name
));
445 /* In 9210 first 0x00 is cut from Unicode string */
447 memcpy(name
+1,msg
.Buffer
+18,msg
.Buffer
[17]*2);
448 name
[msg
.Buffer
[17]*2+1]=0x00;
449 name
[msg
.Buffer
[17]*2+2]=0x00;
450 smprintf(s
, " Network name for phone : %s\n",DecodeUnicodeString(name
));
455 if (Data
->RequestID
==ID_GetNetworkInfo
) {
456 Data
->NetworkInfo
->NetworkName
[0] = 0x00;
457 Data
->NetworkInfo
->NetworkName
[1] = 0x00;
458 Data
->NetworkInfo
->State
= 0;
459 switch (msg
.Buffer
[8]) {
460 case 0x01: Data
->NetworkInfo
->State
= GSM_HomeNetwork
; break;
461 case 0x02: Data
->NetworkInfo
->State
= GSM_RoamingNetwork
; break;
462 case 0x03: Data
->NetworkInfo
->State
= GSM_RequestingNetwork
; break;
463 case 0x04: Data
->NetworkInfo
->State
= GSM_NoNetwork
; break;
465 if (Data
->NetworkInfo
->State
== GSM_HomeNetwork
|| Data
->NetworkInfo
->State
== GSM_RoamingNetwork
) {
466 if (msg
.Buffer
[18]==0x00) {
467 /* In 6210 name is in "normal" Unicode */
468 memcpy(Data
->NetworkInfo
->NetworkName
,msg
.Buffer
+18,msg
.Buffer
[17]*2);
469 Data
->NetworkInfo
->NetworkName
[msg
.Buffer
[17]*2] = 0x00;
470 Data
->NetworkInfo
->NetworkName
[msg
.Buffer
[17]*2+1] = 0x00;
472 /* In 9210 first 0x00 is cut from Unicode string */
473 Data
->NetworkInfo
->NetworkName
[0] = 0;
474 memcpy(Data
->NetworkInfo
->NetworkName
+1,msg
.Buffer
+18,msg
.Buffer
[17]*2);
475 Data
->NetworkInfo
->NetworkName
[msg
.Buffer
[17]*2+1]=0x00;
476 Data
->NetworkInfo
->NetworkName
[msg
.Buffer
[17]*2+2]=0x00;
478 NOKIA_DecodeNetworkCode(msg
.Buffer
+14,Data
->NetworkInfo
->NetworkCode
);
479 sprintf(Data
->NetworkInfo
->CellID
, "%02x%02x", msg
.Buffer
[10], msg
.Buffer
[11]);
480 sprintf(Data
->NetworkInfo
->LAC
, "%02x%02x", msg
.Buffer
[12], msg
.Buffer
[13]);
484 if (Data
->RequestID
==ID_GetBitmap
) {
485 if (msg
.Buffer
[4]==0x02) {
486 smprintf(s
, "Operator logo available\n");
488 /* skip network info */
489 count
+= msg
.Buffer
[count
];
491 Data
->Bitmap
->Width
= msg
.Buffer
[count
++];
492 Data
->Bitmap
->Height
= msg
.Buffer
[count
++];
494 PHONE_DecodeBitmap(GSM_Nokia7110OperatorLogo
,msg
.Buffer
+count
,Data
->Bitmap
);
495 NOKIA_DecodeNetworkCode(msg
.Buffer
+14,Data
->Bitmap
->NetworkCode
);
497 Data
->Bitmap
->Width
= 78;
498 Data
->Bitmap
->Height
= 21;
499 GSM_ClearBitmap(Data
->Bitmap
);
500 strcpy(Data
->Bitmap
->NetworkCode
,"000 00");
506 GSM_Error
DCT3_GetNetworkInfo(GSM_StateMachine
*s
, GSM_NetworkInfo
*netinfo
)
508 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x70};
510 s
->Phone
.Data
.NetworkInfo
=netinfo
;
511 smprintf(s
, "Getting network info\n");
512 return GSM_WaitFor (s
, req
, 4, 0x0a, 4, ID_GetNetworkInfo
);
515 GSM_Error
DCT3_ReplyDialCommand(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
517 smprintf(s
, "Answer for call commands\n");
521 GSM_Error
DCT3_DialVoice(GSM_StateMachine
*s
, char *number
, GSM_CallShowNumber ShowNumber
)
525 unsigned char req
[64] = {
527 0x01}; /* call command */
529 if (ShowNumber
!= GN_CALL_Default
) return GE_NOTSUPPORTED
;
531 error
=DCT3_EnableSecurity (s
, 0x01);
532 if (error
!=GE_NONE
) return error
;
534 for (i
=0; i
< strlen(number
) ; i
++) req
[4+i
]=number
[i
];
537 smprintf(s
, "Making voice call\n");
538 return GSM_WaitFor (s
, req
, 4+strlen(number
)+1, 0x40, 4, ID_DialVoice
);
541 static GSM_Error
DCT3_CancelAllCalls(GSM_StateMachine
*s
)
544 unsigned char req
[64] = {
546 0x03}; /* call command */
548 error
=DCT3_EnableSecurity (s
, 0x01);
549 if (error
!=GE_NONE
) return error
;
551 smprintf(s
, "Canceling calls\n");
552 return GSM_WaitFor (s
, req
, 4, 0x40, 4, ID_CancelCall
);
555 GSM_Error
DCT3_CancelCall(GSM_StateMachine
*s
, int ID
, bool all
)
557 if (!all
) return DCT3DCT4_CancelCall(s
,ID
);
558 return DCT3_CancelAllCalls(s
);
561 GSM_Error
DCT3_AnswerAllCalls(GSM_StateMachine
*s
)
564 unsigned char req
[64] = {
566 0x02}; /* call command */
568 error
=DCT3_EnableSecurity (s
, 0x01);
569 if (error
!=GE_NONE
) return error
;
571 smprintf(s
, "Answering calls\n");
572 return GSM_WaitFor (s
, req
, 4, 0x40, 4, ID_AnswerCall
);
575 GSM_Error
DCT3_Reset(GSM_StateMachine
*s
, bool hard
)
580 error
=DCT3_EnableSecurity(s
, 0x04);
582 error
=DCT3_EnableSecurity(s
, 0x03);
584 if (error
== GE_NONE
) {
585 s
->Phone
.Data
.EnableIncomingSMS
= false;
586 s
->Phone
.Data
.EnableIncomingCB
= false;
591 GSM_Error
DCT3_ReplyGetWAPBookmark(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
593 return DCT3DCT4_ReplyGetWAPBookmark (msg
,s
,false);
596 GSM_Error
DCT3_SetWAPBookmark(GSM_StateMachine
*s
, GSM_WAPBookmark
*bookmark
)
601 unsigned char req
[600] = { N6110_FRAME_HEADER
, 0x09 };
603 /* We have to enable WAP frames in phone */
604 error
=DCT3DCT4_EnableWAP(s
);
605 if (error
!=GE_NONE
) return error
;
607 if (bookmark
->Location
== 0) {
610 location
= bookmark
->Location
- 1;
613 req
[count
++] = (location
& 0xff00) >> 8;
614 req
[count
++] = (location
& 0x00ff);
616 req
[count
++] = UnicodeLength(bookmark
->Title
);
617 CopyUnicodeString(req
+count
,bookmark
->Title
);
618 count
= count
+ 2*UnicodeLength(bookmark
->Title
);
620 req
[count
++] = UnicodeLength(bookmark
->Address
);
621 CopyUnicodeString(req
+count
,bookmark
->Address
);
622 count
= count
+ 2*UnicodeLength(bookmark
->Address
);
625 req
[count
++] = 0x01; req
[count
++] = 0x80; req
[count
++] = 0x00;
626 req
[count
++] = 0x00; req
[count
++] = 0x00; req
[count
++] = 0x00;
627 req
[count
++] = 0x00; req
[count
++] = 0x00; req
[count
++] = 0x00;
629 smprintf(s
, "Setting WAP bookmark\n");
630 return GSM_WaitFor (s
, req
, count
, 0x3f, 4, ID_SetWAPBookmark
);
633 GSM_Error
DCT3_ReplyGetWAPSettings(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
637 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
638 #ifdef GSM_ENABLE_NOKIA6110
639 GSM_Phone_N6110Data
*Priv6110
= &s
->Phone
.Data
.Priv
.N6110
;
641 #ifdef GSM_ENABLE_NOKIA7110
642 GSM_Phone_N7110Data
*Priv7110
= &s
->Phone
.Data
.Priv
.N7110
;
645 switch(msg
.Buffer
[3]) {
647 smprintf(s
, "WAP settings part 1 received OK\n");
651 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[0].Title
,false);
652 smprintf(s
, "Title: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[0].Title
));
654 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[0].HomePage
,false);
655 smprintf(s
, "Homepage: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[0].HomePage
));
657 smprintf(s
, "Connection type: ");
658 switch (msg
.Buffer
[tmp
]) {
659 case 0x00: smprintf(s
, "temporary\n"); break;
660 case 0x01: smprintf(s
, "continuous\n"); break;
661 default: smprintf(s
, "unknown\n");
663 smprintf(s
, "Connection security: ");
664 switch (msg
.Buffer
[tmp
+13]) {
665 case 0x00: smprintf(s
, "off\n"); break;
666 case 0x01: smprintf(s
, "on\n"); break;
667 default: smprintf(s
, "unknown\n");
670 Data
->WAPSettings
->Settings
[0].IsContinuous
= false;
671 if (msg
.Buffer
[tmp
] == 0x01) Data
->WAPSettings
->Settings
[0].IsContinuous
= true;
672 Data
->WAPSettings
->Settings
[0].IsSecurity
= false;
673 if (msg
.Buffer
[tmp
+13] == 0x01) Data
->WAPSettings
->Settings
[0].IsSecurity
= true;
675 /* I'm not sure here. Experimental values from 6210 5.56 */
676 // tmp2 = DecodeUnicodeLength(Data->WAPSettings->Settings[0].Title);
677 // if (tmp2 != 0) tmp2 --;
679 if (!(UnicodeLength(Data
->WAPSettings
->Settings
[0].Title
)) % 2) tmp
++;
680 if (UnicodeLength(Data
->WAPSettings
->Settings
[0].HomePage
)!=0) tmp
++;
682 smprintf(s
, "ID for writing %i\n",msg
.Buffer
[tmp
+5]);
684 smprintf(s
, "Current set location in phone %i\n",msg
.Buffer
[tmp
+6]);
686 smprintf(s
, "1 location %i\n",msg
.Buffer
[tmp
+8]);
687 smprintf(s
, "2 location %i\n",msg
.Buffer
[tmp
+9]);
688 smprintf(s
, "3 location %i\n",msg
.Buffer
[tmp
+10]);
689 smprintf(s
, "4 location %i\n",msg
.Buffer
[tmp
+11]);
690 #ifdef GSM_ENABLE_NOKIA7110
691 if (strstr(N7110Phone
.models
, Data
->ModelInfo
->model
) != NULL
) {
692 Priv7110
->WAPLocations
.ID
= msg
.Buffer
[tmp
+5];
693 Priv7110
->WAPLocations
.CurrentLocation
= msg
.Buffer
[tmp
+6];
694 Priv7110
->WAPLocations
.Locations
[0] = msg
.Buffer
[tmp
+8];
695 Priv7110
->WAPLocations
.Locations
[1] = msg
.Buffer
[tmp
+9];
696 Priv7110
->WAPLocations
.Locations
[2] = msg
.Buffer
[tmp
+10];
697 Priv7110
->WAPLocations
.Locations
[3] = msg
.Buffer
[tmp
+11];
699 // Priv7110->WAPLocations.CurrentLocation = msg.Buffer[tmp2+1];
700 // Priv7110->WAPLocations.Locations[0] = msg.Buffer[tmp2+3];
701 // Priv7110->WAPLocations.Locations[1] = msg.Buffer[tmp2+4];
702 // Priv7110->WAPLocations.Locations[2] = msg.Buffer[tmp2+5];
703 // Priv7110->WAPLocations.Locations[3] = msg.Buffer[tmp2+6];
706 #ifdef GSM_ENABLE_NOKIA6110
707 if (strstr(N6110Phone
.models
, Data
->ModelInfo
->model
) != NULL
) {
708 Priv6110
->WAPLocations
.ID
= msg
.Buffer
[tmp
+5];
709 Priv6110
->WAPLocations
.CurrentLocation
= msg
.Buffer
[tmp
+6];
710 Priv6110
->WAPLocations
.Locations
[0] = msg
.Buffer
[tmp
+8];
711 Priv6110
->WAPLocations
.Locations
[1] = msg
.Buffer
[tmp
+9];
712 Priv6110
->WAPLocations
.Locations
[2] = msg
.Buffer
[tmp
+10];
713 Priv6110
->WAPLocations
.Locations
[3] = msg
.Buffer
[tmp
+11];
718 smprintf(s
, "WAP settings part 1 receiving error\n");
719 switch (msg
.Buffer
[4]) {
721 smprintf(s
, "Security error. Inside WAP settings menu\n");
722 return GE_INSIDEPHONEMENU
;
724 smprintf(s
, "Invalid or empty\n");
725 return GE_INVALIDLOCATION
;
727 smprintf(s
, "ERROR: unknown %i\n",msg
.Buffer
[4]);
728 return GE_UNKNOWNRESPONSE
;
732 smprintf(s
, "WAP settings part 2 received OK\n");
733 Number
= Data
->WAPSettings
->Number
;
734 switch (msg
.Buffer
[5]) {
736 Data
->WAPSettings
->Settings
[Number
].Bearer
= WAPSETTINGS_BEARER_SMS
;
737 smprintf(s
, "Settings for SMS bearer:\n");
740 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].Service
,false);
741 smprintf(s
, "Service number: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Service
));
743 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].Server
,false);
744 smprintf(s
, "Server number: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Server
));
747 Data
->WAPSettings
->Settings
[Number
].Bearer
= WAPSETTINGS_BEARER_DATA
;
748 smprintf(s
, "Settings for data bearer:\n");
749 Data
->WAPSettings
->Settings
[Number
].ManualLogin
= false;
752 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].IPAddress
,false);
753 smprintf(s
, "IP address: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].IPAddress
));
755 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].DialUp
,false);
756 smprintf(s
, "Dial-up number: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].DialUp
));
758 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].User
,false);
759 smprintf(s
, "User name: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].User
));
761 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].Password
,false);
762 smprintf(s
, "Password: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Password
));
764 smprintf(s
, "Authentication type: ");
765 switch (msg
.Buffer
[6]) {
766 case 0x00: smprintf(s
, "normal\n"); break;
767 case 0x01: smprintf(s
, "secure\n"); break;
768 default: smprintf(s
, "unknown\n"); break;
770 smprintf(s
, "Data call type: ");
771 switch (msg
.Buffer
[7]) {
772 case 0x00: smprintf(s
, "analogue\n"); break;
773 case 0x01: smprintf(s
, "ISDN\n"); break;
774 default: smprintf(s
, "unknown\n"); break;
776 smprintf(s
, "Data call speed: ");
777 switch (msg
.Buffer
[9]) {
778 case 0x01: smprintf(s
, "9600\n"); break;
779 case 0x02: smprintf(s
, "14400\n"); break;
780 default: smprintf(s
, "unknown\n"); break;
783 Data
->WAPSettings
->Settings
[Number
].IsNormalAuthentication
=true;
784 if (msg
.Buffer
[6]==0x01) Data
->WAPSettings
->Settings
[Number
].IsNormalAuthentication
=false;
785 Data
->WAPSettings
->Settings
[Number
].IsISDNCall
=false;
786 if (msg
.Buffer
[7]==0x01) Data
->WAPSettings
->Settings
[Number
].IsISDNCall
=true;
787 Data
->WAPSettings
->Settings
[Number
].Speed
= WAPSETTINGS_SPEED_9600
;
788 if (msg
.Buffer
[9]==0x02) Data
->WAPSettings
->Settings
[Number
].Speed
= WAPSETTINGS_SPEED_14400
;
791 Data
->WAPSettings
->Settings
[Number
].Bearer
=WAPSETTINGS_BEARER_USSD
;
792 smprintf(s
, "Settings for USSD bearer:\n");
794 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].Service
,false);
796 if (msg
.Buffer
[6]==0x01)
797 smprintf(s
, "Service number: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Service
));
799 smprintf(s
, "IP address: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Service
));
801 Data
->WAPSettings
->Settings
[Number
].IsIP
=true;
802 if (msg
.Buffer
[6]==0x01) Data
->WAPSettings
->Settings
[Number
].IsIP
=false;
803 NOKIA_GetUnicodeString(s
, &tmp
, msg
.Buffer
, Data
->WAPSettings
->Settings
[Number
].Code
,false);
804 smprintf(s
, "Service code: \"%s\"\n",DecodeUnicodeString(Data
->WAPSettings
->Settings
[Number
].Code
));
806 Data
->WAPSettings
->Number
++;
809 smprintf(s
, "Incorrect WAP settings location\n");
812 return GE_UNKNOWNRESPONSE
;
815 GSM_Error
DCT3_GetWAPSettings(GSM_StateMachine
*s
, GSM_MultiWAPSettings
*settings
)
817 #ifdef GSM_ENABLE_NOKIA6110
818 GSM_Phone_N6110Data
*Priv6110
= &s
->Phone
.Data
.Priv
.N6110
;
820 #ifdef GSM_ENABLE_NOKIA7110
821 GSM_Phone_N7110Data
*Priv7110
= &s
->Phone
.Data
.Priv
.N7110
;
825 unsigned char req
[] = {
826 N6110_FRAME_HEADER
,0x15,
827 0x00}; /* Location */
828 unsigned char req2
[] = {
829 N6110_FRAME_HEADER
,0x1b,
830 0x00}; /* Location */
832 /* We have to enable WAP frames in phone */
833 error
=DCT3DCT4_EnableWAP(s
);
834 if (error
!=GE_NONE
) return error
;
836 s
->Phone
.Data
.WAPSettings
= settings
;
837 settings
->Number
= 0;
839 req
[4] = settings
->Location
-1;
840 smprintf(s
, "Getting WAP settings part 1\n");
841 error
= GSM_WaitFor (s
, req
, 5, 0x3f, 4, ID_GetWAPSettings
);
842 if (error
!= GE_NONE
) return error
;
844 #ifdef GSM_ENABLE_NOKIA7110
845 if (strstr(N7110Phone
.models
, s
->Phone
.Data
.ModelInfo
->model
) != NULL
) {
847 req2
[4] = Priv7110
->WAPLocations
.Locations
[i
];
848 smprintf(s
, "Getting WAP settings part 2\n");
849 error
=GSM_WaitFor (s
, req2
, 5, 0x3f, 4, ID_GetWAPSettings
);
850 if (error
!= GE_NONE
) return error
;
851 if (Priv7110
->WAPLocations
.Locations
[i
] == Priv7110
->WAPLocations
.CurrentLocation
) {
852 settings
->ActiveBearer
= settings
->Settings
[settings
->Number
-1].Bearer
;
857 #ifdef GSM_ENABLE_NOKIA6110
858 if (strstr(N6110Phone
.models
, s
->Phone
.Data
.ModelInfo
->model
) != NULL
) {
860 req2
[4] = Priv6110
->WAPLocations
.Locations
[i
];
861 smprintf(s
, "Getting WAP settings part 2\n");
862 error
=GSM_WaitFor (s
, req2
, 5, 0x3f, 4, ID_GetWAPSettings
);
863 if (error
!= GE_NONE
) return error
;
864 if (Priv6110
->WAPLocations
.Locations
[i
] == Priv6110
->WAPLocations
.CurrentLocation
) {
865 settings
->ActiveBearer
= settings
->Settings
[settings
->Number
-1].Bearer
;
870 if (error
== GE_NONE
) {
872 CopyUnicodeString(settings
->Settings
[i
].Title
,settings
->Settings
[0].Title
);
873 CopyUnicodeString(settings
->Settings
[i
].HomePage
,settings
->Settings
[0].HomePage
);
874 settings
->Settings
[i
].IsContinuous
= settings
->Settings
[0].IsContinuous
;
875 settings
->Settings
[i
].IsSecurity
= settings
->Settings
[0].IsSecurity
;
877 error
= DCT3DCT4_GetActiveWAPMMSSet(s
);
882 GSM_Error
DCT3_ReplySetWAPSettings(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
884 switch(msg
.Buffer
[3]) {
886 smprintf(s
, "WAP settings part 1 set OK\n");
889 smprintf(s
, "WAP settings part 1 setting error\n");
890 switch (msg
.Buffer
[4]) {
892 smprintf(s
, "Security error. Inside WAP settings menu\n");
893 return GE_INSIDEPHONEMENU
;
895 smprintf(s
, "Incorrect data\n");
898 smprintf(s
, "ERROR: unknown %i\n",msg
.Buffer
[4]);
899 return GE_UNKNOWNRESPONSE
;
902 smprintf(s
, "WAP settings part 2 set OK\n");
905 return GE_UNKNOWNRESPONSE
;
908 GSM_Error
DCT3_SetWAPSettings(GSM_StateMachine
*s
, GSM_MultiWAPSettings
*settings
)
910 #ifdef GSM_ENABLE_NOKIA6110
911 GSM_Phone_N6110Data
*Priv6110
= &s
->Phone
.Data
.Priv
.N6110
;
913 #ifdef GSM_ENABLE_NOKIA7110
914 GSM_Phone_N7110Data
*Priv7110
= &s
->Phone
.Data
.Priv
.N7110
;
917 GSM_MultiWAPSettings settings2
;
918 int i
,pos
,phone1
=-1,phone2
=-1,phone3
=-1;
919 int ID
=0,locations
[4],loc1
=-1,loc2
=-1,loc3
=-1;
920 unsigned char req
[] = {
921 N6110_FRAME_HEADER
,0x15,
922 0x00}; /* Location */
923 unsigned char req2
[] = {
924 N6110_FRAME_HEADER
,0x1b,
925 0x00}; /* Location */
926 unsigned char SetReq
[200] = {
927 N7110_FRAME_HEADER
, 0x18,
928 0x00}; /* Location */
929 unsigned char SetReq2
[200] = {
930 N7110_FRAME_HEADER
, 0x1e,
931 0x00}; /* Location */
933 /* We have to enable WAP frames in phone */
934 error
=DCT3DCT4_EnableWAP(s
);
935 if (error
!=GE_NONE
) return error
;
937 s
->Phone
.Data
.WAPSettings
= &settings2
;
938 settings2
.Number
= 0;
940 req
[4] = settings
->Location
-1;
941 smprintf(s
, "Getting WAP settings part 1\n");
942 error
= GSM_WaitFor (s
, req
, 6, 0x3f, 4, ID_GetWAPSettings
);
943 if (error
!= GE_NONE
) return error
;
945 #ifdef GSM_ENABLE_NOKIA6110
946 if (strstr(N6110Phone
.models
, s
->Phone
.Data
.ModelInfo
->model
) != NULL
) {
947 for (i
=0;i
<4;i
++) locations
[i
] = Priv6110
->WAPLocations
.Locations
[i
];
948 ID
= Priv6110
->WAPLocations
.ID
;
951 #ifdef GSM_ENABLE_NOKIA7110
952 if (strstr(N7110Phone
.models
, s
->Phone
.Data
.ModelInfo
->model
) != NULL
) {
953 for (i
=0;i
<4;i
++) locations
[i
] = Priv7110
->WAPLocations
.Locations
[i
];
954 ID
= Priv7110
->WAPLocations
.ID
;
958 /* Now we get info about supported types by phone and their locations */
960 settings2
.Number
= 0;
961 settings2
.Settings
[0].Bearer
= 0;
962 req2
[4] = locations
[i
];
963 smprintf(s
, "Getting WAP settings part 2\n");
964 error
=GSM_WaitFor (s
, req2
, 6, 0x3f, 4, ID_GetWAPSettings
);
965 if (error
!= GE_NONE
) return error
;
966 switch (settings2
.Settings
[0].Bearer
) {
967 case WAPSETTINGS_BEARER_DATA
: phone1
= locations
[i
]; break;
968 case WAPSETTINGS_BEARER_SMS
: phone2
= locations
[i
]; break;
969 case WAPSETTINGS_BEARER_USSD
: phone3
= locations
[i
]; break;
972 if (error
!= GE_NONE
) return error
;
975 /* We have some phone locations and some data to set. We try to
976 * find info about locations in phone used to write concrete bearers
978 for (i
=0;i
<settings
->Number
;i
++) {
979 if (settings
->Settings
[i
].Bearer
== WAPSETTINGS_BEARER_DATA
) {
980 if (phone1
!= -1) loc1
=i
;
982 if (settings
->Settings
[i
].Bearer
== WAPSETTINGS_BEARER_SMS
) {
983 if (phone2
!= -1) loc2
=i
;
985 if (settings
->Settings
[i
].Bearer
== WAPSETTINGS_BEARER_USSD
) {
986 if (phone3
!= -1) loc3
=i
;
991 memset(SetReq
+ pos
, 0, 200 - pos
);
992 SetReq
[4] = settings
->Location
- 1;
995 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc1
].Title
, false);
997 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc1
].HomePage
, false);
998 if (settings
->Settings
[loc1
].IsContinuous
) SetReq
[pos
] = 0x01;
1002 SetReq
[pos
] = phone1
; /* bearer */
1003 switch (settings
->ActiveBearer
) {
1004 case WAPSETTINGS_BEARER_DATA
:
1005 if (loc1
!= -1) SetReq
[pos
] = phone1
;
1007 case WAPSETTINGS_BEARER_SMS
:
1008 if (loc2
!= -1) SetReq
[pos
] = phone2
;
1010 case WAPSETTINGS_BEARER_USSD
:
1011 if (loc3
!= -1) SetReq
[pos
] = phone3
;
1017 if (settings
->Settings
[loc1
].IsSecurity
) SetReq
[pos
] = 0x01;
1019 } else if (loc2
!= -1) {
1021 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc2
].Title
, false);
1023 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc2
].HomePage
, false);
1024 if (settings
->Settings
[loc2
].IsContinuous
) SetReq
[pos
] = 0x01;
1028 SetReq
[pos
] = phone2
; /* bearer */
1029 switch (settings
->ActiveBearer
) {
1030 case WAPSETTINGS_BEARER_DATA
:
1031 if (loc1
!= -1) SetReq
[pos
] = phone1
;
1033 case WAPSETTINGS_BEARER_SMS
:
1034 if (loc2
!= -1) SetReq
[pos
] = phone2
;
1036 case WAPSETTINGS_BEARER_USSD
:
1037 if (loc3
!= -1) SetReq
[pos
] = phone3
;
1043 if (settings
->Settings
[loc2
].IsSecurity
) SetReq
[pos
] = 0x01;
1045 } else if (loc3
!= -1) {
1047 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc3
].Title
, false);
1049 pos
+= NOKIA_SetUnicodeString(s
, SetReq
+ pos
, settings
->Settings
[loc3
].HomePage
, false);
1050 if (settings
->Settings
[loc3
].IsContinuous
) SetReq
[pos
] = 0x01;
1054 SetReq
[pos
] = phone3
; /* bearer */
1055 switch (settings
->ActiveBearer
) {
1056 case WAPSETTINGS_BEARER_DATA
:
1057 if (loc1
!= -1) SetReq
[pos
] = phone1
;
1059 case WAPSETTINGS_BEARER_SMS
:
1060 if (loc2
!= -1) SetReq
[pos
] = phone2
;
1062 case WAPSETTINGS_BEARER_USSD
:
1063 if (loc3
!= -1) SetReq
[pos
] = phone3
;
1069 if (settings
->Settings
[loc3
].IsSecurity
) SetReq
[pos
] = 0x01;
1072 return GE_UNKNOWN
; /* We have to have write something known */
1074 memcpy(SetReq
+ pos
, "\x01\x80\x00\x00\x00\x00\x00\x00\x00", 9);
1077 smprintf(s
, "Writing WAP settings part 1\n");
1078 error
=GSM_WaitFor (s
, SetReq
, pos
, 0x3f, 4, ID_SetWAPSettings
);
1079 if (error
!= GE_NONE
) return error
;
1084 memset(SetReq2
+ pos
, 0, 200 - pos
);
1085 SetReq2
[pos
++] = phone1
;
1086 SetReq2
[pos
++] = 0x02;
1087 SetReq2
[pos
++] = 0x01; /* GSMdata */
1089 if (!settings
->Settings
[loc1
].IsNormalAuthentication
) SetReq2
[pos
] = 0x01;
1093 if (settings
->Settings
[loc1
].IsISDNCall
) SetReq2
[pos
] = 0x01;
1097 switch (settings
->Settings
[loc1
].Speed
) {
1098 case WAPSETTINGS_SPEED_9600
: SetReq2
[pos
++] = 0x01; break;
1099 case WAPSETTINGS_SPEED_14400
: SetReq2
[pos
++] = 0x02; break;
1100 default : SetReq2
[pos
++] = 0x02; break;
1102 switch (settings
->Settings
[loc1
].Speed
) {
1103 case WAPSETTINGS_SPEED_9600
: SetReq2
[pos
++] = 0x01; break;
1104 case WAPSETTINGS_SPEED_14400
: SetReq2
[pos
++] = 0x02; break;
1105 default : SetReq2
[pos
++] = 0x02; break;
1110 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc1
].IPAddress
, false);
1112 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc1
].DialUp
, false);
1114 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc1
].User
, false);
1116 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc1
].Password
, false);
1118 memcpy(SetReq2
+ pos
, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
1120 smprintf(s
, "Writing WAP settings part 2 (Data bearer)\n");
1121 error
=GSM_WaitFor (s
, SetReq2
, pos
, 0x3f, 4, ID_SetWAPSettings
);
1122 if (error
!= GE_NONE
) return error
;
1127 memset(SetReq2
+ pos
, 0, 200 - pos
);
1128 SetReq2
[pos
++] = phone2
;
1129 SetReq2
[pos
++] = 0x02;
1130 SetReq2
[pos
++] = 0x00; /* SMS */
1132 /* Service number */
1133 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc2
].Service
, false);
1135 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc2
].Server
, false);
1137 memcpy(SetReq2
+ pos
, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
1139 smprintf(s
, "Writing WAP settings part 2 (SMS bearer)\n");
1140 error
=GSM_WaitFor (s
, SetReq2
, pos
, 0x3f, 4, ID_SetWAPSettings
);
1141 if (error
!= GE_NONE
) return error
;
1146 memset(SetReq2
+ pos
, 0, 200 - pos
);
1147 SetReq2
[pos
++] = phone3
;
1148 SetReq2
[pos
++] = 0x02;
1149 SetReq2
[pos
++] = 0x02; /* USSD */
1151 if (!settings
->Settings
[loc3
].IsIP
) SetReq2
[pos
] = 0x01;
1155 /* Service number or IP address */
1156 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc3
].Service
, false);
1158 pos
+= NOKIA_SetUnicodeString(s
, SetReq2
+ pos
, settings
->Settings
[loc3
].Code
, false);
1160 memcpy(SetReq2
+ pos
, "\x80\x00\x00\x00\x00\x00\x00\x00", 8);
1162 smprintf(s
, "Writing WAP settings part 2 (USSD bearer)\n");
1163 error
=GSM_WaitFor (s
, SetReq2
, pos
, 0x3f, 4, ID_SetWAPSettings
);
1164 if (error
!= GE_NONE
) return error
;
1166 return DCT3DCT4_SetActiveWAPMMSSet(s
, settings
, false);
1169 GSM_Error
DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1171 switch (msg
.Buffer
[3]) {
1173 smprintf(s
, "SMS sent OK\n");
1174 if (s
->User
.SendSMSStatus
!=NULL
) s
->User
.SendSMSStatus(s
->CurrentConfig
->Device
,0);
1177 smprintf(s
, "Error %i\n",msg
.Buffer
[6]);
1178 if (s
->User
.SendSMSStatus
!=NULL
) s
->User
.SendSMSStatus(s
->CurrentConfig
->Device
,msg
.Buffer
[6]);
1181 return GE_UNKNOWNRESPONSE
;
1184 GSM_Error
DCT3_SendSMSMessage(GSM_StateMachine
*s
, GSM_SMSMessage
*sms
)
1188 unsigned char req
[256] = { N6110_FRAME_HEADER
, 0x01, 0x02, 0x00 };
1190 error
=PHONE_EncodeSMSFrame(s
,sms
,req
+6,PHONE_SMSSubmit
,&length
, true);
1191 if (error
!= GE_NONE
) return error
;
1193 smprintf(s
, "Sending sms\n");
1194 return s
->Protocol
.Functions
->WriteMessage(s
, req
, 6+length
, 0x02);
1197 GSM_Error
DCT3_ReplyNetmonitor(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1199 switch (msg
.Buffer
[3]) {
1201 smprintf(s
, "Netmonitor correctly set\n");
1204 smprintf(s
, "Menu %i\n",msg
.Buffer
[3]);
1205 smprintf(s
, "%s\n",msg
.Buffer
+4);
1206 strcpy(s
->Phone
.Data
.Netmonitor
,msg
.Buffer
+4);
1212 GSM_Error
DCT3_Netmonitor(GSM_StateMachine
*s
, int testnumber
, char *value
)
1215 unsigned char req
[] = {
1217 0x00}; /* Test number */
1221 error
=DCT3_EnableSecurity (s
, 0x01);
1222 if (error
!= GE_NONE
) return error
;
1224 req
[3] = testnumber
;
1226 smprintf(s
, "Getting netmonitor test\n");
1227 s
->Phone
.Data
.Netmonitor
= value
;
1228 return GSM_WaitFor (s
, req
, 4, 0x40, 4, ID_Netmonitor
);
1231 GSM_Error
DCT3_GetManufactureMonth(GSM_StateMachine
*s
, char *value
)
1235 error
=DCT3_EnableSecurity (s
, 0x01);
1236 if (error
!= GE_NONE
) return error
;
1237 return NOKIA_GetPhoneString(s
,"\x00\x01\xCC\x02",4,0x40,value
,ID_GetManufactureMonth
,5);
1240 GSM_Error
DCT3_GetProductCode(GSM_StateMachine
*s
, char *value
)
1244 if (strlen(s
->Phone
.Data
.ProductCodeCache
)!=0) {
1245 strcpy(value
,s
->Phone
.Data
.ProductCodeCache
);
1249 error
=DCT3_EnableSecurity (s
, 0x01);
1250 if (error
!= GE_NONE
) return error
;
1251 return NOKIA_GetPhoneString(s
,"\x00\x01\xCA\x01",4,0x40,value
,ID_GetProductCode
,5);
1254 GSM_Error
DCT3_GetOriginalIMEI(GSM_StateMachine
*s
, char *value
)
1258 error
=DCT3_EnableSecurity (s
, 0x01);
1259 if (error
!= GE_NONE
) return error
;
1260 return NOKIA_GetPhoneString(s
,"\x00\x01\xCC\x01",4,0x40,value
,ID_GetOriginalIMEI
,5);
1263 GSM_Error
DCT3_GetHardware(GSM_StateMachine
*s
, char *value
)
1267 if (strlen(s
->Phone
.Data
.HardwareCache
)!=0) {
1268 strcpy(value
,s
->Phone
.Data
.HardwareCache
);
1272 error
=DCT3_EnableSecurity (s
, 0x01);
1273 if (error
!= GE_NONE
) return error
;
1274 return NOKIA_GetPhoneString(s
,"\x00\x01\xC8\x05",4,0x40,value
,ID_GetHardware
,5);
1277 GSM_Error
DCT3_GetPPM(GSM_StateMachine
*s
, char *value
)
1281 error
=DCT3_EnableSecurity (s
, 0x01);
1282 if (error
!= GE_NONE
) return error
;
1283 return NOKIA_GetPhoneString(s
,"\x00\x01\xC8\x12",4,0x40,value
,ID_GetPPM
,5);
1286 GSM_Error
DCT3_GetSMSStatus(GSM_StateMachine
*s
, GSM_SMSMemoryStatus
*status
)
1288 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x36, 0x64};
1290 s
->Phone
.Data
.SMSStatus
=status
;
1291 smprintf(s
, "Getting SMS status\n");
1292 return GSM_WaitFor (s
, req
, 5, 0x14, 2, ID_GetSMSStatus
);
1295 /* Nokia 6210 and family does not show not "fixed" messages from the
1296 * Templates folder, ie. when you save a message to the Templates folder,
1297 * SMSStatus does not change! Workaround: get Templates folder status, which
1298 * does show these messages.
1303 GSM_Error
DCT3_ReplyDeleteSMSMessage(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1305 switch(msg
.Buffer
[3]) {
1307 smprintf(s
, "SMS deleted\n");
1310 smprintf(s
, "Error deleting SMS\n");
1311 switch (msg
.Buffer
[4]) {
1313 /* Not tested on 6210 */
1314 smprintf(s
, "Unknown meaning, SMS seems to be deleted\n");
1317 /* Not tested on 6210 */
1318 smprintf(s
, "Invalid location\n");
1319 return GE_INVALIDLOCATION
;
1321 /* Not tested on 6210 */
1322 smprintf(s
, "Phone is OFF\n");
1325 smprintf(s
, "Unknown error: %02x\n",msg
.Buffer
[4]);
1326 return GE_UNKNOWNRESPONSE
;
1329 return GE_UNKNOWNRESPONSE
;
1332 GSM_Error
N71_92_ReplyGetSignalQuality(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1334 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
1335 smprintf(s
, "Network level received: %i\n",msg
.Buffer
[4]);
1336 Data
->SignalQuality
->SignalStrength
= -1;
1337 Data
->SignalQuality
->SignalPercent
= ((int)msg
.Buffer
[4]);
1338 Data
->SignalQuality
->BitErrorRate
= -1;
1342 GSM_Error
N71_92_GetSignalQuality(GSM_StateMachine
*s
, GSM_SignalQuality
*sig
)
1344 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x81};
1346 s
->Phone
.Data
.SignalQuality
= sig
;
1347 smprintf(s
, "Getting network level\n");
1348 return GSM_WaitFor (s
, req
, 4, 0x0a, 4, ID_GetSignalQuality
);
1351 GSM_Error
N71_92_ReplyGetBatteryCharge(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1353 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
1354 smprintf(s
, "Battery level received: %i\n",msg
.Buffer
[5]);
1355 Data
->BatteryCharge
->BatteryPercent
= ((int)msg
.Buffer
[5]);
1356 Data
->BatteryCharge
->ChargeState
= 0;
1360 GSM_Error
N71_92_GetBatteryCharge(GSM_StateMachine
*s
, GSM_BatteryCharge
*bat
)
1362 unsigned char req
[] = {N6110_FRAME_HEADER
, 0x02};
1364 s
->Phone
.Data
.BatteryCharge
= bat
;
1365 smprintf(s
, "Getting battery level\n");
1366 return GSM_WaitFor (s
, req
, 4, 0x17, 4, ID_GetBatteryCharge
);
1369 GSM_Error
N71_92_ReplyPhoneSetting(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1371 GSM_Phone_Bitmap_Types BmpType
;
1372 GSM_Phone_Data
*Data
= &s
->Phone
.Data
;
1374 switch (msg
.Buffer
[4]) {
1376 if (Data
->RequestID
== ID_GetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1377 smprintf(s
, "Welcome note text received\n");
1378 CopyUnicodeString(Data
->Bitmap
->Text
,msg
.Buffer
+6);
1379 smprintf(s
, "Text is \"%s\"\n",DecodeUnicodeString(Data
->Bitmap
->Text
));
1382 if (Data
->RequestID
== ID_SetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1383 smprintf(s
, "Startup text set\n");
1387 if (Data
->RequestID
== ID_GetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1388 smprintf(s
, "Startup logo received\n");
1389 BmpType
=GSM_Nokia7110StartupLogo
;
1390 if (msg
.Buffer
[17]==0x60) BmpType
=GSM_Nokia6210StartupLogo
;
1391 if (msg
.Buffer
[17]==0xc0) BmpType
=GSM_NokiaStartupLogo
;
1392 PHONE_DecodeBitmap(BmpType
, msg
.Buffer
+22, Data
->Bitmap
);
1395 if (Data
->RequestID
== ID_SetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1396 smprintf(s
, "Startup logo set\n");
1400 if (Data
->RequestID
== ID_GetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1401 smprintf(s
, "Dealer note text received\n");
1402 CopyUnicodeString(Data
->Bitmap
->Text
,msg
.Buffer
+6);
1403 smprintf(s
, "Text is \"%s\"\n",DecodeUnicodeString(Data
->Bitmap
->Text
));
1406 if (Data
->RequestID
== ID_SetBitmap
|| Data
->RequestID
== ID_EachFrame
) {
1407 smprintf(s
, "Dealer text set\n");
1411 return GE_UNKNOWNRESPONSE
;
1414 GSM_Error
N71_92_GetPhoneSetting(GSM_StateMachine
*s
, int Request
, int Setting
)
1416 unsigned char req
[] = {
1417 N7110_FRAME_HEADER
, 0xee,
1418 0x1c}; /* Setting */
1421 return GSM_WaitFor (s
, req
, 5, 0x7a, 4, Request
);
1424 GSM_Error
N71_92_GetDateTime(GSM_StateMachine
*s
, GSM_DateTime
*date_time
)
1426 return DCT3_GetDateTime(s
, date_time
, 0x19);
1429 GSM_Error
N71_92_SetDateTime(GSM_StateMachine
*s
, GSM_DateTime
*date_time
)
1431 return DCT3_SetDateTime(s
, date_time
, 0x19);
1434 GSM_Error
DCT3_DecodeSMSFrame(GSM_StateMachine
*s
, GSM_SMSMessage
*SMS
, unsigned char *buffer
)
1436 switch (buffer
[12] & 0x03) {
1438 smprintf(s
, "SMS type - deliver\n");
1439 SMS
->PDU
= SMS_Deliver
;
1440 return GSM_DecodeSMSFrame(SMS
,buffer
,PHONE_SMSDeliver
);
1442 smprintf(s
, "SMS type - submit\n");
1443 SMS
->PDU
= SMS_Submit
;
1444 return GSM_DecodeSMSFrame(SMS
,buffer
,PHONE_SMSSubmit
);
1446 smprintf(s
, "SMS type - delivery report\n");
1447 SMS
->PDU
= SMS_Status_Report
;
1448 return GSM_DecodeSMSFrame(SMS
,buffer
,PHONE_SMSStatusReport
);
1453 GSM_Error
N61_91_ReplySetOpLogo(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1455 switch (msg
.Buffer
[3]) {
1457 smprintf(s
, "Operator logo set OK\n");
1460 smprintf(s
, "Error setting operator logo\n");
1461 switch (msg
.Buffer
[4]) {
1463 smprintf(s
, "Too high location ?\n");
1464 return GE_INVALIDLOCATION
;
1466 smprintf(s
, "ERROR: unknown %i\n",msg
.Buffer
[4]);
1469 return GE_UNKNOWNRESPONSE
;
1472 GSM_Error
N61_71_ReplyResetPhoneSettings(GSM_Protocol_Message msg
, GSM_StateMachine
*s
)
1474 smprintf(s
, "Phone settings cleaned OK\n");
1478 GSM_Error
N61_71_ResetPhoneSettings(GSM_StateMachine
*s
, GSM_ResetSettingsType Type
)
1481 unsigned char req
[] = {
1483 0x01}; /* Reset type */
1486 case GSM_RESET_PHONESETTINGS
: req
[3] = 0x01; break;
1487 case GSM_RESET_DEVICE
: req
[3] = 0x02; break;
1488 case GSM_RESET_USERINTERFACE
: req
[3] = 0x08; break;
1489 case GSM_RESET_USERINTERFACE_PHONESETTINGS
: req
[3] = 0x38; break;
1490 case GSM_RESET_FULLFACTORY
: req
[3] = 0xff; break;
1493 error
=DCT3_EnableSecurity (s
, 0x01);
1494 if (error
!= GE_NONE
) return error
;
1496 return GSM_WaitFor (s
, req
, 4, 0x40, 4, ID_ResetPhoneSettings
);
1501 /* How should editor hadle tabs in this file? Add editor commands here.
1502 * vim: noexpandtab sw=8 ts=8 sts=8: