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
commands_handler.h
1#pragma once
2
4#include "control_status.h"
5#include "remote_command.h"
7#include <cstddef>
8#include <esp_http_server.h>
9
18{
19public:
30 CommandsWebSocketHandler(httpd_handle_t server_handle, const char* uri, BaseDetectionModule* detection = nullptr,
31 const BaseStatusProvider* status = nullptr, remote::BaseRemoteSink* remote = nullptr,
32 const StreamBroadcaster* stream = nullptr);
33
35
37 void register_endpoint();
38
41
43 static constexpr size_t kMaxMessage = 64;
44
46 static esp_err_t pre_handshake(httpd_req_t* req);
47
49 static esp_err_t post_handshake(httpd_req_t* req);
50
53 static esp_err_t websocket_handler(httpd_req_t* req);
54
55private:
57 size_t build_reply(char* out, size_t size) const;
58
59 httpd_handle_t _server_handle;
60 const char* _uri;
61 BaseDetectionModule* _detection_instance;
62 const BaseStatusProvider* _status_provider;
64 const StreamBroadcaster* _stream;
65};
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
void register_endpoint()
Registers the WebSocket endpoint on the server.
Definition commands_handler.cpp:26
static constexpr size_t kMaxMessage
Longest accepted message in bytes; the longest real command ("move:down-right") is 15.
Definition commands_handler.h:43
static esp_err_t websocket_handler(httpd_req_t *req)
httpd callback for /commands: parses one text frame and sends the JSON reply (the handshake goes to t...
Definition commands_handler.cpp:59
static esp_err_t pre_handshake(httpd_req_t *req)
ws_pre_handshake_cb: refuses pages from other origins before the 101 upgrade reply (ESP_FAIL refuses)...
Definition commands_handler.cpp:47
void unregister_endpoint()
Removes the endpoint from the server.
Definition commands_handler.cpp:41
static esp_err_t post_handshake(httpd_req_t *req)
ws_post_handshake_cb: logs the new session once it is a WebSocket.
Definition commands_handler.cpp:52
CommandsWebSocketHandler(httpd_handle_t server_handle, const char *uri, BaseDetectionModule *detection=nullptr, const BaseStatusProvider *status=nullptr, remote::BaseRemoteSink *remote=nullptr, const StreamBroadcaster *stream=nullptr)
Definition commands_handler.cpp:16
Definition stream_broadcaster.h:27
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.
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,...