gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] unsigned ints for cell_id and LAC in gn_network_info structure


From: Bertrik Sikken
Subject: [patch] unsigned ints for cell_id and LAC in gn_network_info structure
Date: Wed, 22 Jan 2003 19:35:02 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130

Hi,

Attached is a patch that changes the byte arrays in structure
gn_network_info into unsigned ints. All references to these
fields are updated too.

Perhaps unsigned ints are not the best replacement for the
byte arrays (we need at least 16 bits, or even better: exactly
16 bits). If necessary, changing the type should be trivial
with this patch in place.

I tested the patch with my nokia 3410 and it works as expected.
Although I did not test it on other phones, the patch for the
other phones is so trivial that I expect it to work for them too.

Regards,
Bertrik Sikken

diff -Nru --exclude CVS gnokii.clean/common/phones/nk6100.c 
gnokii/common/phones/nk6100.c
--- gnokii.clean/common/phones/nk6100.c 2003-01-22 19:11:35.000000000 +0100
+++ gnokii/common/phones/nk6100.c       2003-01-22 19:10:02.000000000 +0100
@@ -1679,10 +1679,8 @@
        /* Network info */
        case 0x71:
                if (data->network_info) {
-                       data->network_info->cell_id[0] = message[10];
-                       data->network_info->cell_id[1] = message[11];
-                       data->network_info->LAC[0] = message[12];
-                       data->network_info->LAC[1] = message[13];
+                       data->network_info->cell_id = (message[10] << 8) + 
message[11];
+                       data->network_info->LAC = (message[12] << 8) + 
message[13];
                        data->network_info->network_code[0] = '0' + 
(message[14] & 0x0f);
                        data->network_info->network_code[1] = '0' + 
(message[14] >> 4);
                        data->network_info->network_code[2] = '0' + 
(message[15] & 0x0f);
diff -Nru --exclude CVS gnokii.clean/common/phones/nk6510.c 
gnokii/common/phones/nk6510.c
--- gnokii.clean/common/phones/nk6510.c 2003-01-22 19:11:36.000000000 +0100
+++ gnokii/common/phones/nk6510.c       2003-01-22 19:10:02.000000000 +0100
@@ -2225,10 +2225,8 @@
                        case 0x09:  /* Operator details */
                                /* Network code is stored as 0xBA 0xXC 0xED 
("ABC DE"). */
                                if (data->network_info) {
-                                       data->network_info->cell_id[0] = 
blockstart[6];
-                                       data->network_info->cell_id[1] = 
blockstart[7];
-                                       data->network_info->LAC[0] = 
blockstart[2];
-                                       data->network_info->LAC[1] = 
blockstart[3];
+                                       data->network_info->cell_id = 
(blockstart[6] << 8) + blockstart[7];
+                                       data->network_info->LAC = 
(blockstart[2] << 8) + blockstart[3];
                                        data->network_info->network_code[0] = 
'0' + (blockstart[8] & 0x0f);
                                        data->network_info->network_code[1] = 
'0' + (blockstart[8] >> 4);
                                        data->network_info->network_code[2] = 
'0' + (blockstart[9] & 0x0f);
diff -Nru --exclude CVS gnokii.clean/common/phones/nk7110.c 
gnokii/common/phones/nk7110.c
--- gnokii.clean/common/phones/nk7110.c 2003-01-22 19:11:36.000000000 +0100
+++ gnokii/common/phones/nk7110.c       2003-01-22 19:10:02.000000000 +0100
@@ -470,10 +470,8 @@
                                /* Network code is stored as 0xBA 0xXC 0xED 
("ABC DE"). */
                                if (data->network_info) {
                                        /* Is this correct? */
-                                       data->network_info->cell_id[0] = 
blockstart[4];
-                                       data->network_info->cell_id[1] = 
blockstart[5];
-                                       data->network_info->LAC[0] = 
blockstart[6];
-                                       data->network_info->LAC[1] = 
blockstart[7];
+                                       data->network_info->cell_id = 
(blockstart[4] << 8) + blockstart[5];
+                                       data->network_info->LAC = 
(blockstart[6] << 8) + blockstart[7];
                                        data->network_info->network_code[0] = 
'0' + (blockstart[8] & 0x0f);
                                        data->network_info->network_code[1] = 
'0' + (blockstart[8] >> 4);
                                        data->network_info->network_code[2] = 
'0' + (blockstart[9] & 0x0f);
Binary files gnokii.clean/gnokii/gnokii and gnokii/gnokii/gnokii differ
diff -Nru --exclude CVS gnokii.clean/gnokii/gnokii.c gnokii/gnokii/gnokii.c
--- gnokii.clean/gnokii/gnokii.c        2003-01-22 19:11:36.000000000 +0100
+++ gnokii/gnokii/gnokii.c      2003-01-22 19:18:11.000000000 +0100
@@ -2611,7 +2611,7 @@
                        fprintf(stdout, _("SMS Messages: Unread %d, Number 
%d\n"), smsstatus.unread, smsstatus.number);
 
                if (gn_sm_functions(GN_OP_GetNetworkInfo, &data, &state) == 
GN_ERR_NONE)
-                       fprintf(stdout, _("Network: %s (%s), LAC: %02x%02x, 
CellID: %02x%02x\n"), gn_network_name_get(networkinfo.network_code), 
gn_country_name_get(networkinfo.network_code), networkinfo.LAC[0], 
networkinfo.LAC[1], networkinfo.cell_id[0], networkinfo.cell_id[1]);
+                       fprintf(stdout, _("Network: %s (%s), LAC: %04x, CellID: 
%04x\n"), gn_network_name_get(networkinfo.network_code), 
gn_country_name_get(networkinfo.network_code), networkinfo.LAC, 
networkinfo.cell_id);
 
                for (i = 0; i < GN_CALL_MAX_PARALLEL; i++)
                        displaycall(i);
@@ -4269,7 +4269,6 @@
 {
        gn_network_info networkinfo;
        gn_data data;
-       int cid, lac;
        char country[4] = {0, 0, 0, 0};
 
        gn_data_clear(&data);
@@ -4279,16 +4278,14 @@
                return -1;
        }
 
-       cid = (networkinfo.cell_id[0] << 8) + networkinfo.cell_id[1];
-       lac = (networkinfo.LAC[0] << 8) + networkinfo.LAC[1];
        memcpy(country, networkinfo.network_code, 3);
 
        fprintf(stdout, _("Network      : %s (%s)\n"),
                        gn_network_name_get((char *)networkinfo.network_code),
                        gn_country_name_get((char *)country));
        fprintf(stdout, _("Network code : %s\n"), networkinfo.network_code);
-       fprintf(stdout, _("LAC          : %04x\n"), lac);
-       fprintf(stdout, _("Cell id      : %04x\n"), cid);
+       fprintf(stdout, _("LAC          : %04x\n"), networkinfo.LAC);
+       fprintf(stdout, _("Cell id      : %04x\n"), networkinfo.cell_id);
 
        return 0;
 }
Binary files gnokii.clean/gnokii/gnokii.o and gnokii/gnokii/gnokii.o differ
diff -Nru --exclude CVS gnokii.clean/include/gsm-common.h 
gnokii/include/gsm-common.h
--- gnokii.clean/include/gsm-common.h   2003-01-22 19:11:36.000000000 +0100
+++ gnokii/include/gsm-common.h 2003-01-22 19:13:58.000000000 +0100
@@ -127,8 +127,8 @@
 /* This structure is used to get the current network status */
 typedef struct {
        char network_code[10];     /* GSM network code */
-       unsigned char cell_id[10]; /* CellID */
-       unsigned char LAC[10];     /* LAC */
+       unsigned int cell_id;
+       unsigned int LAC;
 } gn_network_info;
 
 /* Limits for sizing of array in gn_phonebook_entry. Individual handsets may

reply via email to

[Prev in Thread] Current Thread [Next in Thread]