mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2025-12-21 08:24:22 +01:00
Add CGMS module
This commit is contained in:
@@ -10,6 +10,15 @@ class SelectedBluetoothDeviceHolder {
|
||||
fun isBondingRequired(): Boolean {
|
||||
return device?.bondState == BluetoothDevice.BOND_NONE
|
||||
}
|
||||
|
||||
fun getBondingState(): BondingState {
|
||||
return when (device?.bondState) {
|
||||
BluetoothDevice.BOND_BONDED -> BondingState.BONDED
|
||||
BluetoothDevice.BOND_BONDING -> BondingState.BONDING
|
||||
else -> BondingState.NONE
|
||||
}
|
||||
}
|
||||
|
||||
fun bondDevice() {
|
||||
device?.createBond()
|
||||
}
|
||||
@@ -22,3 +31,18 @@ class SelectedBluetoothDeviceHolder {
|
||||
device = null
|
||||
}
|
||||
}
|
||||
|
||||
enum class BondingState {
|
||||
NONE, BONDING, BONDED;
|
||||
|
||||
companion object {
|
||||
fun create(value: Int): BondingState {
|
||||
return when (value) {
|
||||
BluetoothDevice.BOND_BONDED -> BONDED
|
||||
BluetoothDevice.BOND_BONDING -> BONDING
|
||||
BluetoothDevice.BOND_NONE -> NONE
|
||||
else -> throw IllegalArgumentException("Cannot create BondingState for the value: $value")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user