From 6979326340c3ff800d9a20642ccfa006f03a2a63 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Thu, 7 May 2026 16:51:03 +1000 Subject: [PATCH] * CMD_SET_FLOOD_SCOPE_KEY, now with second variant for explicitly sending un-scoped * FIRMWARE_VER_CODE bumped to 12 --- examples/companion_radio/MyMesh.cpp | 33 ++++++++++++++++++++--------- examples/companion_radio/MyMesh.h | 3 ++- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 71ba4abeb6..d439b2cbc4 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -495,19 +495,27 @@ void MyMesh::sendFloodScoped(const TransportKey& scope, mesh::Packet* pkt, uint3 void MyMesh::sendFloodScoped(const ContactInfo& recipient, mesh::Packet* pkt, uint32_t delay_millis) { // TODO: dynamic send_scope, depending on recipient and current 'home' Region - TransportKey default_scope; - memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key)); + if (send_unscoped) { + sendFlood(pkt, delay_millis, _prefs.path_hash_mode + 1); // app has explicitly requested un-scoped + } else { + TransportKey default_scope; + memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key)); - auto scope = send_scope.isNull() ? &default_scope : &send_scope; - sendFloodScoped(*scope, pkt, delay_millis); + auto scope = send_scope.isNull() ? &default_scope : &send_scope; + sendFloodScoped(*scope, pkt, delay_millis); + } } void MyMesh::sendFloodScoped(const mesh::GroupChannel& channel, mesh::Packet* pkt, uint32_t delay_millis) { // TODO: have per-channel send_scope - TransportKey default_scope; - memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key)); + if (send_unscoped) { + sendFlood(pkt, delay_millis, _prefs.path_hash_mode + 1); // app has explicitly requested un-scoped + } else { + TransportKey default_scope; + memcpy(&default_scope.key, _prefs.default_scope_key, sizeof(default_scope.key)); - auto scope = send_scope.isNull() ? &default_scope : &send_scope; - sendFloodScoped(*scope, pkt, delay_millis); + auto scope = send_scope.isNull() ? &default_scope : &send_scope; + sendFloodScoped(*scope, pkt, delay_millis); + } } void MyMesh::onMessageRecv(const ContactInfo &from, mesh::Packet *pkt, uint32_t sender_timestamp, @@ -856,6 +864,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe dirty_contacts_expiry = 0; memset(advert_paths, 0, sizeof(advert_paths)); memset(send_scope.key, 0, sizeof(send_scope.key)); + send_unscoped = false; // defaults memset(&_prefs, 0, sizeof(_prefs)); @@ -1885,10 +1894,14 @@ void MyMesh::handleCmdFrame(size_t len) { } } else if (cmd_frame[0] == CMD_SET_FLOOD_SCOPE_KEY && len >= 2 && cmd_frame[1] == 0) { if (len >= 2 + 16) { - memcpy(send_scope.key, &cmd_frame[2], sizeof(send_scope.key)); // set curr scope TransportKey + memcpy(send_scope.key, &cmd_frame[2], sizeof(send_scope.key)); // set scope override TransportKey } else { - memset(send_scope.key, 0, sizeof(send_scope.key)); // set scope to null + memset(send_scope.key, 0, sizeof(send_scope.key)); // reset scope override } + send_unscoped = false; + writeOKFrame(); + } else if (cmd_frame[0] == CMD_SET_FLOOD_SCOPE_KEY && len >= 2 && cmd_frame[1] == 1) { // ver 12+ + send_unscoped = true; writeOKFrame(); } else if (cmd_frame[0] == CMD_SET_DEFAULT_FLOOD_SCOPE && len >= 1) { if (len >= 1+31+16) { diff --git a/examples/companion_radio/MyMesh.h b/examples/companion_radio/MyMesh.h index aeff591cf4..f6a4ce40e9 100644 --- a/examples/companion_radio/MyMesh.h +++ b/examples/companion_radio/MyMesh.h @@ -5,7 +5,7 @@ #include "AbstractUITask.h" /*------------ Frame Protocol --------------*/ -#define FIRMWARE_VER_CODE 11 +#define FIRMWARE_VER_CODE 12 #ifndef FIRMWARE_BUILD_DATE #define FIRMWARE_BUILD_DATE "19 Apr 2026" @@ -215,6 +215,7 @@ class MyMesh : public BaseChatMesh, public DataStoreHost { uint32_t _active_ble_pin; bool _iter_started; bool _cli_rescue; + bool send_unscoped; // force un-scoped flood (instead of using send_scope) char cli_command[80]; uint8_t app_target_ver; uint8_t *sign_data;