Complete IoT monitoring platform for Acuvim II power meters via ESP32. Firmware (Phases 1-7): - ESP32-WROVER-B (TTGO T-Call v1.4) with RS485 Modbus RTU - WiFi STA+AP concurrent mode with GSM/GPRS failover - Transport abstraction layer with 4 priority modes - MQTT protocol with 20 commands, LWT, QoS, exponential backoff - SD card offline buffering with JSONL rotation and non-blocking drain - OTA firmware updates with dual partition rollback protection - Watchdog timer, crash loop detection, Acuvim health monitoring - Captive portal provisioning with AP mode Console backend (Phase 8): - .NET 10 minimal API with PostgreSQL + EF Core - JWT authentication, SignalR real-time updates - MQTTnet 5.x bridge service with health monitoring - Device, telemetry, firmware, alert, group management - Rate limiting, security headers, Swagger/OpenAPI Frontend (Phase 9): - React 18 + TypeScript + Vite with Ant Design 5 - ECharts telemetry visualization, TanStack Query - SignalR live updates, device management UI - Dashboard, fleet management, firmware deployment Testing & Production (Phase 10): - 28 firmware unit tests (Modbus, JSON, config, version) - 23 xUnit backend tests (device, telemetry, command, alert) - Docker Compose with nginx, TLS MQTT, PostgreSQL - Production deployment, commissioning, and troubleshooting docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#ifndef WIFI_MANAGER_H
|
|
#define WIFI_MANAGER_H
|
|
|
|
#include <Arduino.h>
|
|
#include <WiFi.h>
|
|
#include <functional>
|
|
|
|
class WifiManager {
|
|
public:
|
|
void begin(const char* ssid, const char* password);
|
|
void loop();
|
|
void disconnect();
|
|
|
|
void startAP(const char* deviceId);
|
|
void stopAP();
|
|
bool isAPActive();
|
|
uint8_t getAPClientCount();
|
|
|
|
void startScan();
|
|
bool isScanComplete();
|
|
String getScanResultsJson();
|
|
|
|
bool isConnected();
|
|
int8_t getRSSI();
|
|
String getIPAddress();
|
|
String getMACAddress();
|
|
String getSSID();
|
|
|
|
void connectTo(const char* ssid, const char* password);
|
|
|
|
void onConnect(std::function<void()> callback) { _onConnect = callback; }
|
|
void onDisconnect(std::function<void()> callback) { _onDisconnect = callback; }
|
|
|
|
private:
|
|
char _ssid[64];
|
|
char _password[64];
|
|
bool _staEnabled;
|
|
bool _wasConnected;
|
|
bool _apActive;
|
|
bool _scanRequested;
|
|
|
|
std::function<void()> _onConnect;
|
|
std::function<void()> _onDisconnect;
|
|
|
|
unsigned long _lastReconnectAttemptMs;
|
|
static const unsigned long RECONNECT_INTERVAL_MS = 30000;
|
|
static const unsigned long CONNECT_TIMEOUT_MS = 15000;
|
|
|
|
void attemptConnect();
|
|
void syncNTP();
|
|
void applyMode();
|
|
};
|
|
|
|
#endif
|