diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt index cd35a45bdb..ca371fafac 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/ServiceDiscoverer.kt @@ -27,9 +27,13 @@ class ServiceDiscoverer( fun discoverServices(connectionWaitCond: ConnectionWaitCondition): Map { 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)