Codex added unified library, all work

This commit is contained in:
John Poole 2026-04-19 10:20:35 -07:00
commit 8370e546ff
25 changed files with 2935 additions and 0 deletions

View file

@ -0,0 +1,89 @@
; Repository-level hardware test for tbeam_web.
[platformio]
default_envs = cy
extra_configs = ../../shared/platformio/tbeam_supreme_units.ini
[web_files_base]
extends = tbeam_supreme_common
build_flags =
${tbeam_supreme_common.build_flags}
-D WEB_FILES_TEST=1
[env:amy]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"AMY\"
-D NODE_LABEL=\"Amy\"
-D NODE_SHORT=\"A\"
-D NODE_SLOT_INDEX=0
-D LOG_AP_IP_OCTET=23
-D GNSS_CHIP_NAME=\"L76K\"
[env:bob]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"BOB\"
-D NODE_LABEL=\"Bob\"
-D NODE_SHORT=\"B\"
-D NODE_SLOT_INDEX=1
-D LOG_AP_IP_OCTET=24
-D GNSS_CHIP_NAME=\"L76K\"
[env:cy]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"CY\"
-D NODE_LABEL=\"Cy\"
-D NODE_SHORT=\"C\"
-D NODE_SLOT_INDEX=2
-D LOG_AP_IP_OCTET=25
-D GNSS_CHIP_NAME=\"L76K\"
[env:dan]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"DAN\"
-D NODE_LABEL=\"Dan\"
-D NODE_SHORT=\"D\"
-D NODE_SLOT_INDEX=3
-D LOG_AP_IP_OCTET=26
-D GNSS_CHIP_NAME=\"L76K\"
[env:ed]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"ED\"
-D NODE_LABEL=\"Ed\"
-D NODE_SHORT=\"E\"
-D NODE_SLOT_INDEX=4
-D LOG_AP_IP_OCTET=27
-D GNSS_CHIP_NAME=\"L76K\"
[env:flo]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"FLO\"
-D NODE_LABEL=\"Flo\"
-D NODE_SHORT=\"F\"
-D NODE_SLOT_INDEX=5
-D LOG_AP_IP_OCTET=28
-D GNSS_CHIP_NAME=\"L76K\"
[env:guy]
extends = web_files_base
build_flags =
${web_files_base.build_flags}
-D BOARD_ID=\"GUY\"
-D NODE_LABEL=\"Guy\"
-D NODE_SHORT=\"G\"
-D NODE_SLOT_INDEX=6
-D LOG_AP_IP_OCTET=29
-D GNSS_CHIP_NAME=\"MAX-M10S\"
-D GPS_UBLOX

View file

@ -0,0 +1,132 @@
#include <Arduino.h>
#include <TBeamClock.h>
#include <TBeamDisplay.h>
#include <TBeamLogger.h>
#include <TBeamStorage.h>
#include <TBeamWeb.h>
#ifndef BOARD_ID
#define BOARD_ID "UNKNOWN"
#endif
#ifndef NODE_LABEL
#define NODE_LABEL "Unknown"
#endif
#ifndef LOG_AP_IP_OCTET
#define LOG_AP_IP_OCTET 25
#endif
namespace {
tbeam::TBeamClock clockService(Wire1);
tbeam::TBeamDisplay display;
tbeam::TBeamStorage storage(Serial);
tbeam::TBeamLogger Log;
tbeam::TBeamWeb web(Serial);
uint32_t sampleSeq = 0;
uint32_t lastSampleMs = 0;
uint32_t lastDisplayMs = 0;
void openWebLog() {
if (!storage.ready()) {
Serial.printf("Web log skipped: storage error=%s\r\n", storage.lastError());
return;
}
bool opened = false;
if (clockService.valid()) {
char runId[64];
char path[112];
tbeam::TBeamClock::makeRunId(clockService.lastRtc(), BOARD_ID, runId, sizeof(runId));
snprintf(path, sizeof(path), "%s/%s.csv", storage.logDir(), runId);
opened = Log.openLog(path);
}
if (!opened) {
opened = Log.openUniqueLog(BOARD_ID, ".csv");
}
if (!opened) {
Serial.printf("Web log open failed: %s\r\n", storage.lastError());
return;
}
Log.printf("# test: web_files\r\n");
Log.printf("# board_id: %s\r\n", BOARD_ID);
Log.printf("# node_label: %s\r\n", NODE_LABEL);
Log.printf("# log_path: %s\r\n", Log.currentLogPath());
Log.println("seq,millis,web_ready,stations,sd_ready,rtc_valid,free_heap");
Log.flush();
Serial.printf("Web log opened: %s\r\n", Log.currentLogPath());
}
void drawStatus() {
char ipLine[32];
char webLine[32];
char sdLine[32];
char logLine[32];
snprintf(ipLine, sizeof(ipLine), "%s", web.ip().toString().c_str());
snprintf(webLine, sizeof(webLine), "AP: %s", web.ssid());
snprintf(sdLine, sizeof(sdLine), "SD:%s STA:%u", storage.ready() ? "ok" : "bad", (unsigned)web.stationCount());
snprintf(logLine, sizeof(logLine), "Log:%s", Log.storageReady() ? "open" : "serial");
display.showLines("Web Files", webLine, ipLine, sdLine, logLine, BOARD_ID);
}
} // namespace
void setup() {
Serial.begin(115200);
delay(1500);
Serial.println();
Serial.printf("web files test boot board=%s label=%s\r\n", BOARD_ID, NODE_LABEL);
display.begin();
display.showBoot("Web Files", BOARD_ID, "starting services");
tbeam::StorageConfig storageConfig;
storageConfig.logDir = "/logs/web";
storageConfig.enablePinDumps = false;
storage.begin(storageConfig);
Log.begin(Serial, &storage);
clockService.begin();
openWebLog();
tbeam::WebConfig webConfig;
webConfig.ssidPrefix = "GPSQA";
webConfig.boardId = BOARD_ID;
webConfig.ipOctet = LOG_AP_IP_OCTET;
webConfig.enableDelete = true;
web.begin(storage, webConfig);
Serial.printf("Web UI: http://%s/\r\n", web.ip().toString().c_str());
Serial.printf("SSID: %s\r\n", web.ssid());
drawStatus();
}
void loop() {
storage.update();
clockService.update();
web.update();
Log.update();
const uint32_t now = millis();
if ((uint32_t)(now - lastSampleMs) >= 1000) {
lastSampleMs = now;
Log.printf("%lu,%lu,%s,%u,%s,%s,%lu\r\n",
(unsigned long)sampleSeq++,
(unsigned long)now,
web.ready() ? "yes" : "no",
(unsigned)web.stationCount(),
storage.ready() ? "yes" : "no",
clockService.valid() ? "yes" : "no",
(unsigned long)ESP.getFreeHeap());
}
if ((uint32_t)(now - lastDisplayMs) >= 2500) {
lastDisplayMs = now;
drawStatus();
}
}