From: Anthony Viallard <viallard@syscom-instruments.com>
To: ofono@ofono.org
Subject: [PATCH 6/6] SIMCOM: add a quirk to retrieve network technology used
Date: Fri, 19 Jul 2013 15:35:40 +0200 [thread overview]
Message-ID: <1374240940-30892-6-git-send-email-viallard@syscom-instruments.com> (raw)
In-Reply-To: <1374240940-30892-1-git-send-email-viallard@syscom-instruments.com>
[-- Attachment #1: Type: text/plain, Size: 2843 bytes --]
Use CNSMOD command to get network technology and monitor
changes.
---
drivers/atmodem/network-registration.c | 76 ++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 8cc04b7..d634dbb 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -239,6 +239,14 @@ static void at_registration_status(struct ofono_netreg *netreg,
cbd->user = nd;
switch (nd->vendor) {
+ case OFONO_VENDOR_SIMCOM:
+ /*
+ * Send +CNSMOD? to find out the current tech, it will be
+ * intercepted in simcom_cnsmod_notify
+ */
+ g_at_chat_send(nd->chat, "AT+CNSMOD?", none_prefix,
+ NULL, NULL, NULL);
+ break;
case OFONO_VENDOR_MBM:
/*
* Send *ERINFO to find out the current tech, it will be
@@ -1329,6 +1337,66 @@ static int cnti_to_tech(const char *cnti)
return -1;
}
+static void simcom_cnsmod_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_netreg *netreg = user_data;
+ struct netreg_data *nd = ofono_netreg_get_data(netreg);
+ GAtResultIter iter;
+ int n1,
+ n2,
+ mode;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (g_at_result_iter_next(&iter, "+CNSMOD:") == FALSE)
+ return;
+
+ if (g_at_result_iter_next_number(&iter, &n1) == FALSE)
+ return;
+
+ if (g_at_result_iter_next_number(&iter, &n2) == FALSE)
+ n2 = -1;
+
+ if (n2 != -1)
+ mode = n2;
+ else
+ mode = n1;
+
+ switch (mode) {
+ case 1:
+ case 2:
+ /* GSM, GPRS */
+ nd->tech = ACCESS_TECHNOLOGY_GSM;
+ break;
+ case 3:
+ /* EDGE */
+ nd->tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
+ break;
+ case 4:
+ /* WCDMA */
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN;
+ break;
+ case 5:
+ /* HSDPA */
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
+ break;
+ case 6:
+ /* HSUPA */
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
+ break;
+ case 7: /* HSUPA and HSDPA */
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
+ break;
+ default:
+ case 0:
+ /* no service */
+ nd->tech = -1;
+ break;
+ }
+
+ ofono_netreg_tech_notify(netreg, nd->tech);
+}
+
static void gobi_cnti_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -1760,6 +1828,14 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_register(nd->chat, "+CSQ:",
csq_notify, FALSE, netreg, NULL);
+
+ /* Register for network technology change */
+ g_at_chat_register(nd->chat, "+CNSMOD:",
+ simcom_cnsmod_notify, FALSE, netreg, NULL);
+
+ g_at_chat_send(nd->chat, "AT+CNSMOD=1", none_prefix,
+ NULL, NULL, NULL);
+
break;
case OFONO_VENDOR_PHONESIM:
g_at_chat_register(nd->chat, "+CSQ:",
--
1.8.3.1
next prev parent reply other threads:[~2013-07-19 13:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 13:35 [PATCH 1/6] Add SIMCOM support Anthony Viallard
2013-07-19 13:35 ` [PATCH 2/6] SIMCOM: add a quirk for AT+CNMI command building Anthony Viallard
2013-07-22 20:49 ` Denis Kenzior
2013-07-19 13:35 ` [PATCH 3/6] SIMCOM: add a quirk for signal strength reporting Anthony Viallard
2013-07-22 20:49 ` Denis Kenzior
2013-07-19 13:35 ` [PATCH 4/6] SIMCOM: add a quirk to fix crsm request Anthony Viallard
2013-07-22 20:51 ` Denis Kenzior
2013-07-19 13:35 ` [PATCH 5/6] Add a function to be able to report network technology change Anthony Viallard
2013-07-22 20:57 ` Denis Kenzior
2013-07-19 13:35 ` Anthony Viallard [this message]
2013-07-22 21:08 ` [PATCH 6/6] SIMCOM: add a quirk to retrieve network technology used Denis Kenzior
2013-07-22 20:45 ` [PATCH 1/6] Add SIMCOM support Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374240940-30892-6-git-send-email-viallard@syscom-instruments.com \
--to=viallard@syscom-instruments.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox