gui: defend against lightspeed receivers that contact devices for basic information

This commit is contained in:
Peter F. Patel-Schneider 2023-12-24 07:57:34 -05:00
parent 94e9cfce8e
commit 195e28ad76
1 changed files with 19 additions and 11 deletions

View File

@ -154,6 +154,8 @@ class ReceiverListener(_listener.EventsListener):
def _status_changed(self, device, alert=_status.ALERT.NONE, reason=None):
assert device is not None
if _log.isEnabledFor(_INFO):
try:
device.ping()
if device.kind is None:
_log.info(
'status_changed %r: %s, %s (%X) %s', device, 'present' if bool(device) else 'removed', device.status,
@ -164,6 +166,8 @@ class ReceiverListener(_listener.EventsListener):
'status_changed %r: %s %s, %s (%X) %s', device, 'paired' if bool(device) else 'unpaired',
'online' if device.online else 'offline', device.status, alert, reason or ''
)
except Exception:
_log.info('status_changed for unknown device')
if device.kind is None:
assert device == self.receiver
@ -253,7 +257,11 @@ class ReceiverListener(_listener.EventsListener):
# Apply settings every time the device connects
if n.sub_id == 0x41:
if _log.isEnabledFor(_INFO):
try:
dev.ping()
_log.info('connection %s for %r', n, dev)
except Exception:
_log.info('connection %s for unknown device, number %s', n, n.devnumber)
# If there are saved configs, bring the device's settings up-to-date.
# They will be applied when the device is marked as online.
configuration.attach_to(dev)