Public Access
Add Wi-Fi/TLS heap probe; limit deep+ LDF to native tests
The deep+ dependency finder broke the framework's WiFi -> Network include on the device build; only the native test env needs it. The probe serial command (probe <ssid>TAB<password>) measures heap with Wi-Fi connected and one TLS connection; credentials never touch the repo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// roro9stack firmware entry point: wires Services, Apps and the UI loop together.
|
||||
#include <M5Cardputer.h>
|
||||
#include <NetworkClientSecure.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "app_manager.h"
|
||||
#include "apps/demo_app.h"
|
||||
@@ -101,6 +103,41 @@ void setup() {
|
||||
Serial.printf("%s %s ready, free heap %u\n", kProductName, versionString(), ESP.getFreeHeap());
|
||||
}
|
||||
|
||||
// Dev aid (M1 step 1): heap cost of Wi-Fi and one TLS connection. Credentials come over serial only.
|
||||
static void memoryProbe(const String& ssid, const String& pass) {
|
||||
auto heap = [](const char* stage) {
|
||||
Serial.printf("probe %-18s heap %6u min %6u largest block %6u\n", stage, ESP.getFreeHeap(),
|
||||
ESP.getMinFreeHeap(), heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
|
||||
};
|
||||
heap("before wifi");
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid.c_str(), pass.c_str());
|
||||
uint32_t start = millis();
|
||||
while (WiFi.status() != WL_CONNECTED && millis() - start < 20000) delay(100);
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.printf("probe wifi failed, status %d\n", WiFi.status());
|
||||
heap("wifi failed");
|
||||
WiFi.disconnect(true);
|
||||
return;
|
||||
}
|
||||
Serial.printf("probe wifi connected, rssi %d, ip %s\n", WiFi.RSSI(), WiFi.localIP().toString().c_str());
|
||||
heap("wifi connected");
|
||||
{
|
||||
NetworkClientSecure tls;
|
||||
tls.setInsecure(); // measurement only; M1 verifies certificates
|
||||
if (tls.connect("irc.libera.chat", 6697)) {
|
||||
heap("tls connected");
|
||||
tls.stop();
|
||||
} else {
|
||||
Serial.println("probe tls connect failed");
|
||||
}
|
||||
}
|
||||
heap("tls closed");
|
||||
WiFi.disconnect(true);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
heap("wifi off");
|
||||
}
|
||||
|
||||
// Dev aid: serial commands to drive the UI without the keyboard.
|
||||
static void serialCommands() {
|
||||
static String line;
|
||||
@@ -120,6 +157,10 @@ static void serialCommands() {
|
||||
: k == "right" ? Key::Right : k == "back" ? Key::Back : k == "home" ? Key::Home : Key::Select;
|
||||
if (!power->onKey(millis())) apps->handleKey(KeyEvent::of(key));
|
||||
}
|
||||
if (line.startsWith("probe ")) { // probe <ssid>\t<password>
|
||||
int tab = line.indexOf('\t');
|
||||
if (tab > 0) memoryProbe(line.substring(6, tab), line.substring(tab + 1));
|
||||
}
|
||||
if (line == "sound off") settings.setBool(Setting::Sound, false);
|
||||
if (line == "sound on") settings.setBool(Setting::Sound, true);
|
||||
if (line == "short") {
|
||||
|
||||
Reference in New Issue
Block a user