Add CGMS module

This commit is contained in:
Sylwester Zieliński
2021-10-18 09:25:44 +02:00
parent d6ccce9187
commit 670b711ec7
41 changed files with 1653 additions and 48 deletions

View File

@@ -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")
}
}
}
}