From df8df2bffad97dbc35fbd927c55e19a9cfba1856 Mon Sep 17 00:00:00 2001 From: Daniel Pavel Date: Fri, 21 Jun 2013 22:24:28 +0200 Subject: [PATCH] don't force a battery read on link active, will happen anyway --- lib/logitech/unifying_receiver/status.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/logitech/unifying_receiver/status.py b/lib/logitech/unifying_receiver/status.py index 5e3659a5..c021a5f9 100644 --- a/lib/logitech/unifying_receiver/status.py +++ b/lib/logitech/unifying_receiver/status.py @@ -207,9 +207,9 @@ class DeviceStatus(dict): d.feature_request(_hidpp20.FEATURE.SOLAR_DASHBOARD, 0x00, 1, 1) return - if battery: + if battery is not None: level, status = battery - self.set_battery_info(level, status, timestamp=timestamp) + self.set_battery_info(level, status) elif KEYS.BATTERY_STATUS in self: self[KEYS.BATTERY_STATUS] = None self[KEYS.BATTERY_CHARGING] = None @@ -272,7 +272,7 @@ class DeviceStatus(dict): # may go to sleep and wake up without the devices available if timestamp - self.updated > _STATUS_TIMEOUT: if d.ping(): - self.updated = _timestamp() + timestamp = self.updated = _timestamp() else: self._changed(active=False, reason='out of range') @@ -363,17 +363,6 @@ class DeviceStatus(dict): self._device, protocol_name, sw_present, link_encrypyed, link_established, has_payload) self[KEYS.LINK_ENCRYPTED] = link_encrypyed self._changed(active=link_established) - - # if protocol_name == 'eQuad': - # # some Nano devices might not have been initialized fully - # if self._device._kind is None: - # kind = ord(n.data[:1]) & 0x0F - # self._device._kind = _hidpp10.DEVICE_KIND[kind] - # assert self._device.wpid == _strhex(n.data[2:3] + n.data[1:2]) - - # if the device just came online, read the battery charge - if self._active and KEYS.BATTERY_LEVEL not in self: - self.read_battery() else: _log.warn("%s: connection notification with unknown protocol %02X: %s", self._device.number, n.address, n)