summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Poeschel <poeschel@lemonage.de>2020-08-11 13:42:16 +0200
committerDenis Kenzior <denkenz@gmail.com>2020-08-11 10:47:58 -0500
commita01613ad13e6bbf9afef0b92a73a20fdff6c624e (patch)
treed4a17b754e5f10870de3061231955a15a2d32d6a
parent3401d9e29cdfe728ecb28c2eb4487892d4f32ffc (diff)
downloadofono-a01613ad13e6bbf9afef0b92a73a20fdff6c624e.tar.gz
atmodem: Get strength and tech the quectel way on EC21
I had some trouble getting network strengh and access technology the standard way on Quectel EC21. It does work - but only kind of. I did not get URCs when I am sure I should. This way through CIEV, CIND and CMER is also not documented in Quectel documentation, so I suspect this to be unsupported. This is now changed to the "quectelish" way of gettings those values and this does work more fine-grained and reliable on the Quectel EC21.
-rw-r--r--drivers/atmodem/network-registration.c71
-rw-r--r--plugins/quectel.c2
2 files changed, 72 insertions, 1 deletions
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index cc702c2c..78b1994c 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -957,6 +957,66 @@ static void tlts_notify(GAtResult *result, gpointer user_data)
ofono_netreg_time_notify(netreg, &nd->time);
}
+static void quectel_qind_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_netreg *netreg = user_data;
+ struct at_netreg_data *nd = ofono_netreg_get_data(netreg);
+ int rssi, ber, strength;
+ const char *str;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+QIND:"))
+ return;
+
+ if (!g_at_result_iter_next_string(&iter, &str))
+ return;
+
+ if (g_str_equal("csq", str)) {
+ if (!g_at_result_iter_next_number(&iter, &rssi))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &ber))
+ return;
+
+ DBG("rssi %d ber %d", rssi, ber);
+
+ if ((rssi == 99) || (rssi == 199))
+ strength = -1;
+ else if (rssi > 99) {
+ rssi -= 100;
+ strength = (rssi * 100) / 91;
+ } else
+ strength = (rssi * 100) / 31;
+
+ ofono_netreg_strength_notify(netreg, strength);
+ return;
+ }
+
+ if (g_str_equal("act", str)) {
+ nd->tech = -1;
+ if (!g_at_result_iter_next_string(&iter, &str))
+ return;
+
+ DBG("technology %s", str);
+ if (g_str_equal("GSM", str))
+ nd->tech = ACCESS_TECHNOLOGY_GSM;
+ else if (g_str_equal("EGPRS", str))
+ nd->tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
+ else if (g_str_equal("WCDMA", str))
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN;
+ else if (g_str_equal("HSDPA", str))
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
+ else if (g_str_equal("HSUPA", str))
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
+ else if (g_str_equal("HSDPA&HSUPA", str))
+ nd->tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
+ else if (g_str_equal("LTE", str))
+ nd->tech = ACCESS_TECHNOLOGY_EUTRAN;
+ }
+}
+
static gboolean notify_time(gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -2047,6 +2107,17 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
case OFONO_VENDOR_SAMSUNG:
/* Signal strength reporting via CIND is not supported */
break;
+ case OFONO_VENDOR_QUECTEL_EC2X:
+ g_at_chat_register(nd->chat, "+QIND:",
+ quectel_qind_notify, FALSE, netreg, NULL);
+ /* Register for specific signal strength reports */
+ g_at_chat_send(nd->chat, "AT+QINDCFG=\"csq\",1", none_prefix,
+ NULL, NULL, NULL);
+
+ /* Register for network technology updates */
+ g_at_chat_send(nd->chat, "AT+QINDCFG=\"act\",1", none_prefix,
+ NULL, NULL, NULL);
+ break;
default:
g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
cind_support_cb, netreg, NULL);
diff --git a/plugins/quectel.c b/plugins/quectel.c
index 8ca901f2..c3343008 100644
--- a/plugins/quectel.c
+++ b/plugins/quectel.c
@@ -1286,7 +1286,7 @@ static void quectel_post_online(struct ofono_modem *modem)
DBG("%p", modem);
- ofono_netreg_create(modem, 0, "atmodem", data->aux);
+ ofono_netreg_create(modem, data->vendor, "atmodem", data->aux);
}
static struct ofono_modem_driver quectel_driver = {