receiver notifications: don't set all flags, might fail
This commit is contained in:
parent
ad67e6eaee
commit
b2b4febd31
|
@ -14,7 +14,7 @@ del getLogger
|
||||||
from . import base as _base
|
from . import base as _base
|
||||||
from . import hidpp10 as _hidpp10
|
from . import hidpp10 as _hidpp10
|
||||||
from . import hidpp20 as _hidpp20
|
from . import hidpp20 as _hidpp20
|
||||||
from .common import strhex as _strhex, NamedInts as _NamedInts
|
from .common import strhex as _strhex
|
||||||
from . import descriptors as _descriptors
|
from . import descriptors as _descriptors
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -50,6 +50,10 @@ class PairedDevice(object):
|
||||||
kind = ord(pair_info[7:8]) & 0x0F
|
kind = ord(pair_info[7:8]) & 0x0F
|
||||||
self._kind = _hidpp10.DEVICE_KIND[kind]
|
self._kind = _hidpp10.DEVICE_KIND[kind]
|
||||||
self.polling_rate = ord(pair_info[2:3])
|
self.polling_rate = ord(pair_info[2:3])
|
||||||
|
else:
|
||||||
|
# no device at this address...
|
||||||
|
return
|
||||||
|
|
||||||
# else:
|
# else:
|
||||||
# # guesswork...
|
# # guesswork...
|
||||||
# descriptor = _descriptors.DEVICES.get(self.receiver.product_id)
|
# descriptor = _descriptors.DEVICES.get(self.receiver.product_id)
|
||||||
|
@ -251,6 +255,7 @@ class Receiver(object):
|
||||||
|
|
||||||
old_equad_reply = self.request(0x83B5, 0x04)
|
old_equad_reply = self.request(0x83B5, 0x04)
|
||||||
self.unifying_supported = old_equad_reply is None
|
self.unifying_supported = old_equad_reply is None
|
||||||
|
_log.info("%s (%s) uses protocol %s", self.name, self.path, 'eQuad' if old_equad_reply else 'eQuad DJ')
|
||||||
|
|
||||||
self._firmware = None
|
self._firmware = None
|
||||||
self._devices = {}
|
self._devices = {}
|
||||||
|
@ -275,18 +280,22 @@ class Receiver(object):
|
||||||
if not self.handle:
|
if not self.handle:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# flag_bits = _hidpp10.NOTIFICATION_FLAG.all_bits() if enable else 0
|
if enable:
|
||||||
flag_bits = 0xFFFFFF if enable else 0
|
set_flag_bits = ( _hidpp10.NOTIFICATION_FLAG.battery_status
|
||||||
ok = _hidpp10.set_notification_flags(self, flag_bits)
|
+ _hidpp10.NOTIFICATION_FLAG.wireless
|
||||||
|
+ _hidpp10.NOTIFICATION_FLAG.software_present )
|
||||||
|
else:
|
||||||
|
set_flag_bits = 0
|
||||||
|
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
|
||||||
|
|
||||||
flag_bits = _hidpp10.get_notification_flags(self)
|
flag_bits = _hidpp10.get_notification_flags(self)
|
||||||
if flag_bits is not None:
|
if flag_bits is not None:
|
||||||
flag_bits = tuple(_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
|
flag_bits = tuple(_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
_log.info("%s: device notifications %s %s", self, 'enabled' if enable else 'disabled', flag_bits)
|
_log.info("%s: receiver notifications %s => %s", self, 'enabled' if enable else 'disabled', flag_bits)
|
||||||
else:
|
else:
|
||||||
_log.warn("%s: failed to %s device notifications %s", self, 'enable' if enable else 'disable', flag_bits)
|
_log.warn("%s: failed to %s receiver notifications %s", self, 'enable' if enable else 'disable', flag_bits)
|
||||||
return ok
|
return ok
|
||||||
|
|
||||||
def notify_devices(self):
|
def notify_devices(self):
|
||||||
|
@ -301,10 +310,11 @@ class Receiver(object):
|
||||||
|
|
||||||
dev = PairedDevice(self, number)
|
dev = PairedDevice(self, number)
|
||||||
if dev.wpid:
|
if dev.wpid:
|
||||||
_log.info("%s: found device %d (%s)", self, number, dev.wpid)
|
_log.info("%s: found new device %d (%s)", self, number, dev.wpid)
|
||||||
self._devices[number] = dev
|
self._devices[number] = dev
|
||||||
return dev
|
return dev
|
||||||
|
|
||||||
|
_log.warning("%s: looked for device %d, not found", self, number)
|
||||||
self._devices[number] = None
|
self._devices[number] = None
|
||||||
|
|
||||||
def set_lock(self, lock_closed=True, device=0, timeout=0):
|
def set_lock(self, lock_closed=True, device=0, timeout=0):
|
||||||
|
@ -319,6 +329,9 @@ class Receiver(object):
|
||||||
count = self.request(0x8102)
|
count = self.request(0x8102)
|
||||||
return 0 if count is None else ord(count[1:2])
|
return 0 if count is None else ord(count[1:2])
|
||||||
|
|
||||||
|
# def has_devices(self):
|
||||||
|
# return len(self) > 0 or self.count() > 0
|
||||||
|
|
||||||
def request(self, request_id, *params):
|
def request(self, request_id, *params):
|
||||||
if self.handle:
|
if self.handle:
|
||||||
return _base.request(self.handle, 0xFF, request_id, *params)
|
return _base.request(self.handle, 0xFF, request_id, *params)
|
||||||
|
|
|
@ -62,15 +62,9 @@ class ReceiverListener(_listener.EventsListener):
|
||||||
r.status = 'The receiver was unplugged.'
|
r.status = 'The receiver was unplugged.'
|
||||||
if r:
|
if r:
|
||||||
try:
|
try:
|
||||||
pass
|
r.close()
|
||||||
# r.enable_notifications(False)
|
|
||||||
except:
|
except:
|
||||||
_log.exception("disabling notifications on receiver %s" % r)
|
_log.exception("closing receiver %s" % r.path)
|
||||||
finally:
|
|
||||||
try:
|
|
||||||
r.close()
|
|
||||||
except:
|
|
||||||
_log.exception("closing receiver %s" % r.path)
|
|
||||||
self.status_changed_callback(r) #, _status.ALERT.NOTIFICATION)
|
self.status_changed_callback(r) #, _status.ALERT.NOTIFICATION)
|
||||||
|
|
||||||
# configuration.save()
|
# configuration.save()
|
||||||
|
|
Loading…
Reference in New Issue