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
CommandsWebSocketHandler Class Reference

The /commands WebSocket: parses each HUD message, hands it to the remote sink and replies with JSON metrics. More...

#include <commands_handler.h>

Public Member Functions

 CommandsWebSocketHandler (httpd_handle_t server_handle, const char *uri, BaseDetectionModule *detection=nullptr, const BaseStatusProvider *status=nullptr, remote::BaseRemoteSink *remote=nullptr, const StreamBroadcaster *stream=nullptr)
 
void register_endpoint ()
 Registers the WebSocket endpoint on the server.
 
void unregister_endpoint ()
 Removes the endpoint from the server.
 

Static Public Member Functions

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).
 
static esp_err_t post_handshake (httpd_req_t *req)
 ws_post_handshake_cb: logs the new session once it is a WebSocket.
 
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 the pre/post hooks, never here).
 

Static Public Attributes

static constexpr size_t kMaxMessage = 64
 Longest accepted message in bytes; the longest real command ("move:down-right") is 15.
 

Detailed Description

The /commands WebSocket: parses each HUD message, hands it to the remote sink and replies with JSON metrics.

Request/reply: every received text frame gets exactly one JSON reply (the HUD's poll loop depends on it). Receive and reply buffers live on the httpd task's stack (64 B and hud::kReplySize), so there is no heap use per message and nothing to leak when a send fails.

Constructor & Destructor Documentation

◆ CommandsWebSocketHandler()

CommandsWebSocketHandler::CommandsWebSocketHandler ( httpd_handle_t server_handle,
const char * uri,
BaseDetectionModule * detection = nullptr,
const BaseStatusProvider * status = nullptr,
remote::BaseRemoteSink * remote = nullptr,
const StreamBroadcaster * stream = nullptr )
Parameters
server_handleRunning httpd server to register the endpoint on.
uriEndpoint path (must outlive the handler; a string literal).
detectionOptional detection module for the tracker fields.
statusOptional controller status for the mode/calibration fields.
remoteOptional sink that receives the parsed commands (the Controller).
streamOptional /stream broadcaster whose viewer count is sent as "vw" (0 when null). Must outlive the handler; StreamBroadcaster::viewer_count() is safe to call from the httpd task (but not concurrently with StreamBroadcaster::stop(), so httpd must be stopped first).

The documentation for this class was generated from the following files: