content: six real code exhibits, rendered by the panel (AUD-152)

This commit is contained in:
Sam Rolfe
2026-10-28 16:00:06 +11:00
parent 2ceb0c147c
commit 36d8e514d4
11 changed files with 296 additions and 25 deletions

View File

@@ -0,0 +1,31 @@
// Two files from firmware/src/hw, reproduced verbatim: WiFiMgr.hpp (the
// interface) and WiFiMgr.cpp (the implementation). The boundary is marked.
// WiFiMgr.hpp — the interface the rest of the firmware depends on
// WiFiMgr.hpp
#pragma once
#include <Arduino.h>
namespace WiFiMgr {
bool connectHome(const char* ssid, const char* psk, uint32_t timeoutMs = 15000);
void disconnect();
}
// WiFiMgr.cpp — the only translation unit that includes <WiFi.h>
// WiFiMgr.cpp
#include "WiFiMgr.hpp"
#include <WiFi.h> // ESP32 WiFi
namespace WiFiMgr {
bool connectHome(const char* ssid, const char* psk, uint32_t timeoutMs) {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, psk);
uint32_t t0 = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
delay(200);
}
return WiFi.status() == WL_CONNECTED;
}
void disconnect() {
WiFi.disconnect(true, true);
WiFi.mode(WIFI_OFF);
}
}