From ed589f9620cf7a97c62ae64e9e42e48aca1375aa Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 26 Jan 2026 22:20:36 +1300 Subject: [PATCH 1/3] boot adverts are now zero hop instead of flood --- examples/simple_repeater/MyMesh.cpp | 8 ++++++-- examples/simple_repeater/MyMesh.h | 2 +- examples/simple_repeater/main.cpp | 4 ++-- examples/simple_room_server/MyMesh.cpp | 8 ++++++-- examples/simple_room_server/MyMesh.h | 2 +- examples/simple_room_server/main.cpp | 4 ++-- examples/simple_sensor/SensorMesh.cpp | 8 ++++++-- examples/simple_sensor/SensorMesh.h | 2 +- examples/simple_sensor/main.cpp | 4 ++-- src/helpers/CommonCLI.cpp | 3 ++- src/helpers/CommonCLI.h | 2 +- 11 files changed, 30 insertions(+), 17 deletions(-) diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index b838bdcb..2d905511 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -854,10 +854,14 @@ bool MyMesh::formatFileSystem() { #endif } -void MyMesh::sendSelfAdvertisement(int delay_millis) { +void MyMesh::sendSelfAdvertisement(int delay_millis, bool flood) { mesh::Packet *pkt = createSelfAdvert(); if (pkt) { - sendFlood(pkt, delay_millis); + if (flood) { + sendFlood(pkt, delay_millis); + } else { + sendZeroHop(pkt, delay_millis); + } } else { MESH_DEBUG_PRINTLN("ERROR: unable to create advertisement packet!"); } diff --git a/examples/simple_repeater/MyMesh.h b/examples/simple_repeater/MyMesh.h index 38eb658d..60d22902 100644 --- a/examples/simple_repeater/MyMesh.h +++ b/examples/simple_repeater/MyMesh.h @@ -187,7 +187,7 @@ public: void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override; bool formatFileSystem() override; - void sendSelfAdvertisement(int delay_millis) override; + void sendSelfAdvertisement(int delay_millis, bool flood) override; void updateAdvertTimer() override; void updateFloodAdvertTimer() override; diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 8c745613..d7e10fe2 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -87,8 +87,8 @@ void setup() { ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION); #endif - // send out initial Advertisement to the mesh - the_mesh.sendSelfAdvertisement(16000); + // send out initial zero hop Advertisement to the mesh + the_mesh.sendSelfAdvertisement(16000, false); } void loop() { diff --git a/examples/simple_room_server/MyMesh.cpp b/examples/simple_room_server/MyMesh.cpp index bb62e618..22a3d208 100644 --- a/examples/simple_room_server/MyMesh.cpp +++ b/examples/simple_room_server/MyMesh.cpp @@ -675,10 +675,14 @@ bool MyMesh::formatFileSystem() { #endif } -void MyMesh::sendSelfAdvertisement(int delay_millis) { +void MyMesh::sendSelfAdvertisement(int delay_millis, bool flood) { mesh::Packet *pkt = createSelfAdvert(); if (pkt) { - sendFlood(pkt, delay_millis); + if (flood) { + sendFlood(pkt, delay_millis); + } else { + sendZeroHop(pkt, delay_millis); + } } else { MESH_DEBUG_PRINTLN("ERROR: unable to create advertisement packet!"); } diff --git a/examples/simple_room_server/MyMesh.h b/examples/simple_room_server/MyMesh.h index f6adf01e..4f3ed0e4 100644 --- a/examples/simple_room_server/MyMesh.h +++ b/examples/simple_room_server/MyMesh.h @@ -177,7 +177,7 @@ public: void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) override; bool formatFileSystem() override; - void sendSelfAdvertisement(int delay_millis) override; + void sendSelfAdvertisement(int delay_millis, bool flood) override; void updateAdvertTimer() override; void updateFloodAdvertTimer() override; diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 1a3b4d6e..2c76ba0c 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -76,8 +76,8 @@ void setup() { ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION); #endif - // send out initial Advertisement to the mesh - the_mesh.sendSelfAdvertisement(16000); + // send out initial zero hop Advertisement to the mesh + the_mesh.sendSelfAdvertisement(16000, false); } void loop() { diff --git a/examples/simple_sensor/SensorMesh.cpp b/examples/simple_sensor/SensorMesh.cpp index 201532b9..8e27323e 100644 --- a/examples/simple_sensor/SensorMesh.cpp +++ b/examples/simple_sensor/SensorMesh.cpp @@ -787,10 +787,14 @@ void SensorMesh::applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t revert_radio_at = futureMillis(2000 + timeout_mins*60*1000); // schedule when to revert radio params } -void SensorMesh::sendSelfAdvertisement(int delay_millis) { +void SensorMesh::sendSelfAdvertisement(int delay_millis, bool flood) { mesh::Packet* pkt = createSelfAdvert(); if (pkt) { - sendFlood(pkt, delay_millis); + if (flood) { + sendFlood(pkt, delay_millis); + } else { + sendZeroHop(pkt, delay_millis); + } } else { MESH_DEBUG_PRINTLN("ERROR: unable to create advertisement packet!"); } diff --git a/examples/simple_sensor/SensorMesh.h b/examples/simple_sensor/SensorMesh.h index 6046a1df..eb2d90c5 100644 --- a/examples/simple_sensor/SensorMesh.h +++ b/examples/simple_sensor/SensorMesh.h @@ -60,7 +60,7 @@ public: NodePrefs* getNodePrefs() { return &_prefs; } void savePrefs() override { _cli.savePrefs(_fs); } bool formatFileSystem() override; - void sendSelfAdvertisement(int delay_millis) override; + void sendSelfAdvertisement(int delay_millis, bool flood) override; void updateAdvertTimer() override; void updateFloodAdvertTimer() override; void setLoggingOn(bool enable) override { } diff --git a/examples/simple_sensor/main.cpp b/examples/simple_sensor/main.cpp index a5fcc148..ab2842e0 100644 --- a/examples/simple_sensor/main.cpp +++ b/examples/simple_sensor/main.cpp @@ -110,8 +110,8 @@ void setup() { ui_task.begin(the_mesh.getNodePrefs(), FIRMWARE_BUILD_DATE, FIRMWARE_VERSION); #endif - // send out initial Advertisement to the mesh - the_mesh.sendSelfAdvertisement(16000); + // send out initial zero hop Advertisement to the mesh + the_mesh.sendSelfAdvertisement(16000, false); } void loop() { diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index a8dd9d09..db830285 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -197,7 +197,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch if (memcmp(command, "reboot", 6) == 0) { _board->reboot(); // doesn't return } else if (memcmp(command, "advert", 6) == 0) { - _callbacks->sendSelfAdvertisement(1500); // longer delay, give CLI response time to be sent first + // send flood advert + _callbacks->sendSelfAdvertisement(1500, true); // longer delay, give CLI response time to be sent first strcpy(reply, "OK - Advert sent"); } else if (memcmp(command, "clock sync", 10) == 0) { uint32_t curr = getRTCClock()->getCurrentTime(); diff --git a/src/helpers/CommonCLI.h b/src/helpers/CommonCLI.h index b0530102..8661d1e6 100644 --- a/src/helpers/CommonCLI.h +++ b/src/helpers/CommonCLI.h @@ -61,7 +61,7 @@ public: virtual const char* getBuildDate() = 0; virtual const char* getRole() = 0; virtual bool formatFileSystem() = 0; - virtual void sendSelfAdvertisement(int delay_millis) = 0; + virtual void sendSelfAdvertisement(int delay_millis, bool flood) = 0; virtual void updateAdvertTimer() = 0; virtual void updateFloodAdvertTimer() = 0; virtual void setLoggingOn(bool enable) = 0; From d13bc446de689277ce59208c9bcac90ad8e58453 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 26 Jan 2026 22:39:39 +1300 Subject: [PATCH 2/3] added build flag to enable/disable boot advert --- examples/simple_repeater/main.cpp | 2 ++ examples/simple_room_server/main.cpp | 2 ++ examples/simple_secure_chat/main.cpp | 2 ++ examples/simple_sensor/main.cpp | 2 ++ platformio.ini | 1 + 5 files changed, 9 insertions(+) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index d7e10fe2..d55d6118 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -88,7 +88,9 @@ void setup() { #endif // send out initial zero hop Advertisement to the mesh +#if ENABLE_ADVERT_ON_BOOT == 1 the_mesh.sendSelfAdvertisement(16000, false); +#endif } void loop() { diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 2c76ba0c..825fb007 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -77,7 +77,9 @@ void setup() { #endif // send out initial zero hop Advertisement to the mesh +#if ENABLE_ADVERT_ON_BOOT == 1 the_mesh.sendSelfAdvertisement(16000, false); +#endif } void loop() { diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index da1bac5b..018ec2a2 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -582,7 +582,9 @@ void setup() { the_mesh.showWelcome(); // send out initial Advertisement to the mesh +#if ENABLE_ADVERT_ON_BOOT == 1 the_mesh.sendSelfAdvert(1200); // add slight delay +#endif } void loop() { diff --git a/examples/simple_sensor/main.cpp b/examples/simple_sensor/main.cpp index ab2842e0..330adcc2 100644 --- a/examples/simple_sensor/main.cpp +++ b/examples/simple_sensor/main.cpp @@ -111,7 +111,9 @@ void setup() { #endif // send out initial zero hop Advertisement to the mesh +#if ENABLE_ADVERT_ON_BOOT == 1 the_mesh.sendSelfAdvertisement(16000, false); +#endif } void loop() { diff --git a/platformio.ini b/platformio.ini index 75d37e86..743e357a 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,6 +27,7 @@ build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1 -DRADIOLIB_GODMODE=1 -D LORA_FREQ=869.525 -D LORA_BW=250 -D LORA_SF=11 + -D ENABLE_ADVERT_ON_BOOT=1 -D ENABLE_PRIVATE_KEY_IMPORT=1 ; NOTE: comment these out for more secure firmware -D ENABLE_PRIVATE_KEY_EXPORT=1 -D RADIOLIB_EXCLUDE_CC1101=1 From 7e24bd00b9f768f3c537a0514263b85257fdffb4 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 26 Jan 2026 23:05:10 +1300 Subject: [PATCH 3/3] increase maximum flood advert interval to 168 hours (7 days) --- src/helpers/CommonCLI.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index db830285..93baad5b 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -422,8 +422,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch strcpy(reply, "OK"); } else if (memcmp(config, "flood.advert.interval ", 22) == 0) { int hours = _atoi(&config[22]); - if ((hours > 0 && hours < 3) || (hours > 48)) { - strcpy(reply, "Error: interval range is 3-48 hours"); + if ((hours > 0 && hours < 3) || (hours > 168)) { + strcpy(reply, "Error: interval range is 3-168 hours"); } else { _prefs->flood_advert_interval = (uint8_t)(hours); _callbacks->updateFloodAdvertTimer();