Bond State
Represents the bonding (pairing) state of a Bluetooth device.
Bonding is the process of creating a trusted relationship between two Bluetooth devices by exchanging and storing security keys. This enum mirrors the bonding states defined in BluetoothDevice but provides a more Kotlin-idiomatic API.
Bonding vs Pairing
While often used interchangeably, bonding specifically refers to the storage of security keys for future connections, while pairing is the initial key exchange. A bonded device can reconnect securely without requiring user interaction.
Usage Example
val bondState = BondState.fromInt(device.bondState)
when (bondState) {
BondState.BOND_NONE -> initiateBonding()
BondState.BOND_BONDING -> showBondingProgress()
BondState.BOND_BONDED -> proceedWithConnection()
}Content copied to clipboard