feat: Add Status Message module support (#4163)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-25 08:15:47 -06:00 committed by GitHub
parent df592d4d86
commit 355d2260e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 1195 additions and 9 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Meshtastic LLC
* Copyright (c) 2025-2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.geeksville.mesh.repository.radio
import co.touchlab.kermit.Logger
@ -32,12 +31,14 @@ import org.meshtastic.proto.ChannelProtos
import org.meshtastic.proto.ConfigKt
import org.meshtastic.proto.ConfigProtos
import org.meshtastic.proto.MeshProtos
import org.meshtastic.proto.ModuleConfigProtos
import org.meshtastic.proto.Portnums
import org.meshtastic.proto.TelemetryProtos
import org.meshtastic.proto.channel
import org.meshtastic.proto.config
import org.meshtastic.proto.deviceMetadata
import org.meshtastic.proto.fromRadio
import org.meshtastic.proto.moduleConfig
import org.meshtastic.proto.queueStatus
import kotlin.random.Random
@ -108,6 +109,16 @@ constructor(
}
}
d.getModuleConfigRequest == AdminProtos.AdminMessage.ModuleConfigType.STATUSMESSAGE_CONFIG ->
sendAdmin(pr.packet.to, pr.packet.from, pr.packet.id) {
getModuleConfigResponse = moduleConfig {
statusmessage =
ModuleConfigProtos.ModuleConfig.StatusMessageConfig.newBuilder()
.setNodeStatus("Going to the farm.. to grow wheat.")
.build()
}
}
else -> Logger.i { "Ignoring admin sent to mock interface $d" }
}
}
@ -240,6 +251,30 @@ constructor(
.build()
}
private fun makeNodeStatus(numIn: Int) = MeshProtos.FromRadio.newBuilder().apply {
packet =
MeshProtos.MeshPacket.newBuilder()
.apply {
id = packetIdSequence.next()
from = numIn
to = 0xffffffff.toInt() // broadcast
rxTime = (System.currentTimeMillis() / 1000).toInt()
rxSnr = 1.5f
decoded =
MeshProtos.Data.newBuilder()
.apply {
portnum = Portnums.PortNum.NODE_STATUS_APP
payload =
MeshProtos.StatusMessage.newBuilder()
.setStatus("Going to the farm.. to grow wheat.")
.build()
.toByteString()
}
.build()
}
.build()
}
private fun makeDataPacket(fromIn: Int, toIn: Int, data: MeshProtos.Data.Builder) =
MeshProtos.FromRadio.newBuilder().apply {
packet =
@ -356,6 +391,7 @@ constructor(
makeNeighborInfo(MY_NODE + 1),
makePosition(MY_NODE + 1),
makeTelemetry(MY_NODE + 1),
makeNodeStatus(MY_NODE + 1),
)
packets.forEach { p -> service.handleFromRadio(p.build().toByteArray()) }