diff --git a/src/MyMesh.cpp b/src/MyMesh.cpp index e400bdd..1ff8815 100644 --- a/src/MyMesh.cpp +++ b/src/MyMesh.cpp @@ -4559,6 +4559,20 @@ void MyMesh::handleCmdFrame(size_t len) { char *np = strchr(sp, ':'); // look for separator char if (np) { *np++ = 0; // modify 'cmd_frame', replace ':' with null + // #256: "ble.rxlog:1" opts THIS session's BLE companion into the full + // per-packet RX log (0x88). It is not a sensor setting, so intercept it + // before the sensor dispatch below. Coverage/region apps need it because + // the transport codes and the full relay path exist only in that frame — + // RESP_CODE_CHANNEL_MSG_RECV_V3 carries neither. Off by default and never + // persisted, so the #46/#54 fix stands for everyone who does not ask. + // Requested by the KiekR author (marcelverdult), who traced it for us. +#if defined(ESP32) && defined(MULTI_TRANSPORT_COMPANION) + if (strcmp(sp, "ble.rxlog") == 0) { + MultiTransportCompanionInterface::bleSetRxLogFirehose(np[0] == '1'); + writeOKFrame(); + return; + } +#endif bool success = sensors.setSettingValue(sp, np); if (success) { #if ENV_INCLUDE_GPS == 1 diff --git a/src/helpers/esp32/MultiTransportCompanionInterface.cpp b/src/helpers/esp32/MultiTransportCompanionInterface.cpp index ef9e4ba..d1986f5 100644 --- a/src/helpers/esp32/MultiTransportCompanionInterface.cpp +++ b/src/helpers/esp32/MultiTransportCompanionInterface.cpp @@ -11,6 +11,7 @@ #define PUSH_CODE_LOG_RX_DATA 0x88 bool MultiTransportCompanionInterface::s_ble_rxlog_once = false; +bool MultiTransportCompanionInterface::s_ble_rxlog_all = false; // #256: opt-in, per session MultiTransportCompanionInterface::MultiTransportCompanionInterface() : _tcp_port(0), _ws_port(0), _tcp_started(false), _ws_started(false), _tcp_enabled(true), _isEnabled(false), _broadcast(false), _last_reply_target(REPLY_TARGET_USB), _ota_tcp_suspended(false), _ota_ws_suspended(false), _ota_ws_listen_paused(false) @@ -548,7 +549,11 @@ size_t MultiTransportCompanionInterface::writeFrameToAll(const uint8_t src[], si // blanket skip landed in beta_23 — issue #94), and a few echoes per send are // nowhere near the flood that caused #46/#54. const bool rxlog = (len > 0 && src[0] == PUSH_CODE_LOG_RX_DATA); - const bool ble_pass = rxlog && s_ble_rxlog_once; + // #256: a companion that wants the whole firehose (coverage/region mapping — + // region and the full path exist ONLY in this frame) can ask for it per + // session with CMD_SET_CUSTOM_VAR "ble.rxlog:1". Default stays off, so the + // #46/#54 behaviour above is unchanged for every app that does not opt in. + const bool ble_pass = rxlog && (s_ble_rxlog_once || s_ble_rxlog_all); if (rxlog) s_ble_rxlog_once = false; // consume the one-shot either way const bool skip_ble = rxlog && !ble_pass; if (!skip_ble && _ble_begun && _ble_enabled && _ble.isConnected() && _ble.writeFrame(src, len) != len) diff --git a/src/helpers/esp32/MultiTransportCompanionInterface.h b/src/helpers/esp32/MultiTransportCompanionInterface.h index 03a8a8c..9294db3 100644 --- a/src/helpers/esp32/MultiTransportCompanionInterface.h +++ b/src/helpers/esp32/MultiTransportCompanionInterface.h @@ -94,6 +94,13 @@ public: * gets exactly the few frames the app needs and none of the flood (#94). * Same-thread set-then-consume (both in the mesh loop), so no atomics. */ static void bleAllowNextRxLog() { s_ble_rxlog_once = true; } + /** Opt a BLE companion into the FULL per-packet RX log (#256). + * Off by default and NOT persisted: an app asks for it after connecting, via + * CMD_SET_CUSTOM_VAR "ble.rxlog:1". Deliberately session-scoped — a stored + * flag would silently reinstate the #46/#54 flood for someone who tried a + * coverage app once and moved on, on a link that cannot afford it. */ + static void bleSetRxLogFirehose(bool on) { s_ble_rxlog_all = on; } + static bool bleRxLogFirehose() { return s_ble_rxlog_all; } bool companionUnsolicitedPushesBroadcastToAll() const override { return _broadcast; } size_t checkRecvFrame(uint8_t dest[]) override; @@ -105,6 +112,7 @@ public: private: static bool s_ble_rxlog_once; // one-shot BLE pass for the next RX-log frame (#94) + static bool s_ble_rxlog_all; // app opted into the whole RX log over BLE (#256); session-scoped public: private: