From: Lars Poeschel <poeschel(a)lemonage.de>
As the default way of getting the signal quality with +CIND is also
unstable on quectel serial modems (the same as on quectel EC21). In fact
the signal quality is only updated on cell changes. Those trigger a
manual AT+CSQ in ofono and get an update this way, but the URCs do not
work.
So we implement a quectelish way here as well.
--- >8 ---
I send this patch as a RFC because the quectel_csqn_notify function
very much duplicates the ifx_xcsq_notify function despite the "+CSQN"
string. I did not see a good way to reuse the already existing
function because the callback interface only has one user defined
pointer and this is used by the struct ofono_netreg pointer already.
Does anyone have a better idea ?
Thanks,
Lars
---
drivers/atmodem/network-registration.c | 34 ++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/atmodem/network-registration.c
b/drivers/atmodem/network-registration.c
index 78b1994c..74829201 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -1017,6 +1017,33 @@ static void quectel_qind_notify(GAtResult *result, gpointer
user_data)
}
}
+static void quectel_csqn_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_netreg *netreg = user_data;
+ int rssi, ber, strength;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CSQN:"))
+ return;
+
+ 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)
+ strength = -1;
+ else
+ strength = (rssi * 100) / 31;
+
+ ofono_netreg_strength_notify(netreg, strength);
+}
+
static gboolean notify_time(gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -2118,6 +2145,13 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer
user_data)
g_at_chat_send(nd->chat, "AT+QINDCFG=\"act\",1", none_prefix,
NULL, NULL, NULL);
break;
+ case OFONO_VENDOR_QUECTEL_SERIAL:
+ g_at_chat_register(nd->chat, "+CSQN:",
+ quectel_csqn_notify, FALSE, netreg, NULL);
+ /* Register for specific signal strength reports */
+ g_at_chat_send(nd->chat, "AT+QEXTUNSOL=\"SQ\",1", none_prefix,
+ NULL, NULL, NULL);
+ break;
default:
g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix,
cind_support_cb, netreg, NULL);
--
2.27.0
Show replies by date
Hi Lars,
On 8/19/20 7:43 AM, poeschel(a)lemonage.de wrote:
From: Lars Poeschel <poeschel(a)lemonage.de>
As the default way of getting the signal quality with +CIND is also
unstable on quectel serial modems (the same as on quectel EC21). In fact
the signal quality is only updated on cell changes. Those trigger a
manual AT+CSQ in ofono and get an update this way, but the URCs do not
work.
So we implement a quectelish way here as well.
--- >8 ---
I send this patch as a RFC because the quectel_csqn_notify function
very much duplicates the ifx_xcsq_notify function despite the "+CSQN"
string. I did not see a good way to reuse the already existing
function because the callback interface only has one user defined
pointer and this is used by the struct ofono_netreg pointer already.
Does anyone have a better idea ?
You could take advantage of the fact that at_netreg_data carries the vendor id
in nd->vendor. So if you wanted to make ifx_xcsq_notify you could do something
like:
struct ofono_netreg *netreg = user_data;
struct at_netreg_data *nd =
ofono_netreg_get_data(netreg);
switch (nd->vendor) {
case ...
prefix = "+XCSQ:";
break;
case ...
prefix = "+CSQN:";
break;
}
....
Or just put the meat of ifx_xcsq_notify into a separate function that takes the
prefix as a parameter...
Then ifx_xcsq_notify might look something like:
netreg_generic_strength_report("+XCSQ:");
Thanks,
Lars
---
drivers/atmodem/network-registration.c | 34 ++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
Regards,
-Denis
On Wed, Aug 19, 2020 at 10:19:13AM -0500, Denis Kenzior wrote:
Hi Lars,
On 8/19/20 7:43 AM, poeschel(a)lemonage.de wrote:
> From: Lars Poeschel <poeschel(a)lemonage.de>
>
> As the default way of getting the signal quality with +CIND is also
> unstable on quectel serial modems (the same as on quectel EC21). In fact
> the signal quality is only updated on cell changes. Those trigger a
> manual AT+CSQ in ofono and get an update this way, but the URCs do not
> work.
> So we implement a quectelish way here as well.
>
> --- >8 ---
>
> I send this patch as a RFC because the quectel_csqn_notify function
> very much duplicates the ifx_xcsq_notify function despite the "+CSQN"
> string. I did not see a good way to reuse the already existing
> function because the callback interface only has one user defined
> pointer and this is used by the struct ofono_netreg pointer already.
> Does anyone have a better idea ?
You could take advantage of the fact that at_netreg_data carries the vendor
id in nd->vendor. So if you wanted to make ifx_xcsq_notify you could do
something like:
struct ofono_netreg *netreg = user_data;
struct at_netreg_data *nd =
ofono_netreg_get_data(netreg);
switch (nd->vendor) {
case ...
prefix = "+XCSQ:";
break;
case ...
prefix = "+CSQN:";
break;
}
Denis, thank you for helping out!
I think I'll go for the vendor switch.
Or just put the meat of ifx_xcsq_notify into a separate function that
takes
the prefix as a parameter...
Then ifx_xcsq_notify might look something like:
netreg_generic_strength_report("+XCSQ:");
Regards,
Lars