From 808a7198234c62566da33b22f8fcbfc8a1fe9c2b Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Sun, 22 Nov 2020 21:54:18 -0500 Subject: [PATCH] device: push device settings when device is active after suspend --- lib/logitech_receiver/status.py | 5 +++-- lib/solaar/listener.py | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/logitech_receiver/status.py b/lib/logitech_receiver/status.py index 5fbd81c1..87f9311a 100644 --- a/lib/logitech_receiver/status.py +++ b/lib/logitech_receiver/status.py @@ -20,6 +20,7 @@ from __future__ import absolute_import, division, print_function, unicode_literals from logging import DEBUG as _DEBUG +from logging import INFO as _INFO from logging import getLogger from time import time as _timestamp @@ -303,8 +304,8 @@ class DeviceStatus(dict): # Devices lose configuration when they are turned off, # make sure they're up-to-date. - if _log.isEnabledFor(_DEBUG): - _log.debug('%s pushing device settings %s', d, d.settings) + if _log.isEnabledFor(_INFO): + _log.info('%s pushing device settings %s', d, d.settings) for s in d.settings: s.apply() diff --git a/lib/solaar/listener.py b/lib/solaar/listener.py index 0f718822..930c1342 100644 --- a/lib/solaar/listener.py +++ b/lib/solaar/listener.py @@ -323,11 +323,14 @@ def stop_all(): # after a resume, the device may have been off # so mark its saved status to ensure that the status is pushed to the device when it comes back def ping_all(resuming=False): + if _log.isEnabledFor(_INFO): + _log.info('ping all devices%s', ' when resuming' if resuming else '') for l in _all_listeners.values(): if l.receiver.isDevice: if resuming: l.receiver.status._active = False - l.receiver.ping() + if l.receiver.ping(): + l.receiver.status.changed(active=True) l._status_changed(l.receiver) else: count = l.receiver.count() @@ -335,7 +338,8 @@ def ping_all(resuming=False): for dev in l.receiver: if resuming: dev.status._active = False - dev.ping() + if dev.ping(): + dev.status.changed(active=True) l._status_changed(dev) count -= 1 if not count: