make it compile

This commit is contained in:
Andrei Vereha 2022-06-17 17:58:21 +02:00
parent 8d23df61bd
commit bf889793f0

View file

@ -27,10 +27,14 @@ class ServiceDiscoverer(
fun discoverServices(connectionWaitCond: ConnectionWaitCondition): Map<CharacteristicType, BluetoothGattCharacteristic> { fun discoverServices(connectionWaitCond: ConnectionWaitCondition): Map<CharacteristicType, BluetoothGattCharacteristic> {
logger.debug(LTag.PUMPBTCOMM, "Discovering services") logger.debug(LTag.PUMPBTCOMM, "Discovering services")
bleCallbacks.startServiceDiscovery() bleCallbacks.startServiceDiscovery()
try {
val discover = gatt.discoverServices() val discover = gatt.discoverServices()
if (!discover) { if (!discover) {
throw ConnectException("Could not start discovering services`") throw ConnectException("Could not start discovering services`")
} }
} catch (ex: SecurityException) {
throw ConnectException("Missing bluetooth permission")
}
connectionWaitCond.timeoutMs?.let { connectionWaitCond.timeoutMs?.let {
bleCallbacks.waitForServiceDiscovery(it) bleCallbacks.waitForServiceDiscovery(it)
} }