device: get extended pairing information early and allow for unknown WPID
This commit is contained in:
parent
2fbaa4a3aa
commit
ca13e06519
|
@ -119,13 +119,14 @@ class Device:
|
||||||
kind = self.get_kind_from_index(number, receiver)
|
kind = self.get_kind_from_index(number, receiver)
|
||||||
self._kind = _hidpp10.DEVICE_KIND[kind]
|
self._kind = _hidpp10.DEVICE_KIND[kind]
|
||||||
else:
|
else:
|
||||||
# Not a notification, force a reading of the wpid
|
# Not a notification, force a reading of pairing information
|
||||||
self.online = True
|
self.online = True
|
||||||
self.update_pairing_information()
|
self.update_pairing_information()
|
||||||
|
self.update_extended_pairing_information()
|
||||||
|
if not self.wpid and not self._serial: # if neither then the device almost certainly wasn't found
|
||||||
|
raise _base.NoSuchDevice(number=number, receiver=receiver, error='no wpid or serial')
|
||||||
|
|
||||||
# the wpid is necessary to properly identify wireless link on/off
|
# the wpid is set to None on this object when the device is unpaired
|
||||||
# notifications also it gets set to None on this object when the
|
|
||||||
# device is unpaired
|
|
||||||
assert self.wpid is not None, 'failed to read wpid: device %d of %s' % (number, receiver)
|
assert self.wpid is not None, 'failed to read wpid: device %d of %s' % (number, receiver)
|
||||||
|
|
||||||
self.descriptor = _descriptors.get_wpid(self.wpid)
|
self.descriptor = _descriptors.get_wpid(self.wpid)
|
||||||
|
|
|
@ -193,6 +193,7 @@ class Receiver:
|
||||||
return wpid, kind, polling_rate
|
return wpid, kind, polling_rate
|
||||||
|
|
||||||
def device_extended_pairing_information(self, n):
|
def device_extended_pairing_information(self, n):
|
||||||
|
serial = None
|
||||||
power_switch = '(unknown)'
|
power_switch = '(unknown)'
|
||||||
if self.receiver_kind == 'bolt':
|
if self.receiver_kind == 'bolt':
|
||||||
pair_info = self.read_register(_R.receiver_info, _IR.bolt_pairing_information + n)
|
pair_info = self.read_register(_R.receiver_info, _IR.bolt_pairing_information + n)
|
||||||
|
@ -208,8 +209,6 @@ class Receiver:
|
||||||
pair_info = self.read_register(0x2D5)
|
pair_info = self.read_register(0x2D5)
|
||||||
if pair_info:
|
if pair_info:
|
||||||
serial = _strhex(pair_info[1:5])
|
serial = _strhex(pair_info[1:5])
|
||||||
else: # fallback...
|
|
||||||
serial = self.serial
|
|
||||||
return serial, power_switch
|
return serial, power_switch
|
||||||
|
|
||||||
def get_kind_from_index(self, index):
|
def get_kind_from_index(self, index):
|
||||||
|
|
Loading…
Reference in New Issue