add received packets binary file logging (to improve simulation)

1.2-legacy
Kevin Hester 2020-03-02 06:31:15 -08:00
rodzic b13e52d2eb
commit 8c185a7718
1 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -188,7 +188,9 @@ class RadioInterfaceService : Service(), Logging {
private lateinit var fromNum: BluetoothGattCharacteristic
private val logSends = false
private val logReceives = false
lateinit var sentPacketsLog: BinaryLogFile // inited in onCreate
lateinit var receivedPacketsLog: BinaryLogFile
private var isConnected = false
@ -219,6 +221,10 @@ class RadioInterfaceService : Service(), Logging {
// Handle an incoming packet from the radio, broadcasts it as an android intent
private fun handleFromRadio(p: ByteArray) {
if(logReceives) {
receivedPacketsLog.write(p)
receivedPacketsLog.flush()
}
broadcastReceivedFromRadio(
this,
p
@ -334,12 +340,16 @@ class RadioInterfaceService : Service(), Logging {
if (logSends)
sentPacketsLog = BinaryLogFile(this, "sent_log.pb")
if (logReceives)
receivedPacketsLog = BinaryLogFile(this, "receive_log.pb")
}
}
} else {
info("Closing radio interface service")
if (logSends)
sentPacketsLog.close()
if(logReceives)
receivedPacketsLog.close()
safe?.close()
safe = null
}