restart service discovery
This commit is contained in:
parent
a62b5f7f70
commit
8f5ecfd0d6
2 changed files with 5 additions and 0 deletions
|
@ -21,6 +21,7 @@ class ServiceDiscoverer(
|
|||
*/
|
||||
fun discoverServices(): Map<CharacteristicType, BluetoothGattCharacteristic> {
|
||||
logger.debug(LTag.PUMPBTCOMM, "Discovering services")
|
||||
bleCallbacks.startServiceDiscovery()
|
||||
val discover = gatt.discoverServices()
|
||||
if (!discover) {
|
||||
throw ConnectException("Could not start discovering services`")
|
||||
|
|
|
@ -61,6 +61,10 @@ class BleCommCallbacks(
|
|||
}
|
||||
}
|
||||
|
||||
fun startServiceDiscovery() {
|
||||
serviceDiscoveryComplete = CountDownLatch(1)
|
||||
}
|
||||
|
||||
fun waitForServiceDiscovery(timeoutMs: Int) {
|
||||
try {
|
||||
serviceDiscoveryComplete.await(timeoutMs.toLong(), TimeUnit.MILLISECONDS)
|
||||
|
|
Loading…
Reference in a new issue