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> {
|
fun discoverServices(): Map<CharacteristicType, BluetoothGattCharacteristic> {
|
||||||
logger.debug(LTag.PUMPBTCOMM, "Discovering services")
|
logger.debug(LTag.PUMPBTCOMM, "Discovering services")
|
||||||
|
bleCallbacks.startServiceDiscovery()
|
||||||
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`")
|
||||||
|
|
|
@ -61,6 +61,10 @@ class BleCommCallbacks(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun startServiceDiscovery() {
|
||||||
|
serviceDiscoveryComplete = CountDownLatch(1)
|
||||||
|
}
|
||||||
|
|
||||||
fun waitForServiceDiscovery(timeoutMs: Int) {
|
fun waitForServiceDiscovery(timeoutMs: Int) {
|
||||||
try {
|
try {
|
||||||
serviceDiscoveryComplete.await(timeoutMs.toLong(), TimeUnit.MILLISECONDS)
|
serviceDiscoveryComplete.await(timeoutMs.toLong(), TimeUnit.MILLISECONDS)
|
||||||
|
|
Loading…
Reference in a new issue