* 2.8: NodeDB refactor to decouple satellite entries and decrease size * Regen * Refactor node mute handling to use dedicated functions for clarity and consistency * Develop ref * Fix NodeDB review follow-ups Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/6b1d6cf6-ed6b-43b6-95cb-8e141757664e Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Address review validation nits Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/6b1d6cf6-ed6b-43b6-95cb-8e141757664e Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Trunk * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Extract legacy NodeDatabase migration * Fix remaining NodeDB review issues Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/c76b9a5a-7244-4fbc-9ef0-98091d8caaea Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fixes * Trunk * Fix latest review compile follow-ups Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/5198da01-ec4c-4c16-8a09-68b8e6d5d410 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Fix cppcheck style warnings Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/e60287ba-4ece-46e0-83d8-a6d89664c0bb Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Change pointer type for mesh node in set_favorite function * Change pointer types for mesh node references to const in multiple applets * Add NodeDB layout v25 documentation and migration guidelines * Remove tests for uninitialized PacketHistory state due to undefined behavior * Fix code block formatting in copilot instructions --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
47 lines
1.8 KiB
C++
47 lines
1.8 KiB
C++
#if !MESHTASTIC_EXCLUDE_STATUS
|
|
|
|
#include "StatusMessageModule.h"
|
|
#include "MeshService.h"
|
|
#include "NodeDB.h"
|
|
#include "ProtobufModule.h"
|
|
|
|
StatusMessageModule *statusMessageModule;
|
|
|
|
int32_t StatusMessageModule::runOnce()
|
|
{
|
|
if (moduleConfig.has_statusmessage && moduleConfig.statusmessage.node_status[0] != '\0') {
|
|
// create and send message with the status message set
|
|
meshtastic_StatusMessage ourStatus = meshtastic_StatusMessage_init_zero;
|
|
strncpy(ourStatus.status, moduleConfig.statusmessage.node_status, sizeof(ourStatus.status));
|
|
ourStatus.status[sizeof(ourStatus.status) - 1] = '\0'; // ensure null termination
|
|
meshtastic_MeshPacket *p = allocDataPacket();
|
|
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
|
meshtastic_StatusMessage_fields, &ourStatus);
|
|
p->to = NODENUM_BROADCAST;
|
|
p->decoded.want_response = false;
|
|
p->priority = meshtastic_MeshPacket_Priority_BACKGROUND;
|
|
p->channel = 0;
|
|
service->sendToMesh(p);
|
|
}
|
|
|
|
return 1000 * 12 * 60 * 60;
|
|
}
|
|
|
|
ProcessMessage StatusMessageModule::handleReceived(const meshtastic_MeshPacket &mp)
|
|
{
|
|
if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag) {
|
|
meshtastic_StatusMessage incomingMessage = meshtastic_StatusMessage_init_zero;
|
|
|
|
if (pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, meshtastic_StatusMessage_fields,
|
|
&incomingMessage)) {
|
|
|
|
LOG_INFO("Received a NodeStatus message %s", incomingMessage.status);
|
|
|
|
if (nodeDB)
|
|
nodeDB->setNodeStatus(mp.from, incomingMessage);
|
|
}
|
|
}
|
|
return ProcessMessage::CONTINUE;
|
|
}
|
|
|
|
#endif |