Address safety review findings for the dual-interface (WiFi + USB serial) architecture running on the ESP32-S3's two Xtensa LX7 cores: - Protect sweep state with std::atomic (acquire/release ordering) - Add Attenuator::getSnapshot() for consistent multi-field reads - Add advanceStep()/persistCurrent() to eliminate TOCTOU races - Switch to StaticSemaphore_t (compile-time mutex, can't fail) - Accumulate web server POST bodies before parsing (chunked TCP fix) - Backport USB serial input validation to web server handlers - Auto-stop sweep on manual set (prevents silent overwrite) - Validate WiFi TX power against known-good levels - Add OTA password authentication support - Check NVS write return values, log failures - Reset USB serial buffer on reconnect (stale overflow fix) - Rename sweep.h to app.h (declares more than sweep functions)
28 lines
641 B
C
28 lines
641 B
C
#pragma once
|
|
|
|
// Shared declarations for functions defined in main.cpp
|
|
// Used by web_server.cpp and usb_serial.cpp
|
|
|
|
#include <Arduino.h>
|
|
#include <WiFi.h>
|
|
|
|
// --- Sweep control ---
|
|
void startSweep(bool up, uint32_t dwellMs);
|
|
void stopSweep();
|
|
bool isSweeping();
|
|
int8_t getSweepDirection();
|
|
uint32_t getSweepDwellMs();
|
|
|
|
// --- OTA ---
|
|
void enableOTA();
|
|
bool isOTAEnabled();
|
|
|
|
// --- WiFi TX power ---
|
|
void setWiFiTxPower(wifi_power_t power);
|
|
wifi_power_t getWiFiTxPower();
|
|
float wifiPowerToDbm(wifi_power_t power);
|
|
bool isValidWifiPower(int raw);
|
|
const int* getValidWifiPowers();
|
|
const float* getValidWifiDbms();
|
|
int getNumWifiPowerLevels();
|