Compare commits

..

9 Commits

Author SHA1 Message Date
Jonathan Bennett
c6003be4c9 Merge branch 'develop' into status-message 2026-01-28 17:20:17 -06:00
Jonathan Bennett
0c14c461c7 Merge branch 'develop' into status-message 2026-01-28 17:11:47 -06:00
Jonathan Bennett
b7081a5c62 Merge branch 'develop' into status-message 2026-01-28 16:17:48 -06:00
Jonathan Bennett
c87b511010 Merge branch 'develop' into status-message 2026-01-25 15:58:55 -06:00
Jonathan Bennett
1f0ef2498a Don't reboot node simply for a StatusMessage config update 2026-01-20 18:10:40 -06:00
Jonathan Bennett
84cd870323 Trunk 2026-01-20 10:42:23 -06:00
Jonathan Bennett
2eda145a56 Merge branch 'develop' into status-message 2026-01-20 10:34:24 -06:00
Jonathan Bennett
2f821ca267 Merge branch 'develop' into status-message 2026-01-18 15:20:57 -06:00
Jonathan Bennett
be8506857c Add StatusMessage module and config overrides 2026-01-18 15:15:31 -06:00
24 changed files with 151 additions and 108 deletions

View File

@@ -1419,6 +1419,15 @@ void NodeDB::loadFromDisk()
if (portduino_config.has_configDisplayMode) {
config.display.displaymode = (_meshtastic_Config_DisplayConfig_DisplayMode)portduino_config.configDisplayMode;
}
if (portduino_config.has_statusMessage) {
moduleConfig.has_statusmessage = true;
strncpy(moduleConfig.statusmessage.node_status, portduino_config.statusMessage.c_str(),
sizeof(moduleConfig.statusmessage.node_status));
moduleConfig.statusmessage.node_status[sizeof(moduleConfig.statusmessage.node_status) - 1] = '\0';
}
if (portduino_config.enable_UDP) {
config.network.enabled_protocols = true;
}
#endif
}
@@ -1559,6 +1568,7 @@ bool NodeDB::saveToDiskNoRetry(int saveWhat)
moduleConfig.has_ambient_lighting = true;
moduleConfig.has_audio = true;
moduleConfig.has_paxcounter = true;
moduleConfig.has_statusmessage = true;
success &=
saveProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, &meshtastic_LocalModuleConfig_msg, &moduleConfig);

View File

@@ -905,10 +905,11 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c)
bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
{
bool shouldReboot = true;
// If we are in an open transaction or configuring MQTT or Serial (which have validation), defer disabling Bluetooth
// Otherwise, disable Bluetooth to prevent the phone from interfering with the config
if (!hasOpenEditTransaction &&
!IS_ONE_OF(c.which_payload_variant, meshtastic_ModuleConfig_mqtt_tag, meshtastic_ModuleConfig_serial_tag)) {
if (!hasOpenEditTransaction && !IS_ONE_OF(c.which_payload_variant, meshtastic_ModuleConfig_mqtt_tag,
meshtastic_ModuleConfig_serial_tag, meshtastic_ModuleConfig_statusmessage_tag)) {
disableBluetooth();
}
@@ -1000,8 +1001,14 @@ bool AdminModule::handleSetModuleConfig(const meshtastic_ModuleConfig &c)
moduleConfig.has_paxcounter = true;
moduleConfig.paxcounter = c.payload_variant.paxcounter;
break;
case meshtastic_ModuleConfig_statusmessage_tag:
LOG_INFO("Set module config: StatusMessage");
moduleConfig.has_statusmessage = true;
moduleConfig.statusmessage = c.payload_variant.statusmessage;
shouldReboot = false;
break;
}
saveChanges(SEGMENT_MODULECONFIG);
saveChanges(SEGMENT_MODULECONFIG, shouldReboot);
return true;
}
@@ -1180,6 +1187,11 @@ void AdminModule::handleGetModuleConfig(const meshtastic_MeshPacket &req, const
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_paxcounter_tag;
res.get_module_config_response.payload_variant.paxcounter = moduleConfig.paxcounter;
break;
case meshtastic_AdminMessage_ModuleConfigType_STATUSMESSAGE_CONFIG:
LOG_INFO("Get module config: StatusMessage");
res.get_module_config_response.which_payload_variant = meshtastic_ModuleConfig_statusmessage_tag;
res.get_module_config_response.payload_variant.statusmessage = moduleConfig.statusmessage;
break;
}
// NOTE: The phone app needs to know the ls_secsvalue so it can properly expect sleep behavior.

View File

@@ -1,7 +1,6 @@
#include "configuration.h"
#if !MESHTASTIC_EXCLUDE_INPUTBROKER
#include "buzz/BuzzerFeedbackThread.h"
#include "modules/StatusLEDModule.h"
#include "modules/SystemCommandsModule.h"
#endif
#if !MESHTASTIC_EXCLUDE_PKI
@@ -90,10 +89,10 @@
#if !MESHTASTIC_EXCLUDE_DROPZONE
#include "modules/DropzoneModule.h"
#endif
#if defined(HAS_HARDWARE_WATCHDOG)
#include "watchdog/watchdogThread.h"
#if !MESHTASTIC_EXCLUDE_STATUS
#include "modules/StatusMessageModule.h"
#endif
/**
* Create module instances here. If you are adding a new module, you must 'new' it here (or somewhere else)
*/
@@ -150,6 +149,9 @@ void setupModules()
#if !MESHTASTIC_EXCLUDE_DROPZONE
dropzoneModule = new DropzoneModule();
#endif
#if !MESHTASTIC_EXCLUDE_STATUS
statusMessageModule = new StatusMessageModule();
#endif
#if !MESHTASTIC_EXCLUDE_GENERIC_THREAD_MODULE
new GenericThreadModule();
#endif
@@ -232,9 +234,6 @@ void setupModules()
#if !MESHTASTIC_EXCLUDE_RANGETEST && !MESHTASTIC_EXCLUDE_GPS
if (moduleConfig.has_range_test && moduleConfig.range_test.enabled)
new RangeTestModule();
#endif
#if defined(HAS_HARDWARE_WATCHDOG)
watchdogThread = new WatchdogThread();
#endif
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
// acks

View File

@@ -0,0 +1,41 @@
#if !MESHTASTIC_EXCLUDE_STATUS
#include "StatusMessageModule.h"
#include "MeshService.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;
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);
}
}
return ProcessMessage::CONTINUE;
}
#endif

View File

@@ -0,0 +1,35 @@
#pragma once
#if !MESHTASTIC_EXCLUDE_STATUS
#include "SinglePortModule.h"
#include "configuration.h"
class StatusMessageModule : public SinglePortModule, private concurrency::OSThread
{
public:
/** Constructor
* name is for debugging output
*/
StatusMessageModule()
: SinglePortModule("statusMessage", meshtastic_PortNum_NODE_STATUS_APP), concurrency::OSThread("StatusMessage")
{
if (moduleConfig.has_statusmessage && moduleConfig.statusmessage.node_status[0] != '\0') {
this->setInterval(2 * 60 * 1000);
} else {
this->setInterval(1000 * 12 * 60 * 60);
}
// TODO: If we have a string, set the initial delay (15 minutes maybe)
}
virtual int32_t runOnce() override;
protected:
/** Called to handle a particular incoming message
*/
virtual ProcessMessage handleReceived(const meshtastic_MeshPacket &mp) override;
private:
};
extern StatusMessageModule *statusMessageModule;
#endif

View File

@@ -872,6 +872,7 @@ bool loadConfig(const char *configPath)
}
if (yamlConfig["Config"]) {
portduino_config.has_config_overrides = true;
if (yamlConfig["Config"]["DisplayMode"]) {
portduino_config.has_configDisplayMode = true;
if ((yamlConfig["Config"]["DisplayMode"]).as<std::string>("") == "TWOCOLOR") {
@@ -884,6 +885,13 @@ bool loadConfig(const char *configPath)
portduino_config.configDisplayMode = meshtastic_Config_DisplayConfig_DisplayMode_DEFAULT;
}
}
if (yamlConfig["Config"]["StatusMessage"]) {
portduino_config.has_statusMessage = true;
portduino_config.statusMessage = (yamlConfig["Config"]["StatusMessage"]).as<std::string>("");
}
if ((yamlConfig["Config"]["EnableUDP"]).as<bool>(false)) {
portduino_config.enable_UDP = true;
}
}
if (yamlConfig["General"]) {

View File

@@ -177,8 +177,12 @@ extern struct portduino_config_struct {
int hostMetrics_channel = 0;
// config
bool has_config_overrides = false;
int configDisplayMode = 0;
bool has_configDisplayMode = false;
std::string statusMessage = "";
bool has_statusMessage = false;
bool enable_UDP = false;
// General
std::string mac_address = "";
@@ -505,8 +509,10 @@ extern struct portduino_config_struct {
}
// config
if (has_configDisplayMode) {
if (has_config_overrides) {
out << YAML::Key << "Config" << YAML::Value << YAML::BeginMap;
if (has_configDisplayMode) {
switch (configDisplayMode) {
case meshtastic_Config_DisplayConfig_DisplayMode_TWOCOLOR:
out << YAML::Key << "DisplayMode" << YAML::Value << "TWOCOLOR";
@@ -521,6 +527,13 @@ extern struct portduino_config_struct {
out << YAML::Key << "DisplayMode" << YAML::Value << "DEFAULT";
break;
}
}
if (has_statusMessage) {
out << YAML::Key << "StatusMessage" << YAML::Value << statusMessage;
}
if (enable_UDP) {
out << YAML::Key << "EnableUDP" << YAML::Value << true;
}
out << YAML::EndMap; // Config
}

View File

@@ -1,37 +0,0 @@
#include "watchdogThread.h"
#include "configuration.h"
#ifdef HAS_HARDWARE_WATCHDOG
WatchdogThread *watchdogThread;
WatchdogThread::WatchdogThread() : OSThread("Watchdog")
{
setup();
}
void WatchdogThread::feedDog(void)
{
digitalWrite(HARDWARE_WATCHDOG_DONE, HIGH);
delay(1);
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
}
int32_t WatchdogThread::runOnce()
{
LOG_DEBUG("Feeding hardware watchdog");
feedDog();
return HARDWARE_WATCHDOG_TIMEOUT_MS;
}
bool WatchdogThread::setup()
{
LOG_DEBUG("init hardware watchdog");
pinMode(HARDWARE_WATCHDOG_WAKE, INPUT);
pinMode(HARDWARE_WATCHDOG_DONE, OUTPUT);
delay(1);
digitalWrite(HARDWARE_WATCHDOG_DONE, LOW);
delay(1);
feedDog();
return true;
}
#endif

View File

@@ -1,19 +0,0 @@
#pragma once
#include <stdint.h>
#include "concurrency/OSThread.h"
#ifdef HAS_HARDWARE_WATCHDOG
class WatchdogThread : private concurrency::OSThread
{
public:
WatchdogThread();
void feedDog(void);
virtual bool setup();
virtual int32_t runOnce() override;
};
extern WatchdogThread *watchdogThread;
#endif

View File

@@ -8,7 +8,6 @@ build_flags =
-I variants/esp32/chatter2
-DMESHTASTIC_EXCLUDE_WEBSERVER=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
-ULED_BUILTIN
lib_deps =
${esp32_base.lib_deps}

View File

@@ -14,4 +14,3 @@ build_flags =
${esp32_base.build_flags}
-D DIY_V1
-I variants/esp32/diy/hydra
-ULED_BUILTIN

View File

@@ -17,4 +17,3 @@ build_flags =
-D DIY_V1
-D EBYTE_E22
-I variants/esp32/diy/v1
-ULED_BUILTIN

View File

@@ -14,4 +14,3 @@ build_flags =
${esp32_base.build_flags}
-D NANO_G1_EXPLORER
-I variants/esp32/nano-g1-explorer
-ULED_BUILTIN

View File

@@ -14,4 +14,3 @@ build_flags =
${esp32_base.build_flags}
-D NANO_G1
-I variants/esp32/nano-g1
-ULED_BUILTIN

View File

@@ -9,7 +9,6 @@ build_flags =
-DHAS_STK8XXX=1
-O2
-I variants/esp32/radiomaster_900_bandit
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool
lib_deps =

View File

@@ -13,6 +13,5 @@ build_flags =
-DCONFIG_DISABLE_HAL_LOCKS=1
-O2
-I variants/esp32/radiomaster_900_bandit_nano
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool

View File

@@ -16,6 +16,5 @@ build_flags =
-DCONFIG_DISABLE_HAL_LOCKS=1
-O2
-I variants/esp32/radiomaster_900_bandit_nano
-ULED_BUILTIN
board_build.f_cpu = 240000000L
upload_protocol = esptool

View File

@@ -14,4 +14,3 @@ build_flags =
${esp32_base.build_flags}
-D STATION_G1
-I variants/esp32/station-g1
-ULED_BUILTIN

View File

@@ -12,7 +12,7 @@ extends = esp32_base
board = ttgo-lora32-v21
board_check = true
build_flags =
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16 -ULED_BUILTIN
${esp32_base.build_flags} -D TLORA_V2_1_16 -I variants/esp32/tlora_v2_1_16
upload_speed = 115200
[env:sugarcube]

View File

@@ -7,4 +7,3 @@ build_flags =
-I variants/esp32/tlora_v2_1_16
-D LORA_TCXO_GPIO=12
-D BUTTON_PIN=0
-ULED_BUILTIN

View File

@@ -6,5 +6,4 @@ board_build.partitions = default_8MB.csv
build_flags =
${esp32s3_base.build_flags} -I variants/esp32s3/heltec_capsule_sensor_v3
-D HELTEC_CAPSULE_SENSOR_V3
-ULED_BUILTIN
;-D DEBUG_DISABLED ; uncomment this line to disable DEBUG output

View File

@@ -7,7 +7,6 @@ build_flags =
${esp32s3_base.build_flags}
-I variants/esp32s3/heltec_sensor_hub
-D HELTEC_SENSOR_HUB
-ULED_BUILTIN
lib_deps = ${esp32s3_base.lib_deps}
# renovate: datasource=custom.pio depName=NeoPixel packageName=adafruit/library/Adafruit NeoPixel

View File

@@ -17,4 +17,3 @@ build_flags =
${esp32s3_base.build_flags}
-D HELTEC_WSL_V3
-I variants/esp32s3/heltec_wsl_v3
-ULED_BUILTIN

View File

@@ -39,15 +39,15 @@ extern "C" {
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
#define PIN_LED1 (32 + 15) // green (confirmed on 1.0 board)
#define PIN_LED1 (0 + 4) // green (confirmed on 1.0 board)
#define LED_BLUE PIN_LED1 // fake for bluefruit library
#define LED_GREEN PIN_LED1
#define LED_STATE_ON 0 // State when LED is lit
// #define HAS_NEOPIXEL // Enable the use of neopixels
// #define NEOPIXEL_COUNT 1 // How many neopixels are connected
// #define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
// #define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
#define HAS_NEOPIXEL // Enable the use of neopixels
#define NEOPIXEL_COUNT 1 // How many neopixels are connected
#define NEOPIXEL_DATA (32 + 15) // gpio pin used to send data to the neopixels
#define NEOPIXEL_TYPE (NEO_GRB + NEO_KHZ800) // type of neopixels in use
/*
* Buttons
@@ -59,8 +59,8 @@ extern "C" {
/*
No longer populated on PCB
*/
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
#define PIN_SERIAL2_RX (0 + 9)
#define PIN_SERIAL2_TX (0 + 10)
/*
* I2C
@@ -137,12 +137,6 @@ No longer populated on PCB
// To debug via the segger JLINK console rather than the CDC-ACM serial device
// #define USE_SEGGER
// Hardware watchdog
#define HAS_HARDWARE_WATCHDOG
#define HARDWARE_WATCHDOG_DONE (0 + 9)
#define HARDWARE_WATCHDOG_WAKE (0 + 10)
#define HARDWARE_WATCHDOG_TIMEOUT_MS (6*60*1000) // 6 minute watchdog
#define BQ4050_SDA_PIN (32 + 1) // I2C data line pin
#define BQ4050_SCL_PIN (32 + 0) // I2C clock line pin
#define BQ4050_EMERGENCY_SHUTDOWN_PIN (32 + 3) // Emergency shutdown pin