feat: Display relay node information for messages (#3574)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2025-10-30 17:25:34 -05:00 committed by GitHub
parent 7d1c5cba4c
commit 453dd398d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 840 additions and 16 deletions

View file

@ -76,8 +76,9 @@ import org.meshtastic.core.database.entity.ReactionEntity
AutoMigration(from = 18, to = 19),
AutoMigration(from = 19, to = 20),
AutoMigration(from = 20, to = 21),
AutoMigration(from = 21, to = 22),
],
version = 21,
version = 22,
exportSchema = true,
)
@TypeConverters(Converters::class)

View file

@ -53,6 +53,7 @@ data class PacketEntity(
emojis = reactions.toReaction(getNode),
replyId = data.replyId,
viaMqtt = node.viaMqtt,
relayNode = data.relayNode,
)
}
}
@ -76,7 +77,23 @@ data class Packet(
@ColumnInfo(name = "snr", defaultValue = "0") val snr: Float = 0f,
@ColumnInfo(name = "rssi", defaultValue = "0") val rssi: Int = 0,
@ColumnInfo(name = "hopsAway", defaultValue = "-1") val hopsAway: Int = -1,
)
) {
companion object {
const val RELAY_NODE_SUFFIX_MASK = 0xFF
fun getRelayNode(relayNodeId: Int, nodes: List<Node>): Node? {
val relayNodeIdSuffix = relayNodeId and RELAY_NODE_SUFFIX_MASK
val candidateRelayNodes = nodes.filter { (it.num and RELAY_NODE_SUFFIX_MASK) == relayNodeIdSuffix }
val closestRelayNode =
if (candidateRelayNodes.size == 1) {
candidateRelayNodes.first()
} else {
candidateRelayNodes.minByOrNull { it.hopsAway }
}
return closestRelayNode
}
}
}
@Suppress("ConstructorParameterNaming")
@Entity(tableName = "contact_settings")

View file

@ -64,6 +64,7 @@ data class Message(
val replyId: Int?,
val originalMessage: Message? = null,
val viaMqtt: Boolean = false,
val relayNode: Int? = null,
) {
fun getStatusStringRes(): Pair<Int, Int> {
val title = if (routingError > 0) R.string.error else R.string.message_delivery_status