improved notifications detection
This commit is contained in:
parent
4bdfe9b9b8
commit
80c36a02a9
|
@ -74,8 +74,9 @@ def _find_device(receiver, name):
|
||||||
|
|
||||||
|
|
||||||
def _print_receiver(receiver, verbose=False):
|
def _print_receiver(receiver, verbose=False):
|
||||||
|
paired_count = receiver.count()
|
||||||
if not verbose:
|
if not verbose:
|
||||||
print ("-: Unifying Receiver [%s:%s] with %d devices" % (receiver.path, receiver.serial, receiver.count()))
|
print ("-: Unifying Receiver [%s:%s] with %d devices" % (receiver.path, receiver.serial, paired_count))
|
||||||
return
|
return
|
||||||
|
|
||||||
print ("-: Unifying Receiver")
|
print ("-: Unifying Receiver")
|
||||||
|
@ -84,21 +85,22 @@ def _print_receiver(receiver, verbose=False):
|
||||||
for f in receiver.firmware:
|
for f in receiver.firmware:
|
||||||
print (" %-11s: %s" % (f.kind, f.version))
|
print (" %-11s: %s" % (f.kind, f.version))
|
||||||
|
|
||||||
print (" Has %d paired device(s)." % receiver.count())
|
print (" Has %d paired device(s)." % paired_count)
|
||||||
|
|
||||||
notifications = receiver.request(0x8100)
|
notifications = receiver.request(0x8100)
|
||||||
if notifications:
|
if notifications:
|
||||||
notifications = ord(notifications[0:1]) << 16 | ord(notifications[1:2]) << 8
|
notifications = ord(notifications[0:1]) << 16 | ord(notifications[1:2]) << 8
|
||||||
if notifications:
|
if notifications:
|
||||||
from logitech.unifying_receiver import hidpp10
|
from logitech.unifying_receiver import hidpp10
|
||||||
print (" Enabled notifications: %s." % hidpp10.NOTIFICATION_FLAG.flag_names(notifications))
|
print (" Enabled notifications: %06X = %s." % (notifications, ', '.join(hidpp10.NOTIFICATION_FLAG.flag_names(notifications))))
|
||||||
else:
|
else:
|
||||||
print (" All notifications disabled.")
|
print (" All notifications disabled.")
|
||||||
|
|
||||||
activity = receiver.request(0x83B3)
|
if paired_count > 0:
|
||||||
if activity:
|
activity = receiver.request(0x83B3)
|
||||||
activity = [(d, ord(activity[d - 1:d])) for d in range(1, receiver.max_devices)]
|
if activity:
|
||||||
print(" Device activity counters: %s" % ', '.join(('%d=%d' % (d, a)) for d, a in activity if a > 0))
|
activity = [(d, ord(activity[d - 1:d])) for d in range(1, receiver.max_devices)]
|
||||||
|
print(" Device activity counters: %s" % ', '.join(('%d=%d' % (d, a)) for d, a in activity if a > 0))
|
||||||
|
|
||||||
|
|
||||||
def _print_device(dev, verbose=False):
|
def _print_device(dev, verbose=False):
|
||||||
|
|
|
@ -83,7 +83,15 @@ class NamedInts(object):
|
||||||
self._fallback = None
|
self._fallback = None
|
||||||
|
|
||||||
def flag_names(self, value):
|
def flag_names(self, value):
|
||||||
return ', '.join(str(self._indexed[k]) for k in self._indexed if k & value == k)
|
unknown_bits = value
|
||||||
|
for k in self._indexed:
|
||||||
|
assert bin(k).count('1') == 1
|
||||||
|
if k & value == k:
|
||||||
|
unknown_bits &= ~k
|
||||||
|
yield str(self._indexed[k])
|
||||||
|
|
||||||
|
if unknown_bits:
|
||||||
|
yield 'unknown:%06X' % unknown_bits
|
||||||
|
|
||||||
def index(self, value):
|
def index(self, value):
|
||||||
if value in self._values:
|
if value in self._values:
|
||||||
|
|
|
@ -36,9 +36,9 @@ POWER_SWITCH_LOCATION = _NamedInts(
|
||||||
bottom_edge=0x0C)
|
bottom_edge=0x0C)
|
||||||
|
|
||||||
NOTIFICATION_FLAG = _NamedInts(
|
NOTIFICATION_FLAG = _NamedInts(
|
||||||
battery_status=0x00100000,
|
battery_status=0x100000,
|
||||||
wireless=0x00000100,
|
wireless=0x000100,
|
||||||
software_present=0x000000800)
|
software_present=0x0000800)
|
||||||
|
|
||||||
ERROR = _NamedInts(
|
ERROR = _NamedInts(
|
||||||
invalid_SubID__command=0x01,
|
invalid_SubID__command=0x01,
|
||||||
|
|
Loading…
Reference in New Issue