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:
Eugene 2025-12-16 18:56:30 +03:00 committed by GitHub
parent 8d858de00a
commit 24f40b2005
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 847 additions and 20 deletions

View file

@ -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)
}