aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-06-13 16:23:23 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-13 14:37:57 +0000
commit4d63d920333c23996b4a2773aa7c363812971b37 (patch)
tree05547644d1928824f9d54988fa955462458c076a
parente4cd7910a544019f6c01ae8a8b5a26e6c85a361e (diff)
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
-rw-r--r--src/osmo_gsm_tester/ofono_client.py14
1 files changed, 13 insertions, 1 deletions
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 @@ class Modem(log.Origin):
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 @@ class Modem(log.Origin):
# 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: