Re: [RFC PATCH] atmodem: Signal quality on quectel serial modems

2020-08-19 Thread Denis Kenzior

Hi Lars,

On 8/19/20 7:43 AM, poesc...@lemonage.de wrote:

From: Lars Poeschel 

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
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: [PATCH 1/2] atmodem: Detect usage of AT+CGEREP

2020-08-19 Thread Denis Kenzior

Hi Lars,

On 8/19/20 7:13 AM, poesc...@lemonage.de wrote:

From: Lars Poeschel 

Currently AT+CGEREP=2,1 is sent in case we don't know what the modem
needs. (default case) Not all modems understand this. So, we first query
what the modem supports with AT+CGEREP=? and then use this information
to be nice to the modem. This way modems, like the Quectel M95 that do
only understand AT+CGEREP=1 do also work nicely.


I think this is a nice improvement, couple of comments below:


---
  drivers/atmodem/gprs.c | 75 --
  1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index d829e2e6..3900b95b 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -45,6 +45,7 @@
  #define MAX_CONTEXTS 255
  
  static const char *cgreg_prefix[] = { "+CGREG:", NULL };

+static const char *cgerep_prefix[] = { "+CGEREP:", NULL };
  static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
  static const char *cgact_prefix[] = { "+CGACT:", NULL };
  static const char *none_prefix[] = { NULL };
@@ -647,6 +648,76 @@ static void gprs_initialized(gboolean ok, GAtResult 
*result, gpointer user_data)
ofono_gprs_register(gprs);
  }
  
+static void at_cgerep_test_cb(gboolean ok, GAtResult *result,

+   gpointer user_data)
+{
+   struct ofono_gprs *gprs = user_data;
+   struct gprs_data *gd = ofono_gprs_get_data(gprs);
+   GAtResultIter iter;
+   int min1, max1 = 1, min2, max2 = 1;
+   gboolean two_arguments = true;
+   char buf[20];
+
+   if (!ok)
+   return;


Hmm, maybe a good idea here is to print a warning and call ofono_gprs_remove(). 
Otherwise this will just fail silently for someone.



+
+   g_at_result_iter_init(, result);
+
+   g_at_result_iter_next(, "+CGEREP:");
+
+   if (!g_at_result_iter_open_list())
+   return;


Ditto here


+
+   if (!g_at_result_iter_next_range(, , ))
+   return;
+


So why not just run iter_next_range in a loop?  it actually understands both 
lists and ranges.  See cind_support_cb() for an example.



+   /* if min1 == max1 we had no range but a list and that
+* means we are interested in the last number of that list*/
+   if (min1 == max1) {
+   while (!g_at_result_iter_close_list()) {
+   if (!g_at_result_iter_next_number(, ))
+   break;
+   }
+   }
+
+   if (!g_at_result_iter_skip_next()) {
+   two_arguments = false;
+   goto out;
+   }


Not sure what this is doing?  isn't +CGEREP just two lists ?  According to 
27.007:
"+CGEREP: (list of supported s),(list of supported s)"


+
+   if (!g_at_result_iter_open_list()) {
+   two_arguments = false;
+   goto out;
+   }
+
+   if (!g_at_result_iter_next_range(, , )) {
+   two_arguments = false;
+   goto out;
+   }
+
+   if (min2 == max2) {
+   while (!g_at_result_iter_close_list()) {
+   if (!g_at_result_iter_next_number(, )) {
+   break;
+   }
+   }
+   }
+
+out:
+   if (max1 > 2)
+   max1 = 2;
+
+   if (max2 > 1)
+   max2 = 1;
+
+   if (two_arguments)
+   sprintf(buf, "AT+CGEREP=%u,%u", max1, max2);
+   else
+   sprintf(buf, "AT+CGEREP=%u", max1);
+
+   g_at_chat_send(gd->chat, buf, none_prefix, gprs_initialized, gprs, 
NULL);
+}
+
  static void at_cgreg_test_cb(gboolean ok, GAtResult *result,
gpointer user_data)
  {
@@ -701,8 +772,8 @@ retry:
gprs_initialized, gprs, NULL);
break;
default:
-   g_at_chat_send(gd->chat, "AT+CGEREP=2,1", none_prefix,
-   gprs_initialized, gprs, NULL);
+   g_at_chat_send(gd->chat, "AT+CGEREP=?", cgerep_prefix,
+   at_cgerep_test_cb, gprs, NULL);
break;
}
  



Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: [PATCH 2/2] atmodem: Deactivate AT+CPSB for quectel serial modems

2020-08-19 Thread Denis Kenzior

Hi Lars,

On 8/19/20 7:13 AM, poesc...@lemonage.de wrote:

From: Lars Poeschel 

There are at the moment two quectel modems in ofono vendored as
OFONO_VENDOR_QUECTEL_SERIAL: The M95 and the MC60.
Both modems are GSM only modems, and their official documentation does
not mention the AT+CPSB command.
I have a M95 here that gives an error on issuing the AT+CPSB=1 command.
So skip this command for these two modems.
---
  drivers/atmodem/gprs.c | 1 +
  1 file changed, 1 insertion(+)



Applied, thanks.

Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


Re: [PATCH v2 0/3] gemalto: USB ethernet data path for ELS81x

2020-08-19 Thread Denis Kenzior

Hi Sergey,

On 8/18/20 3:43 PM, Sergey Matyukevich wrote:

Hi Denis and all,

This patch series enables USB ethernet data path for gemalto modems
that support this feature, in particular for ELS81x devices.


All three applied (minus the S-o-B tags).  Thanks!

Regards,
-Denis
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[RFC PATCH] atmodem: Signal quality on quectel serial modems

2020-08-19 Thread poeschel
From: Lars Poeschel 

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(, result);
+
+   if (!g_at_result_iter_next(, "+CSQN:"))
+   return;
+
+   if (!g_at_result_iter_next_number(, ))
+   return;
+
+   if (!g_at_result_iter_next_number(, ))
+   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
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[PATCH 2/2] atmodem: Deactivate AT+CPSB for quectel serial modems

2020-08-19 Thread poeschel
From: Lars Poeschel 

There are at the moment two quectel modems in ofono vendored as
OFONO_VENDOR_QUECTEL_SERIAL: The M95 and the MC60.
Both modems are GSM only modems, and their official documentation does
not mention the AT+CPSB command.
I have a M95 here that gives an error on issuing the AT+CPSB=1 command.
So skip this command for these two modems.
---
 drivers/atmodem/gprs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 3900b95b..f4c714e8 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -626,6 +626,7 @@ static void gprs_initialized(gboolean ok, GAtResult 
*result, gpointer user_data)
NULL, NULL, NULL);
break;
case OFONO_VENDOR_QUECTEL_EC2X:
+   case OFONO_VENDOR_QUECTEL_SERIAL:
break;
default:
g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify,
-- 
2.27.0
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org


[PATCH 1/2] atmodem: Detect usage of AT+CGEREP

2020-08-19 Thread poeschel
From: Lars Poeschel 

Currently AT+CGEREP=2,1 is sent in case we don't know what the modem
needs. (default case) Not all modems understand this. So, we first query
what the modem supports with AT+CGEREP=? and then use this information
to be nice to the modem. This way modems, like the Quectel M95 that do
only understand AT+CGEREP=1 do also work nicely.
---
 drivers/atmodem/gprs.c | 75 --
 1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index d829e2e6..3900b95b 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -45,6 +45,7 @@
 #define MAX_CONTEXTS 255
 
 static const char *cgreg_prefix[] = { "+CGREG:", NULL };
+static const char *cgerep_prefix[] = { "+CGEREP:", NULL };
 static const char *cgdcont_prefix[] = { "+CGDCONT:", NULL };
 static const char *cgact_prefix[] = { "+CGACT:", NULL };
 static const char *none_prefix[] = { NULL };
@@ -647,6 +648,76 @@ static void gprs_initialized(gboolean ok, GAtResult 
*result, gpointer user_data)
ofono_gprs_register(gprs);
 }
 
+static void at_cgerep_test_cb(gboolean ok, GAtResult *result,
+   gpointer user_data)
+{
+   struct ofono_gprs *gprs = user_data;
+   struct gprs_data *gd = ofono_gprs_get_data(gprs);
+   GAtResultIter iter;
+   int min1, max1 = 1, min2, max2 = 1;
+   gboolean two_arguments = true;
+   char buf[20];
+
+   if (!ok)
+   return;
+
+   g_at_result_iter_init(, result);
+
+   g_at_result_iter_next(, "+CGEREP:");
+
+   if (!g_at_result_iter_open_list())
+   return;
+
+   if (!g_at_result_iter_next_range(, , ))
+   return;
+
+   /* if min1 == max1 we had no range but a list and that
+* means we are interested in the last number of that list*/
+   if (min1 == max1) {
+   while (!g_at_result_iter_close_list()) {
+   if (!g_at_result_iter_next_number(, ))
+   break;
+   }
+   }
+
+   if (!g_at_result_iter_skip_next()) {
+   two_arguments = false;
+   goto out;
+   }
+
+   if (!g_at_result_iter_open_list()) {
+   two_arguments = false;
+   goto out;
+   }
+
+   if (!g_at_result_iter_next_range(, , )) {
+   two_arguments = false;
+   goto out;
+   }
+
+   if (min2 == max2) {
+   while (!g_at_result_iter_close_list()) {
+   if (!g_at_result_iter_next_number(, )) {
+   break;
+   }
+   }
+   }
+
+out:
+   if (max1 > 2)
+   max1 = 2;
+
+   if (max2 > 1)
+   max2 = 1;
+
+   if (two_arguments)
+   sprintf(buf, "AT+CGEREP=%u,%u", max1, max2);
+   else
+   sprintf(buf, "AT+CGEREP=%u", max1);
+
+   g_at_chat_send(gd->chat, buf, none_prefix, gprs_initialized, gprs, 
NULL);
+}
+
 static void at_cgreg_test_cb(gboolean ok, GAtResult *result,
gpointer user_data)
 {
@@ -701,8 +772,8 @@ retry:
gprs_initialized, gprs, NULL);
break;
default:
-   g_at_chat_send(gd->chat, "AT+CGEREP=2,1", none_prefix,
-   gprs_initialized, gprs, NULL);
+   g_at_chat_send(gd->chat, "AT+CGEREP=?", cgerep_prefix,
+   at_cgerep_test_cb, gprs, NULL);
break;
}
 
-- 
2.27.0
___
ofono mailing list -- ofono@ofono.org
To unsubscribe send an email to ofono-le...@ofono.org