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,9 +27,13 @@ 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()
val discover = gatt.discoverServices() try {
if (!discover) { val discover = gatt.discoverServices()
throw ConnectException("Could not start discovering services`") if (!discover) {
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)