Fix back to back writes to not overwrite BLE characterstic. Fixes

the "sending while device was asleep bug"
This commit is contained in:
geeksville 2020-06-13 16:21:26 -07:00
parent 7ee4aff64c
commit f9c1ac8cd2
3 changed files with 60 additions and 22 deletions

View file

@ -217,9 +217,8 @@ class BluetoothInterface(val service: RadioInterfaceService, val address: String
// Note: we generate a new characteristic each time, because we are about to
// change the data and we want the data stored in the closure
val toRadio = getCharacteristic(uuid)
toRadio.value = a
s.asyncWriteCharacteristic(toRadio) { r ->
s.asyncWriteCharacteristic(toRadio, a) { r ->
try {
r.getOrThrow()
debug("write of ${a.size} bytes completed")