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

Manages the ESP32-CAM web interface and control API. More...

#include <turret_server.h>

Public Member Functions

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 only, own task so a stalled video send cannot block /commands replies).
 
uint32_t frames_sent () const
 Frames successfully sent to /stream viewers since boot.
 
StreamBroadcaster::SendStats take_send_stats ()
 /stream send timing (see StreamBroadcaster::SendStats); resets the window max.
 
size_t viewer_count () const
 Number of currently connected /stream viewers.
 
void stop ()
 Shut down both servers and unregister all URI handlers.
 

Static Public Member Functions

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 accesses the root IP address. It serves the primary web interface stored in Flash memory.
 

Detailed Description

Manages the ESP32-CAM web interface and control API.

This class wraps the ESP-IDF HTTP server component. It provides a video stream endpoint and a command endpoint for remote movement.

Member Function Documentation

◆ index_handler()

esp_err_t HttpServer::index_handler ( httpd_req_t * req)
static

HTTP handler for the root ("/") URI. This method is called by the ESP HTTP server whenever a client accesses the root IP address. It serves the primary web interface stored in Flash memory.

HTTP GET handler for the root ("/") URI. This function serves the primary web interface of the turret. To optimize memory usage and transmission speed, it sends a Gzip-compressed HTML payload.

Parameters
reqPointer to the HTTP request object containing session data.
Returns
esp_err_t Returns ESP_OK if the response was sent successfully, otherwise returns an error code from the underlying HTTP server.
See also
index_html.h
Parameters
[in]reqPointer to the HTTP request context provided by the ESP-IDF server.
Returns
  • ESP_OK: The index page was sent successfully.
  • ESP_FAIL: There was an error sending the response.
  • ESP_ERR_HTTPD_RESP_SEND: Specifically indicates a failure in the response send call.

◆ start()

bool HttpServer::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 only, own task so a stalled video send cannot block /commands replies).

Parameters
storeFrameStore the /stream endpoint reads frames from. Must outlive the server.
detectionOptional pointer to detection module for motion visualization.
statusOptional status provider (the Controller); when null the mode/calibration fields are omitted.
remoteOptional sink for the HUD's /commands messages (the Controller); when null they are ignored.
wifiOptional WiFi manager; when set, the setup page, its JSON API and the captive-portal catch-all are registered (after all other routes).
Returns
true if the server was created and handlers were registered.

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