feat(net): start wifi after Lua and keep the radio transient

The driver is started once the runtime has allocated, so its first init faces
the same heap as every later one; against a pristine boot heap it wins blocks
that cannot be reassembled. Only the boot sync powers the radio down, so an
explicit connect stays up. Polling a powered-off driver silently re-inits it,
which is what spammed esp_wifi_init failures, so status and loop now check the
mode first. A failed new otherwise reboots with a bare backtrace; the handler
logs the heap instead.
This commit is contained in:
2026-08-04 13:11:23 -04:00
parent fce0dfb70a
commit af53a668dc
5 changed files with 94 additions and 24 deletions
+14
View File
@@ -7,6 +7,9 @@
#include <TFT_eSPI.h>
#include <XPT2046_Touchscreen.h>
#include <new>
#include "heaplog.h"
#include "host/lua_host.h"
#include "net.h"
#include "settings.h"
@@ -42,6 +45,16 @@ static void fallbackScreen(const char *message) {
void setup() {
Serial.begin(115200);
// A failed new otherwise unwinds to terminate() and a bare abort backtrace.
// Nothing can be freed at that point, so this only buys a legible cause.
std::set_new_handler([]() {
logHeap("oom");
Serial.println("[fatal] out of memory");
Serial.flush();
ESP.restart();
});
tft.begin();
tft.setRotation(0);
tft.fillScreen(TFT_WHITE);
@@ -58,6 +71,7 @@ void setup() {
net::begin();
if (!host.begin())
fallbackScreen("home failed to start");
net::startWifi();
}
void loop() {