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/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgHello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/2449 to look at the new patch set (#4). ofono_client: Implement network registration during connect() Change-Id: I1db8c7cba8a83746c16e1ca45f4b8aa0d595caf8 --- M src/osmo_gsm_tester/ofono_client.py 1 file changed, 48 insertions(+), 3 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/49/2449/4 diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py index 6285c56..1a2c171 100644 --- a/src/osmo_gsm_tester/ofono_client.py +++ b/src/osmo_gsm_tester/ofono_client.py @@ -32,6 +32,10 @@ I_NETREG = 'org.ofono.NetworkRegistration' I_SMS = 'org.ofono.MessageManager' +# See https://github.com/intgr/ofono/blob/master/doc/network-api.txt#L78 +ST_REGISTERED = 'registered' +ST_ROAMING = 'roaming' + def poll(): global glib_main_ctx while glib_main_ctx.pending(): @@ -59,6 +63,8 @@ self._dbus_obj = None self._interfaces = set() self.sms_received_list = [] + self.netreg_status = None + self.nitb = None # init interfaces and connect to signals: self.dbus_obj() test.poll() @@ -145,12 +151,49 @@ if retries <= 0: self.err('Interface enabled by signal, but not available:', I_SMS) raise + elif interface_name == I_NETREG: + self.dbus_obj()[I_NETREG].PropertyChanged.connect(self._on_netreg_property_changed) + self.register(self.nitb) def _on_interface_disabled(self, interface_name): self.dbg('Interface disabled:', interface_name) def has_interface(self, name): return name in self._interfaces + + def _on_netreg_property_changed(self, name, value): + self.log('%r.PropertyChanged() -> %s=%s' % (I_NETREG, name, value)) + + def get_netreg_status(self): + try: + nr = self.dbus_obj()[I_NETREG] + self.netreg_status = nr.GetProperties().get('Status') + except Exception: + self.netreg_status = None + return False + + def is_roaming(self): + status = self.get_netreg_status() + return status == ST_ROAMING + + def is_connected(self): + status = self.get_netreg_status() + return status == ST_REGISTERED or status == ST_ROAMING + + def register(self, nitb): + if nitb == None: + return #connect() was not called yet + self.log('Registering with the network...', nitb) + if self.is_connected(): + self.log('Already registered with the network') + return + nr = self.dbus_obj()[I_NETREG] + nr.Scan() + nr.Register() + if self.is_connected(): + self.dbg('Registered with network successfully: current status is %s', self.netreg_status) + else: + raise RuntimeError('Failed to register with the network, current status is %s' % self.netreg_status) def connect(self, nitb): 'set the modem up to connect to MCC+MNC from NITB config' @@ -159,10 +202,12 @@ self.set_powered(False) self.set_powered() self.set_online() - if not self.has_interface(I_NETREG): - self.log('No %r interface, hoping that the modem connects by itself' % I_NETREG) + self.nitb = nitb + if self.has_interface(I_NETREG): + self.register(nitb) else: - self.log('Use of %r interface not implemented yet, hoping that the modem connects by itself' % I_NETREG) + self.log('No %r interface, delaying registration until it appears' % I_NETREG) + def sms_send(self, to_msisdn): if hasattr(to_msisdn, 'msisdn'): -- To view, visit https://gerrit.osmocom.org/2449 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I1db8c7cba8a83746c16e1ca45f4b8aa0d595caf8 Gerrit-PatchSet: 4 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> Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>