add files
This commit is contained in:
1 parent
3eaff3a647
commit
e76a9c1e9b
9 files changed
+752
No files matched your search
@@ -0,0 +1,45 @@
|
||||
// =====================================================================
|
||||
// WebServerManager.h
|
||||
//
|
||||
// Wi-Fi + HTTP REST API + WebSocket live feed, ported from the
|
||||
// ESP32-LD2450 project's AsyncWebServer/AsyncWebSocket setup.
|
||||
// Protocol-agnostic: only ever touches RadarFrame/RadarTarget and
|
||||
// ZoneManager, never raw radar bytes.
|
||||
// =====================================================================
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "LD2453Parser.h"
|
||||
#include "ZoneManager.h"
|
||||
|
||||
class WebServerManager {
|
||||
public:
|
||||
WebServerManager(ZoneManager &zoneManager);
|
||||
|
||||
// Blocks briefly (via delay in the WiFi connect retry loop only,
|
||||
// as in the original project) until Wi-Fi is up, then starts the
|
||||
// HTTP + WebSocket server. Call once from setup().
|
||||
void begin(const char *ssid, const char *password);
|
||||
|
||||
// Non-blocking. Call every loop() iteration: reconnects Wi-Fi if
|
||||
// dropped, and prunes disconnected WebSocket clients.
|
||||
void loop();
|
||||
|
||||
// Broadcasts one normalized JSON payload (see README "Web Data
|
||||
// Format") to all connected WebSocket clients for this frame.
|
||||
// No-op if no clients are connected.
|
||||
void broadcastFrame(const RadarFrame &frame);
|
||||
|
||||
bool isWifiConnected() const { return WiFi.status() == WL_CONNECTED; }
|
||||
|
||||
private:
|
||||
ZoneManager &_zoneManager;
|
||||
AsyncWebServer _server;
|
||||
AsyncWebSocket _ws;
|
||||
|
||||
void setupRoutes();
|
||||
static void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client,
|
||||
AwsEventType type, void *arg, uint8_t *data, size_t len);
|
||||
};
|
||||
Reference in new issue
Block a user