pub struct ManagerConfig {
pub scan_options: ScanOptions,
pub default_reconnect_options: ReconnectOptions,
pub event_capacity: usize,
pub health_check_interval: Duration,
pub max_concurrent_connections: usize,
pub use_adaptive_interval: bool,
pub min_health_check_interval: Duration,
pub max_health_check_interval: Duration,
pub default_priority: DevicePriority,
pub use_connection_validation: bool,
}Expand description
Configuration for the device manager.
Fields§
§scan_options: ScanOptionsDefault scan options.
default_reconnect_options: ReconnectOptionsDefault reconnect options for new devices.
The health monitor (DeviceManager::start_health_monitor) waits
between automatic reconnects of a device as these options say, and
stops after max_attempts failures in a row, emitting one
DeviceEvent::Error; DeviceManager::connect starts over. With
max_attempts of 0 it never reconnects a device that has been
connected, but a device that has never been connected, such as one
just added, still gets one attempt.
The default is ReconnectOptions::unlimited since 0.3.0. With the
five attempts of ReconnectOptions::default(), the monitor would give
up on a device after about a minute.
event_capacity: usizeEvent channel capacity.
health_check_interval: DurationHealth check interval for auto-reconnect (base interval).
max_concurrent_connections: usizeMaximum number of concurrent BLE connections.
Most BLE adapters support 5-7 concurrent connections. Attempting to connect beyond this limit will return an error. Set to 0 for no limit (not recommended).
use_adaptive_interval: boolWhether to use adaptive health check intervals.
When enabled, the health check interval will automatically adjust:
- Decrease (more frequent) when connections are unstable
- Increase (less frequent) when connections are stable
min_health_check_interval: DurationMinimum health check interval (for adaptive mode).
max_health_check_interval: DurationMaximum health check interval (for adaptive mode).
default_priority: DevicePriorityDefault priority for new devices.
use_connection_validation: boolWhether to use connection validation (keepalive checks).
When enabled, health checks use device.validate_connection(), which
reads the current measurements to verify the connection is alive. That
read needs no pairing that reading the sensor doesn’t. This catches
“zombie connections” but uses more power.
When disabled, health checks only ask the Bluetooth stack whether the device is connected. A zombie connection passes that check, so the health monitor replaces it only once the stack reports it lost.
Implementations§
Source§impl ManagerConfig
impl ManagerConfig
Sourcepub fn with_max_connections(self, max: usize) -> Self
pub fn with_max_connections(self, max: usize) -> Self
Create a configuration with a specific connection limit.
Sourcepub fn unlimited_connections(self) -> Self
pub fn unlimited_connections(self) -> Self
Create a configuration with no connection limit (not recommended).
Sourcepub fn adaptive_interval(self, enabled: bool) -> Self
pub fn adaptive_interval(self, enabled: bool) -> Self
Enable or disable adaptive health check intervals.
Sourcepub fn health_check_interval(self, interval: Duration) -> Self
pub fn health_check_interval(self, interval: Duration) -> Self
Set the health check interval (base interval for adaptive mode).
Sourcepub fn default_priority(self, priority: DevicePriority) -> Self
pub fn default_priority(self, priority: DevicePriority) -> Self
Set the default device priority.
Sourcepub fn connection_validation(self, enabled: bool) -> Self
pub fn connection_validation(self, enabled: bool) -> Self
Enable or disable connection validation in health checks.
Trait Implementations§
Source§impl Clone for ManagerConfig
impl Clone for ManagerConfig
Source§fn clone(&self) -> ManagerConfig
fn clone(&self) -> ManagerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more