feat: show per-message SNR, RSSI and hop count (#2040)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
Łukasz Kosson 2025-06-06 22:41:25 +02:00 committed by GitHub
parent 639213145b
commit 9a371ee9cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 794 additions and 8 deletions

View file

@ -59,6 +59,9 @@ data class DataPacket(
var hopLimit: Int = 0,
var channel: Int = 0, // channel index
var wantAck: Boolean = true, // If true, the receiver should send an ack back
var hopStart: Int = 0,
var snr: Float = 0f,
var rssi: Int = 0,
) : Parcelable {
/**
@ -107,6 +110,9 @@ data class DataPacket(
null
}
val hopsAway: Int
get() = if (hopStart == 0 || hopLimit > hopStart) -1 else hopStart - hopLimit
// Autogenerated comparision, because we have a byte array
constructor(parcel: Parcel) : this(
@ -120,8 +126,12 @@ data class DataPacket(
parcel.readInt(),
parcel.readInt(),
parcel.readInt() == 1,
parcel.readInt(),
parcel.readFloat(),
parcel.readInt(),
)
@Suppress("CyclomaticComplexMethod")
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
@ -138,6 +148,9 @@ data class DataPacket(
if (status != other.status) return false
if (hopLimit != other.hopLimit) return false
if (wantAck != other.wantAck) return false
if (hopStart != other.hopStart) return false
if (snr != other.snr) return false
if (rssi != other.rssi) return false
return true
}
@ -153,6 +166,9 @@ data class DataPacket(
result = 31 * result + hopLimit
result = 31 * result + channel
result = 31 * result + wantAck.hashCode()
result = 31 * result + hopStart
result = 31 * result + snr.hashCode()
result = 31 * result + rssi
return result
}
@ -167,6 +183,9 @@ data class DataPacket(
parcel.writeInt(hopLimit)
parcel.writeInt(channel)
parcel.writeInt(if (wantAck) 1 else 0)
parcel.writeInt(hopStart)
parcel.writeFloat(snr)
parcel.writeInt(rssi)
}
override fun describeContents(): Int {
@ -185,6 +204,9 @@ data class DataPacket(
hopLimit = parcel.readInt()
channel = parcel.readInt()
wantAck = parcel.readInt() == 1
hopStart = parcel.readInt()
snr = parcel.readFloat()
rssi = parcel.readInt()
}
companion object CREATOR : Parcelable.Creator<DataPacket> {