mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Add Status Message module support (#4163)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
df592d4d86
commit
355d2260e8
15 changed files with 1195 additions and 9 deletions
|
|
@ -59,6 +59,7 @@ import org.meshtastic.feature.settings.radio.component.RangeTestConfigScreen
|
|||
import org.meshtastic.feature.settings.radio.component.RemoteHardwareConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.SecurityConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.SerialConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.StatusMessageConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.StoreForwardConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.TelemetryConfigScreen
|
||||
import org.meshtastic.feature.settings.radio.component.UserConfigScreen
|
||||
|
|
@ -163,6 +164,9 @@ fun NavGraphBuilder.settingsGraph(navController: NavHostController) {
|
|||
DetectionSensorConfigScreen(viewModel, onBack = navController::popBackStack)
|
||||
|
||||
ModuleRoute.PAXCOUNTER -> PaxcounterConfigScreen(viewModel, onBack = navController::popBackStack)
|
||||
|
||||
ModuleRoute.STATUS_MESSAGE ->
|
||||
StatusMessageConfigScreen(viewModel, onBack = navController::popBackStack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()) }
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ constructor(
|
|||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE,
|
||||
Portnums.PortNum.ALERT_APP_VALUE,
|
||||
Portnums.PortNum.WAYPOINT_APP_VALUE,
|
||||
Portnums.PortNum.NODE_STATUS_APP_VALUE,
|
||||
)
|
||||
|
||||
fun handleReceivedData(packet: MeshPacket, myNodeNum: Int, logUuid: String? = null, logInsertJob: Job? = null) {
|
||||
|
|
@ -121,6 +122,7 @@ constructor(
|
|||
var shouldBroadcast = !fromUs
|
||||
when (packet.decoded.portnumValue) {
|
||||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE -> handleTextMessage(packet, dataPacket, myNodeNum)
|
||||
Portnums.PortNum.NODE_STATUS_APP_VALUE -> handleNodeStatus(packet, dataPacket, myNodeNum)
|
||||
Portnums.PortNum.ALERT_APP_VALUE -> rememberDataPacket(dataPacket, myNodeNum)
|
||||
Portnums.PortNum.WAYPOINT_APP_VALUE -> handleWaypoint(packet, dataPacket, myNodeNum)
|
||||
Portnums.PortNum.POSITION_APP_VALUE -> handlePosition(packet, dataPacket, myNodeNum)
|
||||
|
|
@ -331,6 +333,12 @@ constructor(
|
|||
nodeManager.handleReceivedUser(packet.from, u, packet.channel)
|
||||
}
|
||||
|
||||
private fun handleNodeStatus(packet: MeshPacket, dataPacket: DataPacket, myNodeNum: Int) {
|
||||
val s = MeshProtos.StatusMessage.parseFrom(packet.decoded.payload)
|
||||
nodeManager.handleReceivedNodeStatus(packet.from, s)
|
||||
rememberDataPacket(dataPacket, myNodeNum)
|
||||
}
|
||||
|
||||
private fun handleTelemetry(packet: MeshPacket, dataPacket: DataPacket, myNodeNum: Int) {
|
||||
val t =
|
||||
TelemetryProtos.Telemetry.parseFrom(packet.decoded.payload).copy {
|
||||
|
|
|
|||
|
|
@ -209,6 +209,10 @@ constructor(
|
|||
updateNodeInfo(fromNum) { it.paxcounter = p }
|
||||
}
|
||||
|
||||
fun handleReceivedNodeStatus(fromNum: Int, s: MeshProtos.StatusMessage) {
|
||||
updateNodeInfo(fromNum) { it.nodeStatus = s.status }
|
||||
}
|
||||
|
||||
fun installNodeInfo(info: MeshProtos.NodeInfo, withBroadcast: Boolean = true) {
|
||||
updateNodeInfo(info.num, withBroadcast = withBroadcast) { entity ->
|
||||
if (info.hasUser()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue