Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
turret_server.h
Go to the documentation of this file.
1
6#pragma once
7
9#include "commands_handler.h"
10#include "control_status.h"
11#include "frame_store.h"
12#include "remote_command.h"
13#include "stream_broadcaster.h"
14#include <esp_http_server.h>
15
16class WifiManager;
17
25{
26private:
27 static httpd_handle_t _server_handle;
28 static httpd_handle_t _stream_handle;
29
33 static BaseDetectionModule* _detection_instance;
34
36 static const BaseStatusProvider* _status_instance;
37
38 CommandsWebSocketHandler* _commands_handler; // Used both for commands to the motors & sending metrics
39 StreamBroadcaster _broadcaster; // Pushes frames from the FrameStore to /stream viewers
40
41public:
42 HttpServer();
44
56 bool start(FrameStore& store, BaseDetectionModule* detection = nullptr, const BaseStatusProvider* status = nullptr,
57 remote::BaseRemoteSink* remote = nullptr, WifiManager* wifi = nullptr);
58
60 uint32_t frames_sent() const { return _broadcaster.frames_sent(); }
61
64
66 size_t viewer_count() const { return _broadcaster.viewer_count(); }
67
71 void stop();
72
83 static esp_err_t index_handler(httpd_req_t* req);
84};
Abstract interface for object detection logic on ESP32-CAM.
An abstract base class (Interface) that defines the contract for detection algorithms....
Definition base_detection_module.h:22
Interface for anything that can report a ControlStatus (the Controller). Lets the network layer read ...
Definition control_status.h:46
The /commands WebSocket: parses each HUD message, hands it to the remote sink and replies with JSON m...
Definition commands_handler.h:18
Definition frame_store.h:30
Manages the ESP32-CAM web interface and control API.
Definition turret_server.h:25
size_t viewer_count() const
Number of currently connected /stream viewers.
Definition turret_server.h:66
StreamBroadcaster::SendStats take_send_stats()
/stream send timing (see StreamBroadcaster::SendStats); resets the window max.
Definition turret_server.h:63
uint32_t frames_sent() const
Frames successfully sent to /stream viewers since boot.
Definition turret_server.h:60
bool start(FrameStore &store, BaseDetectionModule *detection=nullptr, const BaseStatusProvider *status=nullptr, remote::BaseRemoteSink *remote=nullptr, WifiManager *wifi=nullptr)
Configures and launches the web servers: port 80 (page, /commands, WiFi API) and port 81 (/stream onl...
Definition turret_server.cpp:33
void stop()
Shut down both servers and unregister all URI handlers.
Definition turret_server.cpp:102
static esp_err_t index_handler(httpd_req_t *req)
HTTP handler for the root ("/") URI. This method is called by the ESP HTTP server whenever a client a...
Definition turret_server.cpp:133
Definition stream_broadcaster.h:27
SendStats take_send_stats()
The send counters; resets max_us. For the stats line (one reader).
Definition stream_broadcaster.cpp:88
size_t viewer_count() const
Connected /stream viewers (0 to frames::kMaxViewers).
Definition stream_broadcaster.cpp:96
Glue between the pure prov::WifiPlan and the Arduino WiFi stack.
Definition wifi_manager.h:40
Receives parsed commands; implemented by the controller (device) and fakes (tests).
Definition remote_command.h:54
Read-only view of the controller state for the HUD and stats line.
Thread-safe home for camera frames: FrameSlots bookkeeping + fixed PSRAM buffers, allocated once.
Parses the HUD's /commands text messages into typed commands (pure C++20, natively tested).
Pushes the latest camera frame to each idle /stream WebSocket viewer (drop-when-busy,...
How long frame sends block the httpd task (every /stream send runs on it, and so does /commands).
Definition stream_broadcaster.h:48