tweaked timing of enabling receiver notifications

This commit is contained in:
Daniel Pavel 2013-06-21 15:20:52 +02:00
parent f9c192c47a
commit c1aa341a7a
3 changed files with 12 additions and 14 deletions

View File

@ -241,14 +241,12 @@ class PairedDevice(object):
else:
set_flag_bits = 0
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
if ok is None:
_log.warn("%s: failed to %s device notifications", self, 'enable' if enable else 'disable')
flag_bits = _hidpp10.get_notification_flags(self)
flag_names = None if flag_bits is None else tuple(_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
if ok:
_log.info("%s: device notifications %s %s", self, 'enabled' if enable else 'disabled', flag_names)
else:
_log.warn("%s: failed to %s device notifications %s", self, 'enable' if enable else 'disable', flag_names)
_log.info("%s: device notifications %s %s", self, 'enabled' if enable else 'disabled', flag_names)
return flag_bits if ok else None
def request(self, request_id, *params):
@ -355,15 +353,14 @@ class Receiver(object):
else:
set_flag_bits = 0
ok = _hidpp10.set_notification_flags(self, set_flag_bits)
if ok is None:
_log.warn("%s: failed to %s receiver notifications", self, 'enable' if enable else 'disable')
return None
flag_bits = _hidpp10.get_notification_flags(self)
flag_names = None if flag_bits is None else tuple(_hidpp10.NOTIFICATION_FLAG.flag_names(flag_bits))
if ok:
_log.info("%s: receiver notifications %s => %s", self, 'enabled' if enable else 'disabled', flag_names)
else:
_log.warn("%s: failed to %s receiver notifications %s", self, 'enable' if enable else 'disable', flag_names)
return flag_bits if ok else None
_log.info("%s: receiver notifications %s => %s", self, 'enabled' if enable else 'disabled', flag_names)
return flag_bits
def notify_devices(self):
"""Scan all devices."""

View File

@ -69,7 +69,7 @@ class ReceiverStatus(dict):
self.new_device = None
self[KEYS.ERROR] = None
self[KEYS.NOTIFICATION_FLAGS] = receiver.enable_notifications()
# self[KEYS.NOTIFICATION_FLAGS] = receiver.enable_notifications()
def __str__(self):
count = len(self._receiver)
@ -93,7 +93,7 @@ class ReceiverStatus(dict):
r.serial, r.firmware, None
# get an update of the notification flags
self[KEYS.NOTIFICATION_FLAGS] = _hidpp10.get_notification_flags(r)
# self[KEYS.NOTIFICATION_FLAGS] = _hidpp10.get_notification_flags(r)
def process_notification(self, n):
if n.sub_id == 0x4A:

View File

@ -57,7 +57,8 @@ class ReceiverListener(_listener.EventsListener):
def has_started(self):
_log.info("%s: notifications listener has started (%s)", self.receiver, self.receiver.handle)
# self.receiver.enable_notifications()
notification_flags = self.receiver.enable_notifications()
self.receiver.status[_status.KEYS.NOTIFICATION_FLAGS] = notification_flags
self.receiver.notify_devices()
self._status_changed(self.receiver) #, _status.ALERT.NOTIFICATION)