BleConnection

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

Parameters

context

The Android Context used for BLE operations. An application context is recommended to avoid memory leaks.

device

The BluetoothDevice to connect to.

bondManager

Optional BondManager for handling device bonding operations. If null, bond will return an empty flow.

autoReconnect

Whether to automatically attempt reconnection when the connection is lost unexpectedly. Defaults to true.

reconnectDelayMs

Base delay in milliseconds for exponential backoff reconnection. The actual delay increases exponentially with each attempt. Defaults to ConnectionStateMachine.DEFAULT_RECONNECT_DELAY_MS.

maxReconnectDelayMs

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

maxReconnectAttempts

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