On Mon, 2018-02-05 at 15:45 +0000, Matthew Starr wrote:
> > On Thu, 2018-02-01 at 22:09 +0000, Matthew Starr wrote:
> > > I am using a TOBY-R200 which does not support USB Ethernet like
> > > TOBY-
> > > L2 models, but only supports AT interface over USB serial.  When
> > > I use
> > > a NetworkManager profile to start a 3G/4G connection using
> > > ModemManager with the TOBY-R200, the registration step takes a
> > > long
> > > time (~37 seconds).  The modem does eventually connect and
> > > everything
> > > work, but it takes too long for my use case.  When I use a u-blox 
> > > LISA
> > > U230 modem with the same software configuration, hardware
> > > platform,
> > > and SIM card, I get a connection quickly (~5 second).  When I put
> > > ModemManager in debug mode there is a difference in the
> > > connection
> > > between the two at the registration step as shown below. I have
> > > the
> > > same issue on ModemManager versions 1.4.14, 1.6.4, and 1.6.12.
> > 
> > <snip>
> > 
> > > On the TOBY R200, instead of realizing that the modem is already
> > > registered with the network, it runs AT+COPS=0 to reregister with
> > > the
> > > network.  I confirmed that the modem registered with the network
> > > by
> > > checking the AT+CREG?, AT+CEREG?, and AT+CGREG? commands.  Here
> > > is
> > > what ModemManager is outputting when connecting to the network:
> > 
> > Do you see this line at all?
> > 
> > Modem XXX: 3GPP Registration state changed (XXX -> registering)
> > 
> > Basically, right after enabling the modem, ModemManager should be
> > running initial registration checks.  That will run a sequence of
> > AT+CREG?, AT+CGREG?, and AT+CEREG? requests which should report the
> > operator ID (eg MCC/MNC).  This should all happen before the
> > connect, but
> > perhaps the NM connect request is happening to quickly.
> 
> I see that line and waited until that line was output to command
> Network Manager to bring up the GSM connection. See log below
> 
> > 
> > Can you include a bit more of the ModemManager debug output from
> > the
> > time the modem is "enabling" until what you show below?

Thanks; this is a bug in ModemManager but also odd behavior in the
modem.  This could actually be triggered by your SIM though, given the
description of the TOBY-R2 series response to the +COPS command in
ublox document UBX-13002752 (R56).  Anyway:

(ttyACM1): <-- '<CR><LF>+CGREG:
1,"xxxx","xxxxxxxx",6,"6C"<CR><LF><CR><LF>+CIEV:
9,2<CR><LF><CR><LF>+CEREG: 4<CR><LF>'
(ttyACM0): --> 'AT+COPS=3,2;+COPS?<CR>'
(ttyACM0): <-- '<CR><LF>+COPS: 0<CR><LF><CR><LF>OK<CR><LF>'
modem_3gpp_load_operator_name(): loading Operator Name...
(ttyACM0): --> 'AT+COPS=3,0;+COPS?<CR>'
(ttyACM0): <-- '<CR><LF>+COPS: 0<CR><LF><CR><LF>OK<CR><LF>'

Here MM is requesting the "set format only" COPS response, then asking
for the current operator name and number.  The modem replies with "0"
both times; usually devices are supposed to reply with the MCC/MNC and
the operator name.  Might be worth asking ublox why the device responds
this way, but again it could be due to the SIM card.

Anyway, the modem just isn't giving us any information about the
MCC/MNC and operator name, despite the fact that it's registered with
the network and must already know these things.  But MM currently looks
to see if it has a valid operator MCC/MNC before short-circuiting the
automatic registration AT+COPS=0 that you're running into.

Could you try patch below and see if that makes things work better? 
(Attached too just in case my mailer screws up the formatting...)

Dan

diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 89023a46..4ac32fd5 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -119,6 +119,17 @@ get_registration_state_context (MMIfaceModem3gpp *self)
     return ctx;
 }
 
+static gboolean
+reg_state_is_registered (MMModem3gppRegistrationState state)
+{
+    return state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED;
+}
+
 static MMModem3gppRegistrationState
 get_consolidated_reg_state (RegistrationStateContext *ctx)
 {
@@ -307,12 +318,7 @@ run_registration_checks_ready (MMIfaceModem3gpp *self,
     }
 
     /* If we got registered, end registration checks */
-    if (current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING 
||
-        current_registration_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        current_registration_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        current_registration_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        current_registration_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (current_registration_state)) {
         /* Request immediate access tech and signal update: we may have changed
          * from home to roaming or viceversa, both registered states, so there
          * wouldn't be an explicit refresh triggered from the modem interface 
as
@@ -436,9 +442,11 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp 
*self,
     }
     /* Automatic registration requested? */
     else {
+        MMModem3gppRegistrationState reg_state = 
mm_gdbus_modem3gpp_get_registration_state (ctx->skeleton);
+
         /* If the modem is already registered and the last time it was asked
          * automatic registration, we're done */
-        if (current_operator_code &&
+        if ((current_operator_code || reg_state_is_registered (reg_state)) &&
             !registration_state_context->manual_registration) {
             mm_dbg ("Already registered in network '%s',"
                     " automatic registration not launched...",
@@ -1195,13 +1203,7 @@ mm_iface_modem_3gpp_update_access_technologies 
(MMIfaceModem3gpp *self,
 
     /* Even if registration state didn't change, report access technology,
      * but only if something valid to report */
-    if (state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED ||
-        ctx->reloading_registration_info) {
+    if (reg_state_is_registered (state) || ctx->reloading_registration_info) {
         if (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN)
             mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self),
                                                        access_tech,
@@ -1234,13 +1236,7 @@ mm_iface_modem_3gpp_update_location (MMIfaceModem3gpp 
*self,
      * location updates, but only if something valid to report. For the case
      * where we're registering (loading current registration info after a state
      * change to registered), we also allow LAC/CID updates. */
-    if (ctx->reloading_registration_info ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (state) || ctx->reloading_registration_info) {
         if (location_area_code > 0 && cell_id > 0)
             mm_iface_modem_location_3gpp_update_lac_ci 
(MM_IFACE_MODEM_LOCATION (self),
                                                         location_area_code,
@@ -1292,12 +1288,7 @@ update_non_registered_state (MMIfaceModem3gpp *self,
      * sent by the carrier during registration or b) by looking at the
      * registration reject error code.  If b), we want to make sure we
      * preserve the subscription state */
-    if (old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED 
||
-        old_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED)
+    if (reg_state_is_registered (old_state))
         clear_subscription_state (self);
 
     /* The property in the interface is bound to the property
@@ -1334,12 +1325,7 @@ update_registration_state (MMIfaceModem3gpp *self,
     if (new_state == old_state)
         return;
 
-    if (new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED 
||
-        new_state == 
MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (new_state)) {
         MMModemState modem_state;
 
         /* If already reloading registration info, skip it */
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index 89023a46..4ac32fd5 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -119,6 +119,17 @@ get_registration_state_context (MMIfaceModem3gpp *self)
     return ctx;
 }
 
+static gboolean
+reg_state_is_registered (MMModem3gppRegistrationState state)
+{
+    return state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
+        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED;
+}
+
 static MMModem3gppRegistrationState
 get_consolidated_reg_state (RegistrationStateContext *ctx)
 {
@@ -307,12 +318,7 @@ run_registration_checks_ready (MMIfaceModem3gpp *self,
     }
 
     /* If we got registered, end registration checks */
-    if (current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        current_registration_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (current_registration_state)) {
         /* Request immediate access tech and signal update: we may have changed
          * from home to roaming or viceversa, both registered states, so there
          * wouldn't be an explicit refresh triggered from the modem interface as
@@ -436,9 +442,11 @@ mm_iface_modem_3gpp_register_in_network (MMIfaceModem3gpp *self,
     }
     /* Automatic registration requested? */
     else {
+        MMModem3gppRegistrationState reg_state = mm_gdbus_modem3gpp_get_registration_state (ctx->skeleton);
+
         /* If the modem is already registered and the last time it was asked
          * automatic registration, we're done */
-        if (current_operator_code &&
+        if ((current_operator_code || reg_state_is_registered (reg_state)) &&
             !registration_state_context->manual_registration) {
             mm_dbg ("Already registered in network '%s',"
                     " automatic registration not launched...",
@@ -1195,13 +1203,7 @@ mm_iface_modem_3gpp_update_access_technologies (MMIfaceModem3gpp *self,
 
     /* Even if registration state didn't change, report access technology,
      * but only if something valid to report */
-    if (state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED ||
-        ctx->reloading_registration_info) {
+    if (reg_state_is_registered (state) || ctx->reloading_registration_info) {
         if (access_tech != MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN)
             mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self),
                                                        access_tech,
@@ -1234,13 +1236,7 @@ mm_iface_modem_3gpp_update_location (MMIfaceModem3gpp *self,
      * location updates, but only if something valid to report. For the case
      * where we're registering (loading current registration info after a state
      * change to registered), we also allow LAC/CID updates. */
-    if (ctx->reloading_registration_info ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (state) || ctx->reloading_registration_info) {
         if (location_area_code > 0 && cell_id > 0)
             mm_iface_modem_location_3gpp_update_lac_ci (MM_IFACE_MODEM_LOCATION (self),
                                                         location_area_code,
@@ -1292,12 +1288,7 @@ update_non_registered_state (MMIfaceModem3gpp *self,
      * sent by the carrier during registration or b) by looking at the
      * registration reject error code.  If b), we want to make sure we
      * preserve the subscription state */
-    if (old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        old_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED)
+    if (reg_state_is_registered (old_state))
         clear_subscription_state (self);
 
     /* The property in the interface is bound to the property
@@ -1334,12 +1325,7 @@ update_registration_state (MMIfaceModem3gpp *self,
     if (new_state == old_state)
         return;
 
-    if (new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_SMS_ONLY ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
-        new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+    if (reg_state_is_registered (new_state)) {
         MMModemState modem_state;
 
         /* If already reloading registration info, skip it */
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to