[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patch] network info for command line gnokii
From: |
bertrik |
Subject: |
[patch] network info for command line gnokii |
Date: |
Fri, 3 Jan 2003 22:33:30 +0100 |
User-agent: |
Internet Messaging Program (IMP) 3.1 |
Hi all,
Attached is a patch for gnokii.c that adds a 'gnokii --getnetworkinfo'
call. Example of gnokii output (with debug enabled):
Found model "NHM-2"
Message sent: 0x0a / 0x0004
00 01 00 70 | p
[Received Ack of type 0a, seq: 6]
[Sending Ack of type 0a, seq: 5]
Message received: 0x0a / 0x0013
01 08 00 71 01 00 01 0b 01 02 3d e3 00 ca 02 f4 | q =ã Ê ô
21 00 00 | !
Received message type 0a
Network code : 204 12
LAC : 202
Cell id : 15843
Serial device: closing device
Kind regards,
Bertrik Sikken
--- /home/bertrik/gnokii.clean/gnokii/gnokii.c 2003-01-03 21:59:29.000000000
+0100
+++ gnokii.c 2003-01-03 22:24:46.000000000 +0100
@@ -152,6 +152,7 @@
OPT_DELETESMSFOLDER,
OPT_CREATESMSFOLDER,
OPT_LISTNETWORKS,
+ OPT_GETNETWORKINFO
} opt_index;
static char *bindir; /* Binaries directory from .gnokiirc file - not used
here yet */
@@ -316,6 +317,7 @@
" [{--timeout|-m} time_in_seconds]\n"
" [{--number|-n} number]\n"
" gnokii --listnetworks\n"
+ " gnokii --getnetworkinfo\n"
));
#ifdef SECURITY
fprintf(f, _(" gnokii --entersecuritycode PIN|PIN2|PUK|PUK2\n"
@@ -1866,7 +1868,7 @@
memset(&bitmap.netcode, 0, sizeof(bitmap.netcode));
if (argc < 3)
- if (gn_sm_functions(GN_OP_GetNetworkInfo, &data,
&state) == GN_ERR_NONE)
+ if (gn_sm_functions(GN_OP_GetNetworkInfo, &data,
&state) == GN_ERR_NONE)
strncpy(bitmap.netcode,
networkinfo.network_code, sizeof(bitmap.netcode) - 1);
if (!strncmp(state.driver.phone.models, "6510", 4))
@@ -4226,7 +4228,7 @@
gn_data data;
gn_error error;
gn_security_code sc;
-
+
memset(&sc, 0, sizeof(sc));
sc.type = GN_SCT_SecurityCode;
data.security_code = ≻
@@ -4240,13 +4242,36 @@
{
extern gn_network networks[];
int i;
-
+
printf("Network Name\n");
printf("-----------------------------------------\n");
for (i = 0; strcmp(networks[i].name, "unknown"); i++)
printf("%-7s %s\n", networks[i].code, networks[i].name);
}
+static int getnetworkinfo(void)
+{
+ gn_network_info networkinfo;
+ gn_data data;
+ int cid, lac;
+
+ gn_data_clear(&data);
+ data.network_info = &networkinfo;
+
+ if (gn_sm_functions(GN_OP_GetNetworkInfo, &data, &state) !=
GN_ERR_NONE) {
+ return -1;
+ }
+
+ cid = (networkinfo.cell_id[0] << 8) + networkinfo.cell_id[1];
+ lac = (networkinfo.LAC[0] << 8) + networkinfo.LAC[1];
+
+ fprintf(stdout, _("Network code : %s\n"), networkinfo.network_code);
+ fprintf(stdout, _("LAC : %d\n"), lac);
+ fprintf(stdout, _("Cell id : %d\n"), cid);
+
+ return 0;
+}
+
/* This is a "convenience" function to allow quick test of new API stuff which
doesn't warrant a "proper" command line function. */
#ifndef WIN32
@@ -4491,6 +4516,9 @@
/* List GSM networks */
{ "listnetworks", no_argument, NULL,
OPT_LISTNETWORKS },
+ /* Get network info */
+ { "getnetworkinfo", no_argument, NULL,
OPT_GETNETWORKINFO },
+
{ 0, 0, 0, 0},
};
@@ -4782,6 +4810,9 @@
case OPT_LISTNETWORKS:
list_gsm_networks();
break;
+ case OPT_GETNETWORKINFO:
+ rc = getnetworkinfo();
+ break;
#ifndef WIN32
case OPT_FOOGLE:
rc = foogle(nargv);
_____________________________________________________________________
Zon Breedband Family, 2 keer zo snel als alle andere ADSL aanbieders.
Voor maar 34 euro per maand.
Bestel nu op www.zonnet.nl/breedband en krijg het modem gratis.
- [patch] network info for command line gnokii,
bertrik <=