modem: Identify modems by sysfs path instead of ofono dbus path
ofono dbus paths are non-deterministic and can change over time for a given modem. For instance when ofono is restartd or if a modem crashes and the object is destroyed and re-announced by udev. Requires at least ofono 1df92289d4e09a1e2db0b189b5153a4c238f98f1, which implemented the feature to export the sysfs path to modem properties. Related: OS#2509 Change-Id: Ibc45a196abadded2706dc9d57b6a3a796b43a201
This commit is contained in:
parent
b2a94e8430
commit
e25cf04aeb
|
@ -67,16 +67,16 @@ arfcn:
|
||||||
band: GSM-1900
|
band: GSM-1900
|
||||||
|
|
||||||
modem:
|
modem:
|
||||||
- label: sierra_1
|
- label: sierra_1st
|
||||||
path: '/sierra_1'
|
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.2'
|
||||||
imsi: '901700000009031'
|
imsi: '901700000009031'
|
||||||
ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
|
ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
|
||||||
auth_algo: 'comp128v1'
|
auth_algo: 'comp128v1'
|
||||||
ciphers: [a5_0, a5_1]
|
ciphers: [a5_0, a5_1]
|
||||||
features: ['sms', 'voice', 'ussd', 'gprs']
|
features: ['sms', 'voice', 'ussd', 'gprs']
|
||||||
|
|
||||||
- label: sierra_2
|
- label: sierra_2nd
|
||||||
path: '/sierra_2'
|
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.3'
|
||||||
imsi: '901700000009029'
|
imsi: '901700000009029'
|
||||||
ki: '00969E283349D354A8239E877F2E0866'
|
ki: '00969E283349D354A8239E877F2E0866'
|
||||||
auth_algo: 'comp128v1'
|
auth_algo: 'comp128v1'
|
||||||
|
@ -84,7 +84,7 @@ modem:
|
||||||
features: ['sms', 'voice', 'ussd', 'gprs']
|
features: ['sms', 'voice', 'ussd', 'gprs']
|
||||||
|
|
||||||
- label: ec20
|
- label: ec20
|
||||||
path: '/gobi_0'
|
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.6'
|
||||||
imsi: '901700000009030'
|
imsi: '901700000009030'
|
||||||
ki: 'BB70807226393CDBAC8DD3439FF54252'
|
ki: 'BB70807226393CDBAC8DD3439FF54252'
|
||||||
auth_algo: 'comp128v1'
|
auth_algo: 'comp128v1'
|
||||||
|
@ -92,7 +92,7 @@ modem:
|
||||||
features: ['sms', 'ussd', 'gprs']
|
features: ['sms', 'ussd', 'gprs']
|
||||||
|
|
||||||
- label: gobi2k
|
- label: gobi2k
|
||||||
path: '/gobi_3'
|
path: '/sys/devices/pci0000:00/0000:00:12.2/usb1/1-1/1-1.5'
|
||||||
imsi: '901700000009032'
|
imsi: '901700000009032'
|
||||||
ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
|
ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
|
||||||
auth_algo: 'comp128v1'
|
auth_algo: 'comp128v1'
|
||||||
|
|
|
@ -92,6 +92,14 @@ def list_modems():
|
||||||
root = systembus_get('/')
|
root = systembus_get('/')
|
||||||
return sorted(root.GetModems())
|
return sorted(root.GetModems())
|
||||||
|
|
||||||
|
def get_dbuspath_from_syspath(syspath):
|
||||||
|
modems = list_modems()
|
||||||
|
for dbuspath, props in modems:
|
||||||
|
if props.get('SystemPath', '') == syspath:
|
||||||
|
return dbuspath
|
||||||
|
raise ValueError('could not find %s in modem list: %s' % (syspath, modems))
|
||||||
|
|
||||||
|
|
||||||
def _async_result_handler(obj, result, user_data):
|
def _async_result_handler(obj, result, user_data):
|
||||||
'''Generic callback dispatcher called from glib loop when an async method
|
'''Generic callback dispatcher called from glib loop when an async method
|
||||||
call has returned. This callback is set up by method dbus_async_call.'''
|
call has returned. This callback is set up by method dbus_async_call.'''
|
||||||
|
@ -341,10 +349,12 @@ class Modem(log.Origin):
|
||||||
|
|
||||||
def __init__(self, conf):
|
def __init__(self, conf):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.path = conf.get('path')
|
self.syspath = conf.get('path')
|
||||||
super().__init__(log.C_TST, self.path)
|
self.dbuspath = get_dbuspath_from_syspath(self.syspath)
|
||||||
|
super().__init__(log.C_TST, self.dbuspath)
|
||||||
|
self.dbg('creating from syspath %s', self.syspath)
|
||||||
self.sms_received_list = []
|
self.sms_received_list = []
|
||||||
self.dbus = ModemDbusInteraction(self.path)
|
self.dbus = ModemDbusInteraction(self.dbuspath)
|
||||||
self.register_attempts = 0
|
self.register_attempts = 0
|
||||||
self.call_list = []
|
self.call_list = []
|
||||||
# one Cancellable can handle several concurrent methods.
|
# one Cancellable can handle several concurrent methods.
|
||||||
|
|
Loading…
Reference in New Issue