mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
make sending packets to the BT radio async, for better throughput
This commit is contained in:
parent
27d437e6ab
commit
9756c5c5e3
1 changed files with 22 additions and 1 deletions
|
|
@ -197,7 +197,7 @@ class RadioInterfaceService : Service(), Logging {
|
|||
// al proto = MeshProtos.ToRadio.parseFrom(p)
|
||||
|
||||
debug("sending to radio")
|
||||
doWrite(BTM_TORADIO_CHARACTER, p)
|
||||
doAsyncWrite(BTM_TORADIO_CHARACTER, p)
|
||||
if (logSends) {
|
||||
sentPacketsLog.write(p)
|
||||
sentPacketsLog.flush()
|
||||
|
|
@ -337,6 +337,27 @@ class RadioInterfaceService : Service(), Logging {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* do an asynchronous write operation
|
||||
* Any error responses will be ignored (other than log messages)
|
||||
*/
|
||||
private fun doAsyncWrite(uuid: UUID, a: ByteArray) = toRemoteExceptions {
|
||||
if (!isConnected)
|
||||
throw RadioNotConnectedException()
|
||||
else {
|
||||
debug("queuing ${a.size} bytes to $uuid")
|
||||
|
||||
// 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 = service.getCharacteristic(uuid)
|
||||
toRadio.value = a
|
||||
|
||||
safe!!.asyncWriteCharacteristic(toRadio) {
|
||||
debug("asyncwrite of ${a.size} bytes completed")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* do a synchronous read operation
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue