pub async fn scan_with_retry(
options: ScanOptions,
max_retries: u32,
retry_on_empty: bool,
) -> Result<Vec<DiscoveredDevice>>Expand description
Scan for devices with retry logic for flaky Bluetooth environments.
This function will retry the scan up to max_retries times if:
- The scan fails due to a Bluetooth error
- No devices are found (when
retry_on_emptyis true)
A delay is applied between retries, starting at 500ms and doubling each attempt.
§Arguments
options- Scan optionsmax_retries- Maximum number of retry attemptsretry_on_empty- Whether to retry if no devices are found
§Example
ⓘ
use aranet_core::scan::{ScanOptions, scan_with_retry};
// Retry up to 3 times, including when no devices found
let devices = scan_with_retry(ScanOptions::default(), 3, true).await?;