[MERGED] osmo-gsm-tester[master]: ofono_client: gracefully handle Scan() failure

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Jun 13 14:38:29 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: ofono_client: gracefully handle Scan() failure
......................................................................


ofono_client: gracefully handle Scan() failure

ofono's NetworkRegistration.Scan() method fails sporadically. On failure,
check if we are now registered to the desired network, and schedule another
scan otherwise.

For instance it fails with org.ofono.Error.Failed if the modem starts to
register internally after we started Scan() and the registering succeeds
while we are still waiting for Scan() to finsih.

Change-Id: I4a2265ee39a94daa00f525b1c7037a6775509425
---
M src/osmo_gsm_tester/ofono_client.py
1 file changed, 13 insertions(+), 1 deletion(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py
index 67659e1..138f7df 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -385,6 +385,7 @@
         netreg = self.dbus.interface(I_NETREG)
         prop = netreg.GetProperties()
         status = prop.get('Status')
+        self.dbg('status:', status)
         if not (status == NETREG_ST_REGISTERED or status == NETREG_ST_ROAMING):
             return False
         if mcc_mnc is None: # Any network is fine and we are registered.
@@ -406,10 +407,21 @@
         # finished.
         register_func = self.scan_cb_register_automatic if mcc_mnc is None else self.scan_cb_register
         result_handler = lambda obj, result, user_data: defer(register_func, result, user_data)
-        error_handler = lambda obj, e, user_data: defer(self.raise_exn, 'Scan() failed:', e)
+        error_handler = lambda obj, e, user_data: defer(self.scan_cb_error_handler, e, mcc_mnc)
         dbus_async_call(netreg, netreg.Scan, timeout=30, result_handler=result_handler,
                         error_handler=error_handler, user_data=mcc_mnc)
 
+    def scan_cb_error_handler(self, e, mcc_mnc):
+        # It was detected that Scan() method can fail for some modems on some
+        # specific circumstances. For instance it fails with org.ofono.Error.Failed
+        # if the modem starts to register internally after we started Scan() and
+        # the registering succeeds while we are still waiting for Scan() to finsih.
+        # So far the easiest seems to check if we are now registered and
+        # otherwise schedule a scan again.
+        self.err('Scan() failed:', e)
+        if not self.is_connected(mcc_mnc):
+            self.schedule_scan_register(mcc_mnc)
+
     def scan_cb_register_automatic(self, scanned_operators, mcc_mnc):
         self.dbg('scanned operators: ', scanned_operators);
         for op_path, op_prop in scanned_operators:

-- 
To view, visit https://gerrit.osmocom.org/2902
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a2265ee39a94daa00f525b1c7037a6775509425
Gerrit-PatchSet: 2
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list