From aaf78d829fddb9133332563c1638cd3a62a26843 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Tue, 1 Jul 2025 10:58:43 -0500 Subject: [PATCH] Trigger a NodeStatus update at the end of setup() to get fresh data on display at boot. --- src/main.cpp | 3 +++ src/mesh/NodeDB.h | 16 ++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ddc1df28c..fbdbf641a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1430,6 +1430,9 @@ void setup() LOG_DEBUG("Free heap : %7d bytes", ESP.getFreeHeap()); LOG_DEBUG("Free PSRAM : %7d bytes", ESP.getFreePsram()); #endif + + // We manually run this to update the NodeStatus + nodeDB->notifyObservers(true); } #endif diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 8cf0c78b3..845f42c76 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -285,6 +285,14 @@ class NodeDB bool restorePreferences(meshtastic_AdminMessage_BackupLocation location, int restoreWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); + /// Notify observers of changes to the DB + void notifyObservers(bool forceUpdate = false) + { + // Notify observers of the current node state + const meshtastic::NodeStatus status = meshtastic::NodeStatus(getNumOnlineMeshNodes(), getNumMeshNodes(), forceUpdate); + newStatus.notifyObservers(&status); + } + private: bool duplicateWarned = false; uint32_t lastNodeDbSave = 0; // when we last saved our db to flash @@ -301,14 +309,6 @@ class NodeDB /// pick a provisional nodenum we hope no one is using void pickNewNodeNum(); - /// Notify observers of changes to the DB - void notifyObservers(bool forceUpdate = false) - { - // Notify observers of the current node state - const meshtastic::NodeStatus status = meshtastic::NodeStatus(getNumOnlineMeshNodes(), getNumMeshNodes(), forceUpdate); - newStatus.notifyObservers(&status); - } - /// read our db from flash void loadFromDisk();