From: Giacinto Cifelli <gciofono@gmail.com>
To: ofono@ofono.org
Subject: [PATCH] atmodem/gprs: initial Gemalto vendor-specific support
Date: Sun, 23 Sep 2018 07:23:06 +0200 [thread overview]
Message-ID: <20180923052306.8052-1-gciofono@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5374 bytes --]
---
drivers/atmodem/gprs.c | 128 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 123 insertions(+), 5 deletions(-)
diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index fc0d8aa3..84ee5c7d 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -672,6 +672,91 @@ static void ublox_ureg_notify(GAtResult *result, gpointer user_data)
ofono_gprs_bearer_notify(gprs, bearer);
}
+static void gemalto_ciev_ceer_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_gprs *gprs = user_data;
+ const char *report;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CIEV: ceer,"))
+ return;
+ /*
+ * No need to check release cause group
+ * as we only subscribe to no. 5
+ */
+ if (!g_at_result_iter_skip_next(&iter))
+ return;
+ if (!g_at_result_iter_next_string(&iter, &report))
+ return;
+
+ /* TODO: Handle more of these? */
+
+ if (g_str_equal(report, "Regular deactivation")) {
+ ofono_gprs_detached_notify(gprs);
+ return;
+ }
+}
+
+static void gemalto_ciev_bearer_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_gprs *gprs = user_data;
+ int bearer;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CIEV: psinfo,"))
+ return;
+ if (!g_at_result_iter_next_number(&iter, &bearer))
+ return;
+
+ /* Go from Gemalto representation to oFono representation */
+ switch (bearer) {
+ case 0: /* GPRS/EGPRS not available */
+ /* Same as "no bearer"? */
+ bearer = 0;
+ break;
+ case 1: /* GPRS available, ignore this one */
+ return;
+ case 2: /* GPRS attached */
+ bearer = 1;
+ break;
+ case 3: /* EGPRS available, ignore this one */
+ return;
+ case 4: /* EGPRS attached */
+ bearer = 2;
+ break;
+ case 5: /* UMTS available, ignore this one */
+ return;
+ case 6: /* UMTS attached */
+ bearer = 3;
+ break;
+ case 7: /* HSDPA available, ignore this one */
+ return;
+ case 8: /* HSDPA attached */
+ bearer = 5;
+ break;
+ case 9: /* HSDPA/HSUPA available, ignore this one */
+ return;
+ case 10: /* HSDPA/HSUPA attached */
+ bearer = 6;
+ break;
+ /* TODO: Limit these cases to ALS3? */
+ case 16: /* E-UTRA available, ignore this one */
+ return;
+ case 17: /* E-UTRA attached */
+ bearer = 7;
+ break;
+ default: /* Assume that non-parsable values mean "no bearer" */
+ bearer = 0;
+ break;
+ }
+
+ ofono_gprs_bearer_notify(gprs, bearer);
+}
+
static void cpsb_notify(GAtResult *result, gpointer user_data)
{
struct ofono_gprs *gprs = user_data;
@@ -696,8 +781,13 @@ static void gprs_initialized(struct ofono_gprs *gprs)
{
struct gprs_data *gd = ofono_gprs_get_data(gprs);
- g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
- NULL);
+ switch (gd->vendor) {
+ case OFONO_VENDOR_GEMALTO:
+ break;
+ default:
+ g_at_chat_send(gd->chat, "AT+CGAUTO=0", none_prefix, NULL, NULL,
+ NULL);
+ }
switch (gd->vendor) {
case OFONO_VENDOR_MBM:
@@ -710,6 +800,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
g_at_chat_send(gd->chat, "AT+CGEREP=1", none_prefix,
NULL, NULL, NULL);
break;
+ case OFONO_VENDOR_GEMALTO:
+ g_at_chat_send(gd->chat, "AT+CGEREP=2", NULL,
+ NULL, NULL, NULL);
+ g_at_chat_send(gd->chat, "AT^SIND=\"psinfo\",1", none_prefix,
+ NULL, NULL, NULL);
+ break;
default:
g_at_chat_send(gd->chat, "AT+CGEREP=2,1", none_prefix,
NULL, NULL, NULL);
@@ -744,6 +840,12 @@ static void gprs_initialized(struct ofono_gprs *gprs)
g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix,
NULL, NULL, NULL);
break;
+ case OFONO_VENDOR_GEMALTO:
+ g_at_chat_register(gd->chat, "+CIEV: psinfo,",
+ gemalto_ciev_bearer_notify, FALSE, gprs, NULL);
+ g_at_chat_register(gd->chat, "+CIEV: ceer,",
+ gemalto_ciev_ceer_notify, FALSE, gprs, NULL);
+ break;
default:
g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
FALSE, gprs, NULL);
@@ -815,7 +917,13 @@ retry:
g_at_result_iter_close_list(&iter);
- if (cgreg1) {
+ if (gd->vendor == OFONO_VENDOR_GEMALTO) {
+ /*
+ * Gemalto prefers to print as much information as available
+ * for support purposes
+ */
+ sprintf(buf, "AT+%s=%d",ind, range[1]);
+ } else if (cgreg1) {
sprintf(buf,"AT+%s=1", ind);
} else if (cgreg2) {
sprintf(buf,"AT+%s=2", ind);
@@ -931,6 +1039,8 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
{
GAtChat *chat = data;
struct gprs_data *gd;
+ int autoattach;
+ struct ofono_modem* modem=ofono_gprs_get_modem(gprs);
gd = g_try_new0(struct gprs_data, 1);
if (gd == NULL)
@@ -941,8 +1051,16 @@ static int at_gprs_probe(struct ofono_gprs *gprs,
ofono_gprs_set_data(gprs, gd);
- g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
- at_cgdcont_test_cb, gprs, NULL);
+ if (gd->vendor == OFONO_VENDOR_GEMALTO) {
+ autoattach=ofono_modem_get_integer(modem, "GemaltoAutoAttach");
+ /* set autoattach */
+ gd->auto_attach = (autoattach == 1);
+ /* skip the cgdcont scanning: set manually */
+ test_and_set_regstatus(gprs);
+ } else {
+ g_at_chat_send(gd->chat, "AT+CGDCONT=?", cgdcont_prefix,
+ at_cgdcont_test_cb, gprs, NULL);
+ }
return 0;
}
--
2.17.1
next reply other threads:[~2018-09-23 5:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-23 5:23 Giacinto Cifelli [this message]
2018-09-27 16:03 ` [PATCH] atmodem/gprs: initial Gemalto vendor-specific 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=20180923052306.8052-1-gciofono@gmail.com \
--to=gciofono@gmail.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