device: recover from errors in ping

This commit is contained in:
Peter F. Patel-Schneider 2025-02-01 12:57:42 -05:00
parent 20e20ce827
commit e297f90e79
1 changed files with 4 additions and 1 deletions

View File

@ -540,7 +540,10 @@ class Device:
self.hidpp_long is None and (self.bluetooth or self._protocol is not None and self._protocol >= 2.0)
)
handle = self.handle or self.receiver.handle
protocol = self.low_level.ping(handle, self.number, long_message=long)
try:
protocol = self.low_level.ping(handle, self.number, long_message=long)
except exceptions.NoReceiver: # if ping fails, device is offline
protocol = None
self.online = protocol is not None
if protocol:
self._protocol = protocol