retryBleOperation

suspend fun <T> retryBleOperation(count: Int = 3, delayMs: Long = 250, tag: String = "BLE", block: suspend () -> T): T(source)

Retries a BLE operation with bounded exponential backoff and jitter.

Each retry waits delayMs * 2^(attempt-1), capped at MAX_RETRY_DELAY_MS, with a random ±25% jitter applied to avoid synchronised retry storms when multiple operations fail in lockstep (e.g. a TX/RX pair both failing the same STATUS_GATT_BUSY window).

Return

The result of the operation.

Parameters

count

Total attempt count (default 3).

delayMs

Initial delay before the first retry. Subsequent delays grow exponentially.

tag

Tag for log prefixes.

block

The operation to perform.

Throws

If the operation fails after all attempts. CancellationException is always re-thrown immediately.