From 0e57aadd280ec40bd3b8754f6169fc507b1b25bf Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 29 May 2017 14:25:22 +0200 Subject: ofono_client: Implement network registration during connect() A new mcc_mnc parameter is now optionally passed to connect() in order to manually register to a specific network with a given MCC+MNC pair. If no parameter is passed (or None), then the modem will be instructed to attempt an automatic registration with any available network which permits it. We get the MCC+MNC parameter from the MSC/NITB and we pass it to the modem object at connect time as shown in the modified tests. Two new simple tests to check network registration is working are added in this commit. Ofono modems seem to be automatically registering at some point after they are set Online=true, and we were actually using that 'feature' before this patch. Thus, it is possible that a modem quickly becomes registered, and we then check so before starting the scan+registration process, which can take a few seconds. The scanning method can take a few seconds to complete. To avoid blocking in the dbus ofono Scan() method, this commit adds some code to make use of glib/gdbus async methods, which are not yet supported directly by pydbus. This way, we can continue polling while waiting for the scan process to complete and we can register several modems in parallel. When scan completes, a callback is run which attempts to register. If no MCC+MNC was passed, as we just finished scanning the modem should have enough fresh operator information to take good and quick decisions on where to connect. If we have an MCC+MNC, then we check the operator list received by Scan() method. If operator with desired MCC+MNC is there, we register with it. If it's not there, we start scanning() again asynchronously hoping the operator will show up in next scan. As scanning() and registration is done in the background, tests are expected to call connect(), and then later on wait for the modem to register by waiting/polling the method "modem.is_connected()". Tests first check for the modem being connected and after with MSC subscriber_attached(). The order is intentional because the later has to poll through network and adds unneeded garbage to the pcap files bein recorded. Change-Id: I8d9eb47eac1044550d3885adb55105c304b0c15c --- src/osmo_gsm_tester/osmo_nitb.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/osmo_gsm_tester/osmo_nitb.py') diff --git a/src/osmo_gsm_tester/osmo_nitb.py b/src/osmo_gsm_tester/osmo_nitb.py index b2ddfb7..b4bf247 100644 --- a/src/osmo_gsm_tester/osmo_nitb.py +++ b/src/osmo_gsm_tester/osmo_nitb.py @@ -76,6 +76,7 @@ class OsmoNitb(log.Origin): for bts in self.bts: bts_list.append(bts.conf_for_bsc()) config.overlay(values, dict(nitb=dict(net=dict(bts_list=bts_list)))) + self.config = values self.dbg('NITB CONFIG:\n' + pprint.pformat(values)) @@ -91,6 +92,15 @@ class OsmoNitb(log.Origin): self.bts.append(bts) bts.set_bsc(self) + def mcc(self): + return self.config['nitb']['net']['mcc'] + + def mnc(self): + return self.config['nitb']['net']['mnc'] + + def mcc_mnc(self): + return (self.mcc(), self.mnc()) + def subscriber_add(self, modem, msisdn=None): if msisdn is None: msisdn = self.suite_run.resources_pool.next_msisdn(modem) -- cgit v1.2.3