From 7ded1c3b123a06d852db17ccd0e38287370df461 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 14 Mar 2024 19:46:17 -0500 Subject: [PATCH 1/3] NodeInfo broadcasts ensure defaults on 0 and enforce 1 hour minumum --- src/mesh/NodeDB.cpp | 13 ++----------- src/mesh/NodeDB.h | 2 ++ src/modules/AdminModule.cpp | 5 +++++ src/modules/NodeInfoModule.cpp | 3 +-- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 9d7647138f..6898f77025 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -101,16 +101,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset) // devicestate.no_save = true; if (devicestate.no_save) { LOG_DEBUG("***** DEVELOPMENT MODE - DO NOT RELEASE *****\n"); - - // Sleep quite frequently to stress test the BLE comms, broadcast position every 6 mins - config.display.screen_on_secs = 10; - config.power.wait_bluetooth_secs = 10; - config.position.position_broadcast_secs = 6 * 60; - config.power.ls_secs = 60; - config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_TW; - - // Enter super deep sleep soon and stay there not very long - // radioConfig.preferences.sds_secs = 60; + // Put your development config changes here } // Update the global myRegion @@ -199,7 +190,7 @@ void NodeDB::installDefaultConfig() config.position.broadcast_smart_minimum_distance = 100; config.position.broadcast_smart_minimum_interval_secs = 30; if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER) - config.device.node_info_broadcast_secs = 3 * 60 * 60; + config.device.node_info_broadcast_secs = default_node_info_broadcast_secs; config.device.serial_enabled = true; resetRadioConfig(); strncpy(config.network.ntp_server, "0.pool.ntp.org", 32); diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 20cc5c25b2..616f745280 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -203,6 +203,8 @@ extern NodeDB nodeDB; #define default_ls_secs IF_ROUTER(ONE_DAY, 5 * 60) #define default_min_wake_secs 10 #define default_screen_on_secs IF_ROUTER(1, 60 * 10) +#define default_node_info_broadcast_secs (3 * 60 * 60) +#define min_node_info_broadcast_secs (60 * 60) // No regular broadcasts of more than once an hour #define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_username "meshdev" diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index abd7c2e548..4828df5255 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -302,6 +302,11 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) // If we're setting router role for the first time, install its intervals if (existingRole != c.payload_variant.device.role) nodeDB.installRoleDefaults(c.payload_variant.device.role); + if (config.device.node_info_broadcast_secs < min_node_info_broadcast_secs) { + LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d\n", + config.device.min_node_info_broadcast_secs); + config.device.node_info_broadcast_secs = min_node_info_broadcast_secs; + } break; case meshtastic_Config_position_tag: LOG_INFO("Setting config: Position\n"); diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index b0b4bbdcd0..5177af33a8 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -91,6 +91,5 @@ int32_t NodeInfoModule::runOnce() LOG_INFO("Sending our nodeinfo to mesh (wantReplies=%d)\n", requestReplies); sendOurNodeInfo(NODENUM_BROADCAST, requestReplies); // Send our info (don't request replies) } - - return getConfiguredOrDefaultMs(config.device.node_info_broadcast_secs, default_broadcast_interval_secs); + return getConfiguredOrDefaultMs(config.device.node_info_broadcast_secs, default_node_info_broadcast_secs); } From 95d5dfc3d4754b06beb81a5e40c5cb666c10f8c1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 14 Mar 2024 20:00:45 -0500 Subject: [PATCH 2/3] Doh! --- src/mesh/NodeDB.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 616f745280..6f2aab8968 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -48,8 +48,8 @@ class NodeDB meshtastic_NodeInfoLite *meshNodes; pb_size_t *numMeshNodes; - public: - bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled +public: + bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled meshtastic_NodeInfoLite *updateGUIforNode = NULL; // if currently showing this node, we think you should update the GUI Observable newStatus; @@ -135,7 +135,8 @@ class NodeDB void setLocalPosition(meshtastic_Position position, bool timeOnly = false) { - if (timeOnly) { + if (timeOnly) + { LOG_DEBUG("Setting local position time only: time=%i\n", position.time); localPosition.time = position.time; return; @@ -145,7 +146,7 @@ class NodeDB localPosition = position; } - private: +private: /// Find a node in our DB, create an empty NodeInfoLite if missing meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n); @@ -191,7 +192,7 @@ extern NodeDB nodeDB; // Our delay functions check for this for times that should never expire #define NODE_DELAY_FOREVER 0xffffffff -#define IF_ROUTER(routerVal, normalVal) \ +#define IF_ROUTER(routerVal, normalVal) \ ((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) ? (routerVal) : (normalVal)) #define ONE_DAY 24 * 60 * 60 @@ -203,8 +204,8 @@ extern NodeDB nodeDB; #define default_ls_secs IF_ROUTER(ONE_DAY, 5 * 60) #define default_min_wake_secs 10 #define default_screen_on_secs IF_ROUTER(1, 60 * 10) -#define default_node_info_broadcast_secs (3 * 60 * 60) -#define min_node_info_broadcast_secs (60 * 60) // No regular broadcasts of more than once an hour +#define default_node_info_broadcast_secs 3 * 60 * 60 +#define min_node_info_broadcast_secs 60 * 60 // No regular broadcasts of more than once an hour #define default_mqtt_address "mqtt.meshtastic.org" #define default_mqtt_username "meshdev" @@ -252,7 +253,7 @@ extern meshtastic_CriticalErrorCode error_code; */ extern uint32_t error_address; -#define Module_Config_size \ - (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ - ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ +#define Module_Config_size \ + (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ + ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_TelemetryConfig_size + ModuleConfig_size) \ No newline at end of file From fdbbfeaa2ed9e6408730fb1ab8576cf34dd4f1b1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 14 Mar 2024 20:14:07 -0500 Subject: [PATCH 3/3] Hey that's not on config! --- src/mesh/NodeDB.h | 17 ++++++++--------- src/modules/AdminModule.cpp | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 6f2aab8968..b34059fb9a 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -48,8 +48,8 @@ class NodeDB meshtastic_NodeInfoLite *meshNodes; pb_size_t *numMeshNodes; -public: - bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled + public: + bool updateGUI = false; // we think the gui should definitely be redrawn, screen will clear this once handled meshtastic_NodeInfoLite *updateGUIforNode = NULL; // if currently showing this node, we think you should update the GUI Observable newStatus; @@ -135,8 +135,7 @@ class NodeDB void setLocalPosition(meshtastic_Position position, bool timeOnly = false) { - if (timeOnly) - { + if (timeOnly) { LOG_DEBUG("Setting local position time only: time=%i\n", position.time); localPosition.time = position.time; return; @@ -146,7 +145,7 @@ class NodeDB localPosition = position; } -private: + private: /// Find a node in our DB, create an empty NodeInfoLite if missing meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n); @@ -192,7 +191,7 @@ extern NodeDB nodeDB; // Our delay functions check for this for times that should never expire #define NODE_DELAY_FOREVER 0xffffffff -#define IF_ROUTER(routerVal, normalVal) \ +#define IF_ROUTER(routerVal, normalVal) \ ((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) ? (routerVal) : (normalVal)) #define ONE_DAY 24 * 60 * 60 @@ -253,7 +252,7 @@ extern meshtastic_CriticalErrorCode error_code; */ extern uint32_t error_address; -#define Module_Config_size \ - (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ - ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ +#define Module_Config_size \ + (ModuleConfig_CannedMessageConfig_size + ModuleConfig_ExternalNotificationConfig_size + ModuleConfig_MQTTConfig_size + \ + ModuleConfig_RangeTestConfig_size + ModuleConfig_SerialConfig_size + ModuleConfig_StoreForwardConfig_size + \ ModuleConfig_TelemetryConfig_size + ModuleConfig_size) \ No newline at end of file diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 4828df5255..06818dc882 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -303,8 +303,7 @@ void AdminModule::handleSetConfig(const meshtastic_Config &c) if (existingRole != c.payload_variant.device.role) nodeDB.installRoleDefaults(c.payload_variant.device.role); if (config.device.node_info_broadcast_secs < min_node_info_broadcast_secs) { - LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d\n", - config.device.min_node_info_broadcast_secs); + LOG_DEBUG("Tried to set node_info_broadcast_secs too low, setting to %d\n", min_node_info_broadcast_secs); config.device.node_info_broadcast_secs = min_node_info_broadcast_secs; } break;