Split MQTT and ESP-NOW controls in Full ESP32 builds
This commit is contained in:
1 parent
6cb1c41eae
commit
b981c5cf88
14 files changed
+337
-108
No files matched your search
@@ -1146,7 +1146,7 @@ void MyMesh::logRx(mesh::Packet *pkt, int len, float score) {
|
||||
#endif
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
// MQTT bridge: always feed RX packets - bridge decides based on mqtt.rx setting
|
||||
if (mqtt_bridge) mqtt_bridge->onPacketReceived(pkt);
|
||||
if (mqtt_bridge && mqtt_bridge->isRunning()) mqtt_bridge->onPacketReceived(pkt);
|
||||
#ifdef WITH_ESPNOW_BRIDGE
|
||||
// ESP-NOW follows bridge.source, independently of MQTT's mqtt.rx policy.
|
||||
ESPNowBridge* espnow = &espnow_bridge;
|
||||
@@ -1198,7 +1198,7 @@ void MyMesh::logTx(mesh::Packet *pkt, int len) {
|
||||
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
// MQTT bridge: always feed TX packets - bridge decides based on mqtt.tx setting
|
||||
if (mqtt_bridge) mqtt_bridge->sendPacket(pkt);
|
||||
if (mqtt_bridge && mqtt_bridge->isRunning()) mqtt_bridge->sendPacket(pkt);
|
||||
#ifdef WITH_ESPNOW_BRIDGE
|
||||
ESPNowBridge* espnow = &espnow_bridge;
|
||||
if (_prefs.bridge_pkt_src == 0 && espnow && espnow->isRunning()) {
|
||||
@@ -3595,6 +3595,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
#else
|
||||
_prefs.bridge_enabled = 1; // enabled
|
||||
#endif
|
||||
_prefs.espnow_bridge_enabled = 1; // preserves the Full image's former combined default
|
||||
_prefs.bridge_delay = 500; // milliseconds
|
||||
_prefs.bridge_pkt_src = 1; // logRx (RX packets)
|
||||
_prefs.bridge_baud = 115200; // baud rate
|
||||
@@ -3792,6 +3793,10 @@ void MyMesh::begin(FILESYSTEM *fs) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_MQTT_BRIDGE) && defined(WITH_ESPNOW_BRIDGE)
|
||||
if (_prefs.espnow_bridge_enabled) setEspNowBridgeState(true);
|
||||
#endif
|
||||
|
||||
// Wire fault-alert reporter. begin() is safe regardless of bridge state.
|
||||
// Passing `this` as the callbacks lets the reporter resolve a TransportKey
|
||||
// scope (alert.region override, falling back to default_scope) so alert
|
||||
@@ -3806,7 +3811,8 @@ void MyMesh::begin(FILESYSTEM *fs) {
|
||||
#ifdef WITH_MQTT_BRIDGE
|
||||
// Preserve the MQTT observer's first-boot setup experience even though the
|
||||
// persistent WebUI master switch defaults off on infrastructure roles.
|
||||
start_webui = start_webui || _cli.getObserverPrefs()->wifi_ssid[0] == 0;
|
||||
start_webui = start_webui || (_prefs.bridge_enabled
|
||||
&& _cli.getObserverPrefs()->wifi_ssid[0] == 0);
|
||||
if (start_webui && _cli.getObserverPrefs()->wifi_ssid[0] == 0) {
|
||||
#if defined(WITH_ESPNOW_BRIDGE)
|
||||
if (espnow_bridge.isRunning()) espnow_bridge.end();
|
||||
@@ -10814,7 +10820,7 @@ void MyMesh::onConfigBatchEnd() {
|
||||
if (_wc_restart_pending) {
|
||||
_wc_restart_pending = false;
|
||||
_wc_slot_restart_mask = 0;
|
||||
if (_prefs.bridge_enabled) restartBridge();
|
||||
if (_prefs.bridge_enabled) restartMqttBridge();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user