Diffstat (limited to 'gammu/emb/common/phone/nokia/dct3/dct3func.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/phone/nokia/dct3/dct3func.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gammu/emb/common/phone/nokia/dct3/dct3func.c b/gammu/emb/common/phone/nokia/dct3/dct3func.c index beef33c..17cd0a4 100644 --- a/gammu/emb/common/phone/nokia/dct3/dct3func.c +++ b/gammu/emb/common/phone/nokia/dct3/dct3func.c | |||
@@ -1,27 +1,30 @@ | |||
1 | /* (c) 2001-2004 by Marcin Wiacek */ | 1 | /* (c) 2001-2004 by Marcin Wiacek */ |
2 | /* based on some work from Markus Plail, Pavel Janik, others and Gnokii */ | ||
3 | /* resetting DCT4 phones settings (c) by Walek */ | 2 | /* resetting DCT4 phones settings (c) by Walek */ |
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 | */ | ||
4 | 7 | ||
5 | #include <string.h> /* memcpy only */ | 8 | #include <string.h> /* memcpy only */ |
6 | #include <stdio.h> | 9 | #include <stdio.h> |
7 | #include <ctype.h> | 10 | #include <ctype.h> |
8 | 11 | ||
9 | #include "../../../gsmstate.h" | 12 | #include "../../../gsmstate.h" |
10 | #include "../../../misc/coding/coding.h" | 13 | #include "../../../misc/coding/coding.h" |
11 | #include "../../../service/sms/gsmsms.h" | 14 | #include "../../../service/sms/gsmsms.h" |
12 | #include "../../pfunc.h" | 15 | #include "../../pfunc.h" |
13 | #include "../nfunc.h" | 16 | #include "../nfunc.h" |
14 | #include "dct3func.h" | 17 | #include "dct3func.h" |
15 | 18 | ||
16 | #ifdef GSM_ENABLE_NOKIA_DCT3 | 19 | #ifdef GSM_ENABLE_NOKIA_DCT3 |
17 | 20 | ||
18 | GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) | 21 | GSM_Error DCT3_DeleteWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark) |
19 | { | 22 | { |
20 | GSM_Error error; | 23 | GSM_Error error; |
21 | 24 | ||
22 | /* We have to enable WAP frames in phone */ | 25 | /* We have to enable WAP frames in phone */ |
23 | error=DCT3DCT4_EnableWAPFunctions(s); | 26 | error=DCT3DCT4_EnableWAPFunctions(s); |
24 | if (error!=ERR_NONE) return error; | 27 | if (error!=ERR_NONE) return error; |
25 | 28 | ||
26 | return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); | 29 | return DCT3DCT4_DeleteWAPBookmarkPart(s,bookmark); |
27 | } | 30 | } |
@@ -373,115 +376,116 @@ GSM_Error DCT3_SetAlarm(GSM_StateMachine *s, GSM_Alarm *alarm, unsigned char msg | |||
373 | req[8] = alarm->DateTime.Hour; | 376 | req[8] = alarm->DateTime.Hour; |
374 | req[9] = alarm->DateTime.Minute; | 377 | req[9] = alarm->DateTime.Minute; |
375 | 378 | ||
376 | smprintf(s, "Setting alarm\n"); | 379 | smprintf(s, "Setting alarm\n"); |
377 | return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm); | 380 | return GSM_WaitFor (s, req, 11, msgtype, 4, ID_SetAlarm); |
378 | } | 381 | } |
379 | 382 | ||
380 | GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) | 383 | GSM_Error DCT3_ReplyGetSMSC(GSM_Protocol_Message msg, GSM_StateMachine *s) |
381 | { | 384 | { |
382 | int i; | 385 | int i; |
383 | GSM_Phone_Data*Data = &s->Phone.Data; | 386 | GSM_Phone_Data*Data = &s->Phone.Data; |
384 | 387 | ||
385 | switch (msg.Buffer[3]) { | 388 | switch (msg.Buffer[3]) { |
386 | case 0x34: | 389 | case 0x34: |
387 | smprintf(s, "SMSC received\n"); | 390 | smprintf(s, "SMSC received\n"); |
388 | Data->SMSC->Format = SMS_FORMAT_Text; | 391 | Data->SMSC->Format = SMS_FORMAT_Text; |
389 | switch (msg.Buffer[6]) { | 392 | switch (msg.Buffer[6]) { |
390 | case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; | 393 | case 0x00: Data->SMSC->Format = SMS_FORMAT_Text; break; |
391 | case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; | 394 | case 0x22: Data->SMSC->Format = SMS_FORMAT_Fax; break; |
392 | case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; | 395 | case 0x26: Data->SMSC->Format = SMS_FORMAT_Pager;break; |
393 | case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; | 396 | case 0x32: Data->SMSC->Format = SMS_FORMAT_Email;break; |
394 | } | 397 | } |
395 | Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; | 398 | Data->SMSC->Validity.Format = SMS_Validity_RelativeFormat; |
396 | Data->SMSC->Validity.Relative= msg.Buffer[8]; | 399 | Data->SMSC->Validity.Relative= msg.Buffer[8]; |
400 | if (msg.Buffer[8] == 0x00) Data->SMSC->Validity.Relative = SMS_VALID_Max_Time; | ||
397 | 401 | ||
398 | i=33; | 402 | i=33; |
399 | while (msg.Buffer[i]!=0) {i++;} | 403 | while (msg.Buffer[i]!=0) {i++;} |
400 | i=i-33; | 404 | i=i-33; |
401 | if (i>GSM_MAX_SMSC_NAME_LENGTH) { | 405 | if (i>GSM_MAX_SMSC_NAME_LENGTH) { |
402 | smprintf(s, "Too long name\n"); | 406 | smprintf(s, "Too long name\n"); |
403 | return ERR_UNKNOWNRESPONSE; | 407 | return ERR_UNKNOWNRESPONSE; |
404 | } | 408 | } |
405 | EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); | 409 | EncodeUnicode(Data->SMSC->Name,msg.Buffer+33,i); |
406 | smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); | 410 | smprintf(s, "Name \"%s\"\n", DecodeUnicodeString(Data->SMSC->Name)); |
407 | 411 | ||
408 | GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); | 412 | GSM_UnpackSemiOctetNumber(Data->SMSC->DefaultNumber,msg.Buffer+9,true); |
409 | smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); | 413 | smprintf(s, "Default number \"%s\"\n", DecodeUnicodeString(Data->SMSC->DefaultNumber)); |
410 | 414 | ||
411 | GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false); | 415 | GSM_UnpackSemiOctetNumber(Data->SMSC->Number,msg.Buffer+21,false); |
412 | smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); | 416 | smprintf(s, "Number \"%s\"\n", DecodeUnicodeString(Data->SMSC->Number)); |
413 | 417 | ||
414 | return ERR_NONE; | 418 | return ERR_NONE; |
415 | case 0x35: | 419 | case 0x35: |
416 | smprintf(s, "Getting SMSC failed\n"); | 420 | smprintf(s, "Getting SMSC failed\n"); |
417 | return ERR_INVALIDLOCATION; | 421 | return ERR_INVALIDLOCATION; |
418 | } | 422 | } |
419 | return ERR_UNKNOWNRESPONSE; | 423 | return ERR_UNKNOWNRESPONSE; |
420 | } | 424 | } |
421 | 425 | ||
422 | GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) | 426 | GSM_Error DCT3_GetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) |
423 | { | 427 | { |
424 | unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64, | 428 | unsigned char req[] = {N6110_FRAME_HEADER, 0x33, 0x64, |
425 | 0x00}; /* Location */ | 429 | 0x00}; /* Location */ |
426 | 430 | ||
427 | if (smsc->Location==0x00) return ERR_INVALIDLOCATION; | 431 | if (smsc->Location==0x00) return ERR_INVALIDLOCATION; |
428 | 432 | ||
429 | req[5]=smsc->Location; | 433 | req[5]=smsc->Location; |
430 | 434 | ||
431 | s->Phone.Data.SMSC=smsc; | 435 | s->Phone.Data.SMSC=smsc; |
432 | smprintf(s, "Getting SMSC\n"); | 436 | smprintf(s, "Getting SMSC\n"); |
433 | return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); | 437 | return GSM_WaitFor (s, req, 6, 0x02, 4, ID_GetSMSC); |
434 | } | 438 | } |
435 | 439 | ||
436 | GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) | 440 | GSM_Error DCT3_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) |
437 | { | 441 | { |
438 | int count; | 442 | int count; |
439 | GSM_Phone_Data*Data = &s->Phone.Data; | 443 | GSM_Phone_Data*Data = &s->Phone.Data; |
440 | #ifdef DEBUG | 444 | #ifdef DEBUG |
441 | GSM_NetworkInfo NetInfo; | 445 | GSM_NetworkInfo NetInfo; |
442 | char name[100]; | 446 | char name[100]; |
443 | 447 | ||
444 | smprintf(s, "Network info received\n"); | 448 | smprintf(s, "Network info received\n"); |
445 | smprintf(s, " Status : "); | 449 | smprintf(s, "Status : "); |
446 | switch (msg.Buffer[8]) { | 450 | switch (msg.Buffer[8]) { |
447 | case 0x01: smprintf(s, "home network"); break; | 451 | case 0x01: smprintf(s, "home network"); break; |
448 | case 0x02: smprintf(s, "roaming network"); break; | 452 | case 0x02: smprintf(s, "roaming network"); break; |
449 | case 0x03: smprintf(s, "requesting network"); break; | 453 | case 0x03: smprintf(s, "requesting network"); break; |
450 | case 0x04: smprintf(s, "not registered in the network");break; | 454 | case 0x04: smprintf(s, "not registered in the network");break; |
451 | default : smprintf(s, "unknown"); | 455 | default : smprintf(s, "unknown"); |
452 | } | 456 | } |
453 | smprintf(s, "\n"); | 457 | smprintf(s, "\n"); |
454 | smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); | 458 | smprintf(s, "Network selection : %s\n", msg.Buffer[9]==1?"manual":"automatic"); |
455 | if (msg.Buffer[8]<0x03) { | 459 | if (msg.Buffer[8]<0x03) { |
456 | sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); | 460 | sprintf(NetInfo.CID, "%02x%02x", msg.Buffer[10], msg.Buffer[11]); |
457 | smprintf(s, "CID : %s\n", NetInfo.CID); | 461 | smprintf(s, "CID : %s\n", NetInfo.CID); |
458 | 462 | ||
459 | sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); | 463 | sprintf(NetInfo.LAC, "%02x%02x", msg.Buffer[12], msg.Buffer[13]); |
460 | smprintf(s, "LAC : %s\n", NetInfo.LAC); | 464 | smprintf(s, "LAC : %s\n", NetInfo.LAC); |
461 | 465 | ||
462 | smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); | ||
463 | NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); | 466 | NOKIA_DecodeNetworkCode(msg.Buffer+14,NetInfo.NetworkCode); |
467 | smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); | ||
464 | smprintf(s, "Network name for Gammu : %s ", | 468 | smprintf(s, "Network name for Gammu : %s ", |
465 | DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); | 469 | DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); |
466 | smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); | 470 | smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); |
467 | 471 | ||
468 | if (msg.Length>18) { | 472 | if (msg.Length>18) { |
469 | if (msg.Buffer[18]==0x00) { | 473 | if (msg.Buffer[18]==0x00) { |
470 | /* In 6210 name is in "normal" Unicode */ | 474 | /* In 6210 name is in "normal" Unicode */ |
471 | memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); | 475 | memcpy(name,msg.Buffer+18,msg.Buffer[17]*2); |
472 | name[msg.Buffer[17]*2]=0x00; | 476 | name[msg.Buffer[17]*2]=0x00; |
473 | name[msg.Buffer[17]*2+1]=0x00; | 477 | name[msg.Buffer[17]*2+1]=0x00; |
474 | smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); | 478 | smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); |
475 | } else { | 479 | } else { |
476 | /* In 9210 first 0x00 is cut from Unicode string */ | 480 | /* In 9210 first 0x00 is cut from Unicode string */ |
477 | name[0] = 0; | 481 | name[0] = 0; |
478 | memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2); | 482 | memcpy(name+1,msg.Buffer+18,msg.Buffer[17]*2); |
479 | name[msg.Buffer[17]*2+1]=0x00; | 483 | name[msg.Buffer[17]*2+1]=0x00; |
480 | name[msg.Buffer[17]*2+2]=0x00; | 484 | name[msg.Buffer[17]*2+2]=0x00; |
481 | smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); | 485 | smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); |
482 | } | 486 | } |
483 | } | 487 | } |
484 | } | 488 | } |
485 | #endif | 489 | #endif |
486 | if (Data->RequestID==ID_GetNetworkInfo) { | 490 | if (Data->RequestID==ID_GetNetworkInfo) { |
487 | Data->NetworkInfo->NetworkName[0] = 0x00; | 491 | Data->NetworkInfo->NetworkName[0] = 0x00; |
@@ -1187,53 +1191,53 @@ GSM_Error DCT3_SetWAPSettings(GSM_StateMachine *s, GSM_MultiWAPSettings *setting | |||
1187 | pos++; | 1191 | pos++; |
1188 | if (loc3 != -1) { | 1192 | if (loc3 != -1) { |
1189 | /* Service number or IP address */ | 1193 | /* Service number or IP address */ |
1190 | pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false); | 1194 | pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Service, false); |
1191 | /* Code number */ | 1195 | /* Code number */ |
1192 | pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false); | 1196 | pos += NOKIA_SetUnicodeString(s, SetReq2 + pos, settings->Settings[loc3].Code, false); |
1193 | } else pos+=2; | 1197 | } else pos+=2; |
1194 | memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); | 1198 | memcpy(SetReq2 + pos, "\x80\x00\x00\x00\x00\x00\x00\x00", 8); |
1195 | pos += 8; | 1199 | pos += 8; |
1196 | smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n"); | 1200 | smprintf(s, "Writing WAP settings part 2 (USSD bearer)\n"); |
1197 | error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); | 1201 | error=GSM_WaitFor (s, SetReq2, pos, 0x3f, 4, ID_SetConnectSet); |
1198 | if (error != ERR_NONE) return error; | 1202 | if (error != ERR_NONE) return error; |
1199 | } | 1203 | } |
1200 | error = DCT3DCT4_SetActiveConnectSet(s, settings); | 1204 | error = DCT3DCT4_SetActiveConnectSet(s, settings); |
1201 | if (error != ERR_NONE) return error; | 1205 | if (error != ERR_NONE) return error; |
1202 | 1206 | ||
1203 | return DCT3DCT4_DisableConnectionFunctions(s); | 1207 | return DCT3DCT4_DisableConnectionFunctions(s); |
1204 | } | 1208 | } |
1205 | 1209 | ||
1206 | GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1210 | GSM_Error DCT3_ReplySendSMSMessage(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1207 | { | 1211 | { |
1208 | switch (msg.Buffer[3]) { | 1212 | switch (msg.Buffer[3]) { |
1209 | case 0x02: | 1213 | case 0x02: |
1210 | smprintf(s, "SMS sent OK\n"); | 1214 | smprintf(s, "SMS sent OK\n"); |
1211 | if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,0); | 1215 | if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,0,msg.Buffer[5]); |
1212 | return ERR_NONE; | 1216 | return ERR_NONE; |
1213 | case 0x03: | 1217 | case 0x03: |
1214 | smprintf(s, "Error %i\n",msg.Buffer[6]); | 1218 | smprintf(s, "Error %i\n",msg.Buffer[6]); |
1215 | if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],0); | 1219 | if (s->User.SendSMSStatus!=NULL) s->User.SendSMSStatus(s->CurrentConfig->Device,msg.Buffer[6],-1); |
1216 | return ERR_NONE; | 1220 | return ERR_NONE; |
1217 | } | 1221 | } |
1218 | return ERR_UNKNOWNRESPONSE; | 1222 | return ERR_UNKNOWNRESPONSE; |
1219 | } | 1223 | } |
1220 | 1224 | ||
1221 | GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) | 1225 | GSM_Error DCT3_SendSMSMessage(GSM_StateMachine *s, GSM_SMSMessage *sms) |
1222 | { | 1226 | { |
1223 | int length; | 1227 | int length; |
1224 | GSM_Error error; | 1228 | GSM_Error error; |
1225 | unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00}; | 1229 | unsigned char req[256] = {N6110_FRAME_HEADER, 0x01, 0x02, 0x00}; |
1226 | 1230 | ||
1227 | error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true); | 1231 | error=PHONE_EncodeSMSFrame(s,sms,req+6,PHONE_SMSSubmit,&length, true); |
1228 | if (error != ERR_NONE) return error; | 1232 | if (error != ERR_NONE) return error; |
1229 | 1233 | ||
1230 | smprintf(s, "Sending sms\n"); | 1234 | smprintf(s, "Sending sms\n"); |
1231 | return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02); | 1235 | return s->Protocol.Functions->WriteMessage(s, req, 6+length, 0x02); |
1232 | } | 1236 | } |
1233 | 1237 | ||
1234 | GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s) | 1238 | GSM_Error DCT3_ReplyNetmonitor(GSM_Protocol_Message msg, GSM_StateMachine *s) |
1235 | { | 1239 | { |
1236 | switch (msg.Buffer[3]) { | 1240 | switch (msg.Buffer[3]) { |
1237 | case 0x00: | 1241 | case 0x00: |
1238 | smprintf(s, "Netmonitor correctly set\n"); | 1242 | smprintf(s, "Netmonitor correctly set\n"); |
1239 | break; | 1243 | break; |