Files
MeshCore/test/fixtures/webconfig_station_owner.cpp
T
mikecarper 73c5f572eb Apply busy radio settings and recover service starts automatically
Save valid busy RX, fast-switch and Companion tuple changes once, then
apply the latest accepted intent at a safe radio gap. Preserve checked-save
rollback, runtime RXEN intent, TempRadio ownership and exact remote reply
delivery. Repair failed preamble compensation without hiding uncertain saves.

Retry WebConfig, MQTT and NimBLE startup failures automatically. Preserve
explicit off choices, OTA ownership and the latest WiFi credentials through
cooperative shutdown. Add regression coverage and update command guides.

Validation: focused host transaction, rollback, ownership and lifecycle suites;
Full RAK4631, Heltec V4 R8 TFT and RC32 packages; representative room, sensor,
LR1110, LR2021, SX1276, STM32WL and ESP-NOW builds. Linked RAK crypto and OTA
workspace checks pass; its complete OTA image uses 712644/712704 bytes.
2026-10-25 15:20:55 -07:00

74 lines
2.5 KiB
C++

#include <cassert>
#include <cstring>
#include <new>
#include <helpers/WirelessControl.h>
struct Worker {
bool running = false, stopping = false;
bool isRunning() const { return running; }
bool isStopping() const { return stopping; }
};
struct Board {
bool isOTAUpdateRunning() const { return false; }
const char* getManufacturerName() const { return "Station G2"; }
} board;
struct CLI {
Board* getBoard() { return &board; }
void* getObserverPrefs() { return this; }
};
struct WebConfigServer {
bool owns, constructor_owns;
WebConfigServer(void*, void*, bool owner, const unsigned char*,
const char*, const char*, const char*, const char*, bool canonical)
: owns(owner), constructor_owns(owner) { assert(canonical); }
bool isRunning() const { return false; }
bool isStopping() const { return false; }
void updateWiFiOwnership(bool owner) { owns = owner; }
void requestNetworkAccess() {}
bool requestStart(bool ap, char* reply) { return ap ? startSetupMode(reply) : startAutoMode(reply); }
bool startAutoMode(char* reply) { strcpy(reply, "starting"); return true; }
bool startSetupMode(char* reply) { strcpy(reply, "setup"); return true; }
};
struct MyMesh {
Worker* @WORKER@ = nullptr;
CLI _cli;
WebConfigServer* _webconfig = nullptr;
bool _unconfigured_setup_espnow_suspended = false;
bool isMqttBridgeRunning() const { return @WORKER@ && @WORKER@->isRunning(); }
bool isMqttBridgeStopping() const { return @WORKER@ && @WORKER@->isStopping(); }
struct { unsigned char pub_key[32] = {}; } self_id;
const char* getFirmwareVer() const { return "test"; }
const char* getBuildDate() const { return "test"; }
const char* getRole() const { return "test"; }
bool startWebConfig(bool force_ap, char* reply);
bool startWebConfigImpl(bool force_ap, char* reply, bool automatic_setup);
bool webConfigOwnsWiFi() const;
void suspendUnconfiguredSetupBridges();
void refresh() {
@REFRESH@
}
};
@START@
@SUSPEND@
int main() {
MyMesh mesh;
Worker worker;
mesh.@WORKER@ = &worker;
char reply[160] = {};
mesh.startWebConfig(false, reply);
assert(mesh._webconfig->constructor_owns && mesh._webconfig->owns);
worker.running = true;
mesh.refresh();
assert(!mesh._webconfig->owns);
worker.running = false;
worker.stopping = true;
mesh.refresh();
assert(!mesh._webconfig->owns);
worker.stopping = false;
mesh.refresh();
assert(mesh._webconfig->owns);
mesh.@WORKER@ = nullptr;
mesh.refresh();
assert(mesh._webconfig->owns);
delete mesh._webconfig;
}