summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/gsmd/usock.h17
-rw-r--r--src/gsmd/usock.c46
-rw-r--r--src/libgsmd/libgsmd_network.c5
-rw-r--r--src/util/shell.c6
4 files changed, 66 insertions, 8 deletions
diff --git a/include/gsmd/usock.h b/include/gsmd/usock.h
index 2591500..6b2bc4a 100644
--- a/include/gsmd/usock.h
+++ b/include/gsmd/usock.h
@@ -153,14 +153,15 @@ enum gsmd_msg_network {
GSMD_NETWORK_VMAIL_GET = 3,
GSMD_NETWORK_VMAIL_SET = 4,
GSMD_NETWORK_OPER_GET = 5,
- GSMD_NETWORK_OPER_LIST = 6,
- GSMD_NETWORK_CIND_GET = 7,
- GSMD_NETWORK_DEREGISTER = 8,
- GSMD_NETWORK_GET_NUMBER = 9,
- GSMD_NETWORK_PREF_LIST = 10,
- GSMD_NETWORK_PREF_DEL = 11,
- GSMD_NETWORK_PREF_ADD = 12,
- GSMD_NETWORK_PREF_SPACE = 13,
+ GSMD_NETWORK_OPER_N_GET = 6,
+ GSMD_NETWORK_OPER_LIST = 7,
+ GSMD_NETWORK_CIND_GET = 8,
+ GSMD_NETWORK_DEREGISTER = 9,
+ GSMD_NETWORK_GET_NUMBER = 10,
+ GSMD_NETWORK_PREF_LIST = 11,
+ GSMD_NETWORK_PREF_DEL = 12,
+ GSMD_NETWORK_PREF_ADD = 13,
+ GSMD_NETWORK_PREF_SPACE = 14,
};
enum gsmd_msg_sms {
diff --git a/src/gsmd/usock.c b/src/gsmd/usock.c
index fffe7a2..18c6662 100644
--- a/src/gsmd/usock.c
+++ b/src/gsmd/usock.c
@@ -767,6 +767,46 @@ static int network_oper_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
return ret;
}
+static int network_oper_n_cb(struct gsmd_atcmd *cmd, void *ctx, char *resp)
+{
+ struct gsmd_user *gu = ctx;
+ int format, s, ret;
+ char buf[16+1] = {'\0'};
+ struct gsm_extrsp *er;
+
+ er = extrsp_parse(cmd, resp);
+
+ if ( !er )
+ return -ENOMEM;
+
+ //extrsp_dump(er);
+
+ /* Format: <mode>[,<format>,<oper>] */
+ if ( er->num_tokens == 1 &&
+ er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC ) {
+
+ /* In case we're not registered, return an empty string */
+ buf[0] = '\0';
+ }
+ else if ( er->num_tokens == 3 &&
+ er->tokens[0].type == GSMD_ECMD_RTT_NUMERIC &&
+ er->tokens[1].type == GSMD_ECMD_RTT_NUMERIC &&
+ er->tokens[2].type == GSMD_ECMD_RTT_STRING ) {
+
+
+ strcpy(buf, er->tokens[2].u.string);
+ }
+ else {
+ DEBUGP("Invalid Input : Parse error\n");
+ return -EINVAL;
+ }
+
+ talloc_free(er);
+
+ return gsmd_ucmd_submit(gu, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_N_GET,
+ cmd->id, sizeof(buf), buf);
+}
+
static int network_opers_parse(const char *str, struct gsmd_msg_oper **out)
{
int len = 0;
@@ -980,6 +1020,12 @@ static int usock_rcv_network(struct gsmd_user *gu, struct gsmd_msg_hdr *gph,
&null_cmd_cb, gu, 0, NULL));
cmd = atcmd_fill("AT+COPS?", 8+1, &network_oper_cb, gu, 0, NULL);
break;
+ case GSMD_NETWORK_OPER_N_GET:
+ /* Set numeric format */
+ atcmd_submit(gu->gsmd, atcmd_fill("AT+COPS=3,2", 11+1,
+ &null_cmd_cb, gu, 0, NULL));
+ cmd = atcmd_fill("AT+COPS?", 8+1, &network_oper_n_cb, gu, 0, NULL);
+ break;
case GSMD_NETWORK_OPER_LIST:
cmd = atcmd_fill("AT+COPS=?", 9+1, &network_opers_cb, gu, 0, NULL);
break;
diff --git a/src/libgsmd/libgsmd_network.c b/src/libgsmd/libgsmd_network.c
index eb45169..7f459c5 100644
--- a/src/libgsmd/libgsmd_network.c
+++ b/src/libgsmd/libgsmd_network.c
@@ -46,6 +46,11 @@ int lgsm_oper_get(struct lgsm_handle *lh)
return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_GET);
}
+int lgsm_oper_n_get(struct lgsm_handle *lh)
+{
+ return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_N_GET);
+}
+
int lgsm_opers_get(struct lgsm_handle *lh)
{
return lgsm_send_simple(lh, GSMD_MSG_NETWORK, GSMD_NETWORK_OPER_LIST);
diff --git a/src/util/shell.c b/src/util/shell.c
index f5f8fd3..e9aae1c 100644
--- a/src/util/shell.c
+++ b/src/util/shell.c
@@ -320,6 +320,7 @@ static int net_msghandler(struct lgsm_handle *lh, struct gsmd_msg_hdr *gmh)
pending_responses --;
break;
case GSMD_NETWORK_OPER_GET:
+ case GSMD_NETWORK_OPER_N_GET:
if (oper[0])
printf("Our current operator is %s\n", oper);
else
@@ -500,6 +501,7 @@ static void shell_help(void)
"\tR\tRegister to given operator (R=number)\n"
"\tU\tUnregister from netowrk\n"
"\tP\tPrint current operator\n"
+ "\tN\tPrint current operator in numeric\n"
"\tL\tList available operators\n"
"\tQ\tRead signal quality\n"
"\tS\tSleep (S[=second], default 5)\n"
@@ -634,6 +636,10 @@ int shell_main(struct lgsm_handle *lgsmh, int sync)
printf("Read current opername\n");
lgsm_oper_get(lgsmh);
pending_responses ++;
+ } else if (!strcmp(buf, "N")) {
+ printf("Read current opername in numeric format\n");
+ lgsm_oper_n_get(lgsmh);
+ pending_responses ++;
} else if (!strcmp(buf, "L")) {
printf("List operators\n");
lgsm_opers_get(lgsmh);
personal git repositories of Harald Welte. Your mileage may vary