[PATCH] osmo-gsm-tester[master]: ofono_client: Implement network registration during connect()

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.org
Fri Apr 28 12:56:47 UTC 2017


Review at  https://gerrit.osmocom.org/2449

ofono_client: Implement network registration during connect()

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


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/49/2449/1

diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py
index a10784f..974746c 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -113,12 +113,29 @@
         self.dbg('Interface enabled:', interface_name)
         if interface_name == I_SMS:
             self.dbus_obj()[I_SMS].IncomingMessage.connect(self._on_incoming_message)
+        if interface_name == I_NETREG:
+            self.dbus_obj()[I_NETREG].PropertyChanged.connect(self._on_netreg_property_changed)
 
     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):
+        nr = self.dbus_obj()[I_NETREG]
+        return nr.GetProperties().get('Status')
+
+    def is_roaming(self):
+        status = self.get_netreg_status()
+        return status == 'roaming'
+
+    def is_connected(self):
+        status = self.get_netreg_status()
+        return status == 'registered' or status == 'roaming'
 
     def connect(self, nitb):
         'set the modem up to connect to MCC+MNC from NITB config'
@@ -127,7 +144,17 @@
         if not self.has_interface(I_NETREG):
             self.log('No %r interface, hoping that the modem connects by itself' % I_NETREG)
         else:
-            self.log('Use of %r interface not implemented yet, hoping that the modem connects by itself' % I_NETREG)
+            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.get_netreg_status())
+            else:
+                raise Exception('Failed to register with the network, current status is %s' % self.get_netreg_status())
+
 
     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: newchange
Gerrit-Change-Id: I1db8c7cba8a83746c16e1ca45f4b8aa0d595caf8
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list