Fix autobug: some BLE implementations might not be completed

with service enumeration by the time they call the discover services
callback.  Therefore be careful to not touch "service" until after
the 500ms delay everyone on stackoverflow says these buggy drivers need.
This commit is contained in:
geeksville
2020-04-22 07:25:07 -07:00
parent a201de649c
commit b194659e8a

View File

@@ -376,7 +376,7 @@ class RadioInterfaceService : Service(), Logging {
// FIXME - no need to discover services more than once - instead use lazy() to use them in future attempts
safe!!.asyncDiscoverServices { discRes ->
discRes.getOrThrow() // FIXME, instead just try to reconnect?
debug("Discovered services! Service size=${service.characteristics.size}")
debug("Discovered services!")
// we begin by setting our MTU size as high as it can go
safe!!.asyncRequestMtu(512) { mtuRes ->