Merge mcarper/keymindCascade into mqtt-observer-plus
Integrates Mike Carper's transmission-reliability work (direct retries with SNR-adaptive backoff and CR, flood retry controls, alt-path replies, flood channel gates) plus its upstream/dev base (as of 2026-07-06) on top of the observer stack. The flex branch is untouched; this branch is the experimental integration line. Conflict-resolution decisions, for future re-syncs (git rerere is enabled and has recorded these): - NodePrefs adopts keymind/upstream member order + retry/flood tail. Member order is in-memory only: /com_prefs stays field-by-field with the same canonical file order both sides already share through offset 294; keymind appends the retry tail at 295+ (new canonical size 676). Flex fleet files load unchanged; retry fields default via direct_retry_prefs_magic. - loadPrefsInt keeps the fork's legacy MQTT-gap recovery but moves its detection boundary from 'extra > 5' to 'extra > LEGACY_MQTT_GAP_3SLOT (864)' so keymind-size tails take the normal read path. COM_PREFS_TAIL_BYTES retired. - Dispatcher/RadioLibWrappers: fork watchdog additions + keymind TX overrides and CAD busy counter are unioned; RxReservePacketManager::queueOutbound follows upstream's new bool return (false when shedding). - CommonCLI: fork observer dispatch + versioned /mqtt_prefs machinery kept; keymind CLI (retry/flood/radioat) taken; duplicate CAD/FEM handlers and sanitise lines deduped (kept keymind placements to minimize future diff). - MyMesh (repeater/room): fork alerter/OTA/observer wiring kept; keymind scheduled-radio system replaces the old pending_* temp-radio members; applySavedRadioParams() replaces raw setParams at startup. - ESP32Board: fork manifest-OTA + keymind powerOff/deepSleep and stopOTAUpdate unioned; startOTAUpdate keeps fork's STA-aware IP with keymind's idempotency guard. - build.sh taken wholesale from keymind (fleet builds use GH Actions). Verified: Heltec_v3_repeater_observer_mqtt, Heltec_v3_repeater, heltec_v4_repeater_observer_mqtt, Heltec_v3_room_server_observer_mqtt build; host migration harness (13 MQTT + non-MQTT scenarios) passes with updated expectations (676-byte /com_prefs; odd-size files normalize on save, not load); native unit tests 13/13.
This commit is contained in:
commit
b88dc02b66
216 files changed
+31361
-1172
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include "ESP32Board.h"
|
||||
#include <target.h>
|
||||
|
||||
#if defined(ADMIN_PASSWORD) && !defined(DISABLE_WIFI_OTA) // Repeater or Room Server only
|
||||
#include <WiFi.h>
|
||||
@@ -13,6 +14,12 @@
|
||||
bool ESP32Board::startOTAUpdate(const char* id, char reply[]) {
|
||||
inhibit_sleep = true; // prevent sleep during OTA
|
||||
|
||||
if (ota_server != nullptr) { // already running (idempotent restart)
|
||||
IPAddress cur_ip = (WiFi.status() == WL_CONNECTED) ? WiFi.localIP() : WiFi.softAPIP();
|
||||
sprintf(reply, "Started: http://%s/update", cur_ip.toString().c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the device is already on a WiFi network (e.g. an observer joined in STA
|
||||
// mode), serve ElegantOTA on the station IP so it's reachable from the LAN
|
||||
// without joining a separate AP. Otherwise raise the MeshCore-OTA SoftAP.
|
||||
@@ -32,18 +39,36 @@ bool ESP32Board::startOTAUpdate(const char* id, char reply[]) {
|
||||
static char home_buf[90];
|
||||
sprintf(home_buf, "<H2>Hi! I am a MeshCore Repeater. ID: %s</H2>", id);
|
||||
|
||||
AsyncWebServer* server = new AsyncWebServer(80);
|
||||
ota_server = new AsyncWebServer(80);
|
||||
|
||||
server->on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
ota_server->on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(200, "text/html", home_buf);
|
||||
});
|
||||
server->on("/log", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
ota_server->on("/log", HTTP_GET, [](AsyncWebServerRequest *request) {
|
||||
request->send(SPIFFS, "/packet_log", "text/plain");
|
||||
});
|
||||
|
||||
AsyncElegantOTA.setID(id_buf);
|
||||
AsyncElegantOTA.begin(server); // Start ElegantOTA
|
||||
server->begin();
|
||||
AsyncElegantOTA.begin(ota_server); // Start ElegantOTA
|
||||
ota_server->begin();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ESP32Board::stopOTAUpdate(char reply[]) {
|
||||
if (ota_server == nullptr) {
|
||||
strcpy(reply, "OK - OTA not running");
|
||||
return true;
|
||||
}
|
||||
|
||||
ota_server->end();
|
||||
delete ota_server;
|
||||
ota_server = nullptr;
|
||||
WiFi.softAPdisconnect(true);
|
||||
inhibit_sleep = false;
|
||||
|
||||
strcpy(reply, "OK - OTA stopped");
|
||||
MESH_DEBUG_PRINTLN("stopOTAUpdate: %s", reply);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -52,6 +77,10 @@ bool ESP32Board::startOTAUpdate(const char* id, char reply[]) {
|
||||
bool ESP32Board::startOTAUpdate(const char* id, char reply[]) {
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
bool ESP32Board::stopOTAUpdate(char reply[]) {
|
||||
return false; // not supported
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -419,4 +448,47 @@ bool ESP32Board::otaFromManifest(const char* current_ver, bool dry_run, char rep
|
||||
}
|
||||
#endif // WITH_MQTT_BRIDGE
|
||||
|
||||
void ESP32Board::powerOff() {
|
||||
enterDeepSleep(0); // Do not wakeup
|
||||
}
|
||||
|
||||
void ESP32Board::enterDeepSleep(uint32_t secs) {
|
||||
// Power off the display if any
|
||||
#ifdef DISPLAY_CLASS
|
||||
display.turnOff();
|
||||
#endif
|
||||
|
||||
// Power off LoRa
|
||||
radio_driver.powerOff();
|
||||
|
||||
#ifdef P_LORA_NSS
|
||||
// Keep LoRa inactive during deepsleep
|
||||
digitalWrite(P_LORA_NSS, HIGH);
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||
gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
#else
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Power off GPS if any
|
||||
if (sensors.getLocationProvider() != NULL) {
|
||||
sensors.getLocationProvider()->stop();
|
||||
}
|
||||
|
||||
// Flush serial buffers
|
||||
Serial.flush();
|
||||
delay(100);
|
||||
|
||||
// Clear stale wakeup sources to avoid ghost wakeup
|
||||
// This is required when Power Management and automatic lightsleep are enabled
|
||||
esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_ALL);
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000ULL);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into deepsleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user