diff --git a/lib/logitech/unifying_receiver/status.py b/lib/logitech/unifying_receiver/status.py index 50f47904..32052aff 100644 --- a/lib/logitech/unifying_receiver/status.py +++ b/lib/logitech/unifying_receiver/status.py @@ -20,7 +20,7 @@ from . import hidpp20 as _hidpp20 # # -ALERT = _NamedInts(NONE=0x00, LOW=0x01, MED=0x02, HIGH=0xFF) +ALERT = _NamedInts(NONE=0x00, NOTIFICATION=0x01, SHOW_WINDOW=0x02, ALL=0xFF) # device properties that may be reported ENCRYPTED='encrypted' @@ -58,7 +58,7 @@ class ReceiverStatus(dict): '%d devices found.' % count) __unicode__ = __str__ - def _changed(self, alert=ALERT.LOW, reason=None): + def _changed(self, alert=ALERT.NOTIFICATION, reason=None): # self.updated = _timestamp() self._changed_callback(self._receiver, alert=alert, reason=reason) @@ -154,7 +154,7 @@ class DeviceStatus(dict): if battery is not None: self[BATTERY_LEVEL] = battery if self.updated == 0: - alert |= ALERT.LOW + alert |= ALERT.NOTIFICATION self.updated = timestamp or _timestamp() # if _log.isEnabledFor(_DEBUG): # _log.debug("device %d changed: active=%s %s", self._device.number, self._active, dict(self)) @@ -168,7 +168,7 @@ class DeviceStatus(dict): return # read these from the device in case they haven't been read already - d.protocol, d.serial, d.firmware + # d.protocol, d.serial, d.firmware # if BATTERY_LEVEL not in self: self.read_battery(timestamp) @@ -207,7 +207,7 @@ class DeviceStatus(dict): # device un-paired self.clear() self._device.status = None - self._changed(False, ALERT.HIGH, 'unpaired') + self._changed(False, ALERT.ALL, 'unpaired') else: _log.warn("%s: disconnection with unknown type %02X: %s", self._device, n.address, n) return True @@ -265,7 +265,7 @@ class DeviceStatus(dict): if n.address == 0x01: if _log.isEnabledFor(_DEBUG): _log.debug("%s: device powered on", self._device) - self._changed(alert=ALERT.LOW, reason='powered on') + self._changed(alert=ALERT.NOTIFICATION, reason='powered on') else: _log.info("%s: unknown %s", self._device, n) return True @@ -285,7 +285,7 @@ class DeviceStatus(dict): if _log.isEnabledFor(_DEBUG): _log.debug("%s: battery %d% charged, %s", self._device, discharge, self[BATTERY_STATUS]) else: - alert = ALERT.MED + alert = ALERT.ALL reason = self[ERROR] = self[BATTERY_STATUS] _log.warn("%s: battery %d% charged, ALERT %s", self._device, discharge, reason) self._changed(alert=alert, reason=reason) @@ -305,7 +305,7 @@ class DeviceStatus(dict): if _log.isEnabledFor(_DEBUG): _log.debug("wireless status: %s", n) if n.data[0:3] == b'\x01\x01\x01': - self._changed(alert=ALERT.LOW, reason='powered on') + self._changed(alert=ALERT.NOTIFICATION, reason='powered on') else: _log.info("%s: unknown WIRELESS %s", self._device, n) else: @@ -328,7 +328,7 @@ class DeviceStatus(dict): self._changed() elif n.address == 0x20: _log.debug("%s: Solar key pressed", self._device) - self._changed(alert=ALERT.MED) + self._changed(alert=ALERT.SHOW_WINDOW) # first cancel any reporting self._device.feature_request(_hidpp20.FEATURE.SOLAR_CHARGE) # trigger a new report chain diff --git a/lib/solaar/gtk.py b/lib/solaar/gtk.py index be9c0355..2c278196 100644 --- a/lib/solaar/gtk.py +++ b/lib/solaar/gtk.py @@ -92,7 +92,7 @@ def _run(args): # callback delivering status notifications from the receiver/devices to the UI def status_changed(receiver, device=None, alert=status.ALERT.NONE, reason=None): - if alert & status.ALERT.MED: + if alert & status.ALERT.SHOW_WINDOW: GObject.idle_add(window.present) if window: GObject.idle_add(ui.main_window.update, window, receiver, device) @@ -101,7 +101,7 @@ def _run(args): if ui.notify.available: # always notify on receiver updates - if device is None or alert & status.ALERT.LOW: + if device is None or alert & status.ALERT.NOTIFICATION: GObject.idle_add(ui.notify.show, device or receiver, reason) if receiver is DUMMY: diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index 594f1c52..e93f381c 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -52,15 +52,15 @@ class ReceiverListener(_listener.EventsListener): _log.info("%s: notifications listener has started (%s)", self.receiver, self.receiver.handle) self.receiver.enable_notifications() self.receiver.notify_devices() - self._status_changed(self.receiver, _status.ALERT.LOW) + self._status_changed(self.receiver, _status.ALERT.NOTIFICATION) def has_stopped(self): _log.info("%s: notifications listener has stopped", self.receiver) if self.receiver: self.receiver.enable_notifications(False) self.receiver.close() + self._status_changed(self.receiver, _status.ALERT.NOTIFICATION) self.receiver = None - self._status_changed(None, _status.ALERT.LOW) def tick(self, timestamp): if _log.isEnabledFor(_DEBUG):