mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
used deferred execution to prevent dropping packets at startup
This commit is contained in:
parent
d03bfb556c
commit
db0936ff88
2 changed files with 36 additions and 22 deletions
|
|
@ -98,6 +98,24 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
composeView(meshServiceState)
|
||||
}
|
||||
|
||||
private fun sendTestPackets() {
|
||||
val m = meshService!!
|
||||
|
||||
// Do some test operations
|
||||
m.setOwner("+16508675309", "Kevin Xter", "kx")
|
||||
val testPayload = "hello world".toByteArray()
|
||||
m.sendData(
|
||||
"+16508675310",
|
||||
testPayload,
|
||||
MeshProtos.Data.Type.SIGNAL_OPAQUE_VALUE
|
||||
)
|
||||
m.sendData(
|
||||
"+16508675310",
|
||||
testPayload,
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun composeView(meshServiceState: MeshServiceState) {
|
||||
MaterialTheme {
|
||||
|
|
@ -122,25 +140,7 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
})
|
||||
|
||||
Button(text = "send packets",
|
||||
onClick = {
|
||||
// FIXME - don't do these operations until we are informed we have a connection, otherwise
|
||||
// the radio interface service might not yet be connected to the mesh service
|
||||
val m = meshService!!
|
||||
|
||||
// Do some test operations
|
||||
m.setOwner("+16508675309", "Kevin Xter", "kx")
|
||||
val testPayload = "hello world".toByteArray()
|
||||
m.sendData(
|
||||
"+16508675310",
|
||||
testPayload,
|
||||
MeshProtos.Data.Type.SIGNAL_OPAQUE_VALUE
|
||||
)
|
||||
m.sendData(
|
||||
"+16508675310",
|
||||
testPayload,
|
||||
MeshProtos.Data.Type.CLEAR_TEXT_VALUE
|
||||
)
|
||||
})
|
||||
onClick = { sendTestPackets() })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -178,6 +178,11 @@ class MainActivity : AppCompatActivity(), Logging {
|
|||
val m = IMeshService.Stub.asInterface(service)
|
||||
meshService = m
|
||||
|
||||
// FIXME: this still can't work this early because the send to +6508675310
|
||||
// requires a DB lookup which isn't yet populated (until the sim test packets
|
||||
// from the radio arrive)
|
||||
// sendTestPackets() // send some traffic ASAP
|
||||
|
||||
// FIXME this doesn't work because the model has already been copied into compose land?
|
||||
// runOnUiThread { // FIXME - this can be removed?
|
||||
meshServiceState.connected = m.isConnected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue