Expand description
Automatic reconnection handling for Aranet devices.
This module provides a wrapper around Device that automatically handles reconnection when the connection is lost.
ReconnectingDevice implements the AranetDevice trait,
allowing it to be used interchangeably with regular devices in generic code.
§When it reconnects
An operation reconnects when the device isn’t connected, or when it fails with a connection error: not connected, a timeout, a failed connection or a Bluetooth link error. Other errors, such as a characteristic the device doesn’t have, are returned at once. The old connection is closed before the new one is made, because on Linux and macOS closing it later would drop the new connection too.
Operations that fail at the same time share one reconnect. Between attempts
it waits with the backoff of ReconnectOptions;
ReconnectingDevice::cancel_reconnect and ReconnectingDevice::disconnect
end that wait, or a connect in progress, at once. An operation that waited
for a reconnect that gave up or was stopped returns an error instead of
starting another one, unless ReconnectingDevice::cancel_reconnect
stopped that reconnect and ReconnectingDevice::reset_cancellation is
called while the operation still waits. If the operation running a
reconnect is dropped part-way (by a timeout around it, say), the
operations waiting for it share a new reconnect instead, which starts once
the old connection is closed.
While a reconnect runs, and after one has failed, there is no connection:
ReconnectingDevice::name() returns None and
ReconnectingDevice::address() returns the identifier.
Structs§
- Reconnect
Options - Options for automatic reconnection.
- Reconnecting
Device - A device wrapper that automatically handles reconnection.
Enums§
- Connection
State - State of the reconnecting device.