diff options
author | Michal Čihař <michal@cihar.com> | 2010-10-04 17:19:03 +0200 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2010-10-04 17:19:03 +0200 |
commit | d91a0635ba6086e8d6a09ac0290b39e6d62fda37 (patch) | |
tree | c9e6685cbe1b9487e7c4affdcc05ec4b7bed2e22 /libgammu/phone/nokia/dct4s40/6510/n6510.c | |
parent | 468ee374ccf16a5e86fae6a911067112999b2a44 (diff) |
Imported Upstream version 1.28.92
Diffstat (limited to 'libgammu/phone/nokia/dct4s40/6510/n6510.c')
-rw-r--r-- | libgammu/phone/nokia/dct4s40/6510/n6510.c | 108 |
1 files changed, 55 insertions, 53 deletions
diff --git a/libgammu/phone/nokia/dct4s40/6510/n6510.c b/libgammu/phone/nokia/dct4s40/6510/n6510.c index 1fb3dcd..17128e9 100644 --- a/libgammu/phone/nokia/dct4s40/6510/n6510.c +++ b/libgammu/phone/nokia/dct4s40/6510/n6510.c @@ -324,59 +324,59 @@ static GSM_Error N6510_SetSMSC(GSM_StateMachine *s, GSM_SMSC *smsc) static GSM_Error N6510_ReplyGetNetworkInfo(GSM_Protocol_Message msg, GSM_StateMachine *s) { - int current = msg.Buffer[7]+7, tmp; + int current = msg.Buffer[7]+7, pos; GSM_Phone_Data *Data = &s->Phone.Data; -#ifdef DEBUG - char name[100]; - GSM_NetworkInfo NetInfo; + GSM_NetworkInfo network_info_local, *network_info; - if (msg.Buffer[3] == 0xf0) return ERR_NOTSUPPORTED; + if (msg.Buffer[3] == 0xf0) { + return ERR_NOTSUPPORTED; + } - smprintf(s, "Network status : "); - switch (msg.Buffer[8]) { - case 0x00 : smprintf(s, "home network\n"); break; - case 0x01 : smprintf(s, "roaming network\n"); break; - case 0x04 : smprintf(s, "not logged"); break; - case 0x06 : smprintf(s, "SIM card rejected\n"); break; - case 0x09 : smprintf(s, "not logged"); break; - default : smprintf(s, "unknown %i!\n",msg.Buffer[8]); break; + if (Data->RequestID == ID_GetNetworkInfo) { + network_info = Data->NetworkInfo; + } else { + network_info = &network_info_local; } - if (msg.Buffer[8]==0x00 || msg.Buffer[8] == 0x01) { - NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7),NetInfo.NetworkCode); - smprintf(s, "Network code : %s\n", NetInfo.NetworkCode); - smprintf(s, "Network name for Gammu : %s ", - DecodeUnicodeString(GSM_GetNetworkName(NetInfo.NetworkCode))); - smprintf(s, "(%s)\n",DecodeUnicodeString(GSM_GetCountryName(NetInfo.NetworkCode))); - - sprintf(NetInfo.LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]); - smprintf(s, "LAC : %s\n", NetInfo.LAC); - - sprintf(NetInfo.CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]); - smprintf(s, "CID : %s\n", NetInfo.CID); - - tmp = 10; - NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,name,TRUE); - smprintf(s, "Network name for phone : %s\n",DecodeUnicodeString(name)); + + network_info->NetworkName[0] = 0x00; + network_info->NetworkName[1] = 0x00; + + switch (msg.Buffer[8]) { + case 0x00: + smprintf(s, "home network\n"); + network_info->State = GSM_HomeNetwork; + break; + case 0x01: + smprintf(s, "roaming network\n"); + network_info->State = GSM_RoamingNetwork; + break; + case 0x04: + smprintf(s, "not logged"); + network_info->State = GSM_NoNetwork; + break; + case 0x06: + smprintf(s, "SIM card rejected\n"); + network_info->State = GSM_RegistrationDenied; + break; + case 0x09: + smprintf(s, "not logged"); + network_info->State = GSM_NoNetwork; + break; + default: + smprintf(s, "unknown %i!\n",msg.Buffer[8]); + network_info->State = GSM_NetworkStatusUnknown; } -#endif - if (Data->RequestID==ID_GetNetworkInfo) { - Data->NetworkInfo->NetworkName[0] = 0x00; - Data->NetworkInfo->NetworkName[1] = 0x00; - Data->NetworkInfo->State = 0; - switch (msg.Buffer[8]) { - case 0x00: Data->NetworkInfo->State = GSM_HomeNetwork; break; - case 0x01: Data->NetworkInfo->State = GSM_RoamingNetwork; break; - case 0x04: - case 0x06: - case 0x09: Data->NetworkInfo->State = GSM_NoNetwork; break; - } - if (Data->NetworkInfo->State == GSM_HomeNetwork || Data->NetworkInfo->State == GSM_RoamingNetwork) { - tmp = 10; - NOKIA_GetUnicodeString(s, &tmp, msg.Buffer,Data->NetworkInfo->NetworkName,TRUE); - sprintf(Data->NetworkInfo->LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]); - sprintf(Data->NetworkInfo->CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]); - NOKIA_DecodeNetworkCode(msg.Buffer + (current+7),Data->NetworkInfo->NetworkCode); - } + if (network_info->State == GSM_HomeNetwork || network_info->State == GSM_RoamingNetwork) { + pos = 10; + NOKIA_GetUnicodeString(s, &pos, msg.Buffer, network_info->NetworkName, TRUE); + smprintf(s, "Network name: %s ", DecodeUnicodeString(network_info->NetworkName)); + NOKIA_DecodeNetworkCode(msg.Buffer + (current + 7), network_info->NetworkCode); + smprintf(s, "Network code: %s\n", network_info->NetworkCode); + smprintf(s, "Network name in libGammu: %s ", DecodeUnicodeString(GSM_GetNetworkName(network_info->NetworkCode))); + sprintf(network_info->LAC, "%02X%02X", msg.Buffer[current+1], msg.Buffer[current+2]); + smprintf(s, "LAC: %s\n", network_info->LAC); + sprintf(network_info->CID, "%02X%02X", msg.Buffer[current+5], msg.Buffer[current+6]); + smprintf(s, "CID: %s\n", network_info->CID); } return ERR_NONE; } @@ -4168,16 +4168,18 @@ static GSM_Reply_Function N6510ReplyFunctions[] = { {N6510_ReplyGetSecurityStatus, "\x08",0x03,0x12,ID_GetSecurityStatus }, {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_GetNetworkInfo }, + {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0xf0,ID_GetNetworkInfo }, + {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality }, + {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap }, + {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0xf0,ID_GetBitmap }, + {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap }, + /* This needs to be last of type */ {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0x01,ID_IncomingFrame }, - {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0xf0,ID_IncomingFrame }, {N6510_ReplyLogIntoNetwork, "\x0A",0x03,0x02,ID_IncomingFrame }, - {N6510_ReplyGetSignalQuality, "\x0A",0x03,0x0C,ID_GetSignalQuality }, {NoneReply, "\x0A",0x03,0x16,ID_IncomingFrame }, {N6510_ReplyGetIncSignalQuality, "\x0A",0x03,0x1E,ID_IncomingFrame }, {NoneReply, "\x0A",0x03,0x20,ID_IncomingFrame }, - {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0x24,ID_GetBitmap }, - {N6510_ReplyGetOperatorLogo, "\x0A",0x03,0xf0,ID_GetBitmap }, - {N6510_ReplySetOperatorLogo, "\x0A",0x03,0x26,ID_SetBitmap }, + {N6510_ReplyGetNetworkInfo, "\x0A",0x03,0xf0,ID_IncomingFrame }, {NoneReply, "\x0B",0x03,0x01,ID_PlayTone }, {NoneReply, "\x0B",0x03,0x15,ID_PlayTone }, |