receiver: handle more device connection protocols
This commit is contained in:
parent
37d6cab569
commit
7873f3e8d0
|
@ -186,7 +186,7 @@ def _process_hidpp10_custom_notification(device, status, n):
|
||||||
|
|
||||||
|
|
||||||
def _process_hidpp10_notification(device, status, n):
|
def _process_hidpp10_notification(device, status, n):
|
||||||
# unpair notification
|
# device unpairing
|
||||||
if n.sub_id == 0x40:
|
if n.sub_id == 0x40:
|
||||||
if n.address == 0x02:
|
if n.address == 0x02:
|
||||||
# device un-paired
|
# device un-paired
|
||||||
|
@ -200,37 +200,29 @@ def _process_hidpp10_notification(device, status, n):
|
||||||
_log.warn('%s: disconnection with unknown type %02X: %s', device, n.address, n)
|
_log.warn('%s: disconnection with unknown type %02X: %s', device, n.address, n)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# wireless link notification
|
# device connection (and disconnection)
|
||||||
if n.sub_id == 0x41:
|
if n.sub_id == 0x41:
|
||||||
protocol_name = (
|
flags = ord(n.data[:1]) & 0xF0
|
||||||
'Bluetooth' if n.address == 0x01 else '27 MHz' if n.address == 0x02 else
|
if n.address == 0x02: # very old 27 MHz protocol
|
||||||
'QUAD or eQUAD' if n.address == 0x03 else 'eQUAD step 4 DJ' if n.address == 0x04 else 'DFU Lite' if n.address ==
|
wpid = '00' + _strhex(n.data[2:3])
|
||||||
0x05 else 'eQUAD step 4 Lite' if n.address == 0x06 else 'eQUAD step 4 Gaming' if n.address ==
|
link_established = True
|
||||||
0x07 else 'eQUAD step 4 for gamepads' if n.address == 0x08 else 'eQUAD nano Lite' if n.address ==
|
link_encrypted = bool(flags & 0x80)
|
||||||
0x0A else 'Lightspeed 1' if n.address == 0x0C else 'Lightspeed 1_1' if n.address == 0x0D else None
|
elif n.address > 0x00: # all other protocols are supposed to be almost the same
|
||||||
)
|
|
||||||
if protocol_name:
|
|
||||||
wpid = _strhex(n.data[2:3] + n.data[1:2])
|
wpid = _strhex(n.data[2:3] + n.data[1:2])
|
||||||
# workaround for short EX100 and other 27 MHz wpids
|
|
||||||
if protocol_name == '27 MHz':
|
|
||||||
wpid = '00' + _strhex(n.data[2:3])
|
|
||||||
if wpid != device.wpid:
|
|
||||||
_log.warn('%s wpid mismatch, got %s', device, wpid)
|
|
||||||
flags = ord(n.data[:1]) & 0xF0
|
|
||||||
link_encrypted = bool(flags & 0x20)
|
|
||||||
link_established = not (flags & 0x40)
|
link_established = not (flags & 0x40)
|
||||||
if _log.isEnabledFor(_DEBUG):
|
link_encrypted = bool(flags & 0x20)
|
||||||
sw_present = bool(flags & 0x10)
|
|
||||||
has_payload = bool(flags & 0x80)
|
|
||||||
_log.debug(
|
|
||||||
'%s: %s connection notification: software=%s, encrypted=%s, link=%s, payload=%s', device, protocol_name,
|
|
||||||
sw_present, link_encrypted, link_established, has_payload
|
|
||||||
)
|
|
||||||
status[_K.LINK_ENCRYPTED] = link_encrypted
|
|
||||||
status.changed(active=link_established)
|
|
||||||
else:
|
else:
|
||||||
_log.warn('%s: connection notification with unknown protocol %02X: %s', device.number, n.address, n)
|
_log.warn('%s: connection notification with unknown protocol %02X: %s', device.number, n.address, n)
|
||||||
|
return True
|
||||||
|
if wpid != device.wpid:
|
||||||
|
_log.warn('%s wpid mismatch, got %s', device, wpid)
|
||||||
|
if _log.isEnabledFor(_DEBUG):
|
||||||
|
_log.debug(
|
||||||
|
'%s: protocol %s connection notification: software=%s, encrypted=%s, link=%s, payload=%s', device, n.address,
|
||||||
|
bool(flags & 0x10), link_encrypted, link_established, bool(flags & 0x80)
|
||||||
|
)
|
||||||
|
status[_K.LINK_ENCRYPTED] = link_encrypted
|
||||||
|
status.changed(active=link_established)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if n.sub_id == 0x49:
|
if n.sub_id == 0x49:
|
||||||
|
|
Loading…
Reference in New Issue