ConnectionStateMachine

constructor(context: Context, device: BluetoothDevice, bondManager: BondManager? = null, autoReconnect: Boolean = true, reconnectDelayMs: Long = DEFAULT_RECONNECT_DELAY_MS, maxReconnectDelayMs: Long = DEFAULT_MAX_RECONNECT_DELAY_MS, maxReconnectAttempts: Int = DEFAULT_MAX_RECONNECT_ATTEMPTS, operationTimeoutMs: Long = DEFAULT_OPERATION_TIMEOUT_MS)

Parameters

context

The Android context used for GATT connection.

device

The BluetoothDevice to connect to.

bondManager

Optional BondManager for handling device bonding/pairing.

autoReconnect

If true, automatically attempts reconnection on disconnection or error. Defaults to true.

reconnectDelayMs

Base delay in milliseconds for exponential backoff reconnection. The actual delay increases exponentially with each attempt. Defaults to DEFAULT_RECONNECT_DELAY_MS (1000ms).

maxReconnectDelayMs

Maximum delay in milliseconds between reconnection attempts. The exponential backoff will be capped at this value. Defaults to DEFAULT_MAX_RECONNECT_DELAY_MS (30000ms).

maxReconnectAttempts

Maximum number of reconnection attempts before giving up. When this limit is reached, the state transitions to ConnectionState.Error. Defaults to DEFAULT_MAX_RECONNECT_ATTEMPTS (10).

operationTimeoutMs

Timeout in milliseconds for BLE operations (MTU, PHY, read, write). Defaults to DEFAULT_OPERATION_TIMEOUT_MS (10000ms).