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> {
logger.debug(LTag.PUMPBTCOMM, "Discovering services")
bleCallbacks.startServiceDiscovery()
val discover = gatt.discoverServices()
if (!discover) {
throw ConnectException("Could not start discovering services`")
try {
val discover = gatt.discoverServices()
if (!discover) {
throw ConnectException("Could not start discovering services`")
}
} catch (ex: SecurityException) {
throw ConnectException("Missing bluetooth permission")
}
connectionWaitCond.timeoutMs?.let {
bleCallbacks.waitForServiceDiscovery(it)