modem: get IMSI from ofono
There's no need to specify the IMSI manually in resource config and it's also prone to errors. Let's take it from ofono. Add a 'sim' feature to allow modem to auto-discover it, otherwise if not supported leave that feature out of the config for that modem and an imsi can still be manually providen. Change-Id: I20f9e8d97775293925205e4ea576d814214bf1a8
This commit is contained in:
parent
e5a7a40faa
commit
bfd0b2310c
|
@ -69,32 +69,28 @@ arfcn:
|
|||
modem:
|
||||
- label: sierra_1st
|
||||
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.2'
|
||||
imsi: '901700000009031'
|
||||
ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
|
||||
auth_algo: 'comp128v1'
|
||||
ciphers: [a5_0, a5_1]
|
||||
features: ['sms', 'voice', 'ussd', 'gprs']
|
||||
features: ['sms', 'voice', 'ussd', 'gprs', 'sim']
|
||||
|
||||
- label: sierra_2nd
|
||||
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3'
|
||||
imsi: '901700000009029'
|
||||
ki: '00969E283349D354A8239E877F2E0866'
|
||||
auth_algo: 'comp128v1'
|
||||
ciphers: [a5_0, a5_1]
|
||||
features: ['sms', 'voice', 'ussd', 'gprs']
|
||||
features: ['sms', 'voice', 'ussd', 'gprs', 'sim']
|
||||
|
||||
- label: ec20
|
||||
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.6'
|
||||
imsi: '901700000009030'
|
||||
ki: 'BB70807226393CDBAC8DD3439FF54252'
|
||||
auth_algo: 'comp128v1'
|
||||
ciphers: [a5_0, a5_1]
|
||||
features: ['sms', 'ussd', 'gprs']
|
||||
features: ['sms', 'ussd', 'gprs', 'sim']
|
||||
|
||||
- label: gobi2k
|
||||
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.5'
|
||||
imsi: '901700000009032'
|
||||
ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
|
||||
auth_algo: 'comp128v1'
|
||||
ciphers: [a5_0, a5_1]
|
||||
features: ['gprs']
|
||||
features: ['gprs', 'sim']
|
||||
|
|
|
@ -41,6 +41,7 @@ I_CONNMGR = 'org.ofono.ConnectionManager'
|
|||
I_CALLMGR = 'org.ofono.VoiceCallManager'
|
||||
I_CALL = 'org.ofono.VoiceCall'
|
||||
I_SS = 'org.ofono.SupplementaryServices'
|
||||
I_SIMMGR = 'org.ofono.SimManager'
|
||||
|
||||
# See https://github.com/intgr/ofono/blob/master/doc/network-api.txt#L78
|
||||
NETREG_ST_REGISTERED = 'registered'
|
||||
|
@ -342,6 +343,7 @@ class Modem(log.Origin):
|
|||
msisdn = None
|
||||
sms_received_list = None
|
||||
_ki = None
|
||||
_imsi = None
|
||||
|
||||
CTX_PROT_IPv4 = 'ip'
|
||||
CTX_PROT_IPv6 = 'ipv6'
|
||||
|
@ -423,10 +425,23 @@ class Modem(log.Origin):
|
|||
self.msisdn = msisdn
|
||||
|
||||
def imsi(self):
|
||||
imsi = self.conf.get('imsi')
|
||||
if not imsi:
|
||||
raise log.Error('No IMSI')
|
||||
return imsi
|
||||
if self._imsi is None:
|
||||
if 'sim' in self.features():
|
||||
if not self.is_powered():
|
||||
self.set_powered()
|
||||
# wait for SimManager iface to appear after we power on
|
||||
event_loop.wait(self, self.dbus.has_interface, I_SIMMGR, timeout=10)
|
||||
simmgr = self.dbus.interface(I_SIMMGR)
|
||||
# If properties are requested quickly, it may happen that Sim property is still not there.
|
||||
event_loop.wait(self, lambda: simmgr.GetProperties().get('SubscriberIdentity', None) is not None, timeout=10)
|
||||
props = simmgr.GetProperties()
|
||||
self.dbg('got SIM properties', props)
|
||||
self._imsi = props.get('SubscriberIdentity', None)
|
||||
else:
|
||||
self._imsi = self.conf.get('imsi')
|
||||
if self._imsi is None:
|
||||
raise log.Error('No IMSI')
|
||||
return self._imsi
|
||||
|
||||
def set_ki(self, ki):
|
||||
self._ki = ki
|
||||
|
@ -447,6 +462,7 @@ class Modem(log.Origin):
|
|||
req_ifaces += (I_SMS,) if 'sms' in self.features() else ()
|
||||
req_ifaces += (I_SS,) if 'ussd' in self.features() else ()
|
||||
req_ifaces += (I_CONNMGR,) if 'gprs' in self.features() else ()
|
||||
req_ifaces += (I_SIMMGR,) if 'sim' in self.features() else ()
|
||||
return req_ifaces
|
||||
|
||||
def _on_netreg_property_changed(self, name, value):
|
||||
|
|
|
@ -95,7 +95,7 @@ def cipher(val):
|
|||
raise ValueError('Unknown Cipher value: %r' % val)
|
||||
|
||||
def modem_feature(val):
|
||||
if val in ('sms', 'gprs', 'voice', 'ussd'):
|
||||
if val in ('sms', 'gprs', 'voice', 'ussd', 'sim'):
|
||||
return
|
||||
raise ValueError('Unknown Modem Feature: %r' % val)
|
||||
|
||||
|
|
Loading…
Reference in New Issue