Include runtime ESP-NOW in Full ESP32 repeaters
This commit is contained in:
1 parent
6cd1289c8b
commit
69d9ac84bc
21 files changed
+1098
-104
No files matched your search
@@ -3472,6 +3472,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
#endif
|
||||
#elif defined(WITH_ESPNOW_BRIDGE)
|
||||
, bridge(&_prefs, _mgr, &rtc)
|
||||
, shared_espnow_retry_at(0)
|
||||
#endif
|
||||
{
|
||||
// Global constructors run before setup(), while the heap is still
|
||||
@@ -3663,6 +3664,12 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
_prefs.espnow_bridge_enabled = 0; // merged normal repeater until explicitly enabled
|
||||
#else
|
||||
_prefs.espnow_bridge_enabled = 1; // preserves the Full image's former combined default
|
||||
#endif
|
||||
#if defined(WITH_ESPNOW_BRIDGE) && defined(ESPNOW_BRIDGE_MERGED) \
|
||||
&& !defined(WITH_MQTT_BRIDGE) && !defined(WITH_RS232_BRIDGE)
|
||||
// The sole transport keeps its legacy primary lifecycle, while merged
|
||||
// profiles persist the same explicit ESP-NOW intent as combined profiles.
|
||||
_prefs.bridge_enabled = _prefs.espnow_bridge_enabled;
|
||||
#endif
|
||||
_prefs.bridge_delay = 500; // milliseconds
|
||||
_prefs.bridge_pkt_src = 1; // logRx (RX packets)
|
||||
@@ -12835,6 +12842,7 @@ void __attribute__((noinline)) MyMesh::servicePostMeshLoop() {
|
||||
else startSharedEspNowBridgeIfReady();
|
||||
#else
|
||||
if (bridge.isRunning()) bridge.loop();
|
||||
else startSharedEspNowBridgeIfReady();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(WITH_RS232_BRIDGE) \
|
||||
|
||||
@@ -592,6 +592,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
#endif
|
||||
#elif defined(WITH_ESPNOW_BRIDGE)
|
||||
ESPNowBridge bridge;
|
||||
uint32_t shared_espnow_retry_at = 0;
|
||||
#endif
|
||||
#ifdef WITH_BRIDGE
|
||||
AbstractBridge* activeBridge() {
|
||||
@@ -614,13 +615,18 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WITH_ESPNOW_BRIDGE) \
|
||||
&& (defined(WITH_MQTT_BRIDGE) || defined(WITH_RS232_BRIDGE))
|
||||
#if defined(WITH_ESPNOW_BRIDGE)
|
||||
// Retry ESP-NOW without taking over an active OTA session. MQTT creates its
|
||||
// WiFi task asynchronously, so it must first associate on the shared channel.
|
||||
bool startSharedEspNowBridgeIfReady() {
|
||||
if (espnow_bridge.isRunning()) return true;
|
||||
#if defined(WITH_MQTT_BRIDGE) || defined(WITH_RS232_BRIDGE)
|
||||
ESPNowBridge& transport = espnow_bridge;
|
||||
if (!_prefs.espnow_bridge_enabled) return false;
|
||||
#else
|
||||
ESPNowBridge& transport = bridge;
|
||||
if (!_prefs.bridge_enabled) return false;
|
||||
#endif
|
||||
if (transport.isRunning()) return true;
|
||||
// Browser OTA pauses the bridges for the entire upload session. The
|
||||
// periodic retry must not undo that pause on its next loop iteration.
|
||||
if (_cli.getBoard()->isOTAUpdateRunning()) return false;
|
||||
@@ -629,9 +635,9 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks
|
||||
#endif
|
||||
if (!millisHasNowPassed(shared_espnow_retry_at)) return false;
|
||||
shared_espnow_retry_at = millis() + 5000;
|
||||
configureBridgeFilter(&espnow_bridge);
|
||||
espnow_bridge.begin();
|
||||
return espnow_bridge.isRunning();
|
||||
configureBridgeFilter(&transport);
|
||||
transport.begin();
|
||||
return transport.isRunning();
|
||||
}
|
||||
#endif
|
||||
#ifdef WITH_SNMP
|
||||
@@ -1386,6 +1392,12 @@ public:
|
||||
? setEspNowBridgeState(true) : setEspNowBridgeState(false);
|
||||
return mqtt_ok && espnow_ok;
|
||||
#else
|
||||
#if defined(WITH_ESPNOW_BRIDGE) && !defined(WITH_RS232_BRIDGE)
|
||||
// A standalone bridge shares its WiFi driver with the browser uploader.
|
||||
// Preserve saved intent, but do not restart it until OTA has stopped.
|
||||
if (enable && _cli.getBoard()->isOTAUpdateRunning()) return false;
|
||||
shared_espnow_retry_at = 0;
|
||||
#endif
|
||||
// Disabling an already-absent heap-backed bridge is successful and must
|
||||
// not allocate an instance merely to stop it. The embedded ESP-NOW bridge
|
||||
// is always present, so it continues through the normal state check.
|
||||
@@ -1477,6 +1489,10 @@ public:
|
||||
#endif
|
||||
return restartEspNowBridge() && restartMqttBridge();
|
||||
#else
|
||||
#if defined(WITH_ESPNOW_BRIDGE) && !defined(WITH_RS232_BRIDGE)
|
||||
if (_cli.getBoard()->isOTAUpdateRunning()) return false;
|
||||
shared_espnow_retry_at = 0;
|
||||
#endif
|
||||
#ifdef WITH_RS232_BRIDGE
|
||||
// RS-232 changes must be applied synchronously so the CLI can commit or
|
||||
// roll back the selected pins/baud. This branch also reconstructs a bridge
|
||||
|
||||
Reference in new issue
Block a user