mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: add SNR/RSSI/Hops Away metrics and timestamp to the reaction dialog (#3964)
Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
8d858de00a
commit
24f40b2005
5 changed files with 847 additions and 20 deletions
|
|
@ -752,6 +752,9 @@ class MeshService : Service() {
|
|||
userId = toNodeID(packet.from),
|
||||
emoji = packet.decoded.payload.toByteArray().decodeToString(),
|
||||
timestamp = System.currentTimeMillis(),
|
||||
snr = packet.rxSnr,
|
||||
rssi = packet.rxRssi,
|
||||
hopsAway = getHopsAwayForPacket(packet),
|
||||
)
|
||||
packetRepository.get().insertReaction(reaction)
|
||||
}
|
||||
|
|
@ -1362,6 +1365,15 @@ class MeshService : Service() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun getHopsAwayForPacket(packet: MeshPacket): Int =
|
||||
if (packet.decoded.portnumValue == Portnums.PortNum.RANGE_TEST_APP_VALUE) {
|
||||
0 // These don't come with the .hop params, but do not propagate, so they must be 0
|
||||
} else if (packet.hopStart == 0 || packet.hopLimit > packet.hopStart) {
|
||||
-1
|
||||
} else {
|
||||
packet.hopStart - packet.hopLimit
|
||||
}
|
||||
|
||||
// Update our model and resend as needed for a MeshPacket we just received from the radio
|
||||
private fun processReceivedMeshPacket(packet: MeshPacket) {
|
||||
val fromNum = packet.from
|
||||
|
|
@ -1403,14 +1415,7 @@ class MeshService : Service() {
|
|||
it.rssi = packet.rxRssi
|
||||
|
||||
// Generate our own hopsAway, comparing hopStart to hopLimit.
|
||||
it.hopsAway =
|
||||
if (packet.decoded.portnumValue == Portnums.PortNum.RANGE_TEST_APP_VALUE) {
|
||||
0 // These don't come with the .hop params, but do not propogate, so they must be 0
|
||||
} else if (packet.hopStart == 0 || packet.hopLimit > packet.hopStart) {
|
||||
-1
|
||||
} else {
|
||||
packet.hopStart - packet.hopLimit
|
||||
}
|
||||
it.hopsAway = getHopsAwayForPacket(packet)
|
||||
}
|
||||
handleReceivedData(packet)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue