#ifndef HTTP_SERVER_H #define HTTP_SERVER_H #include #include #include "ShutterController.h" /// /// HTTP server for handling Minolta remote control API requests. /// Manages WiFi access point configuration, HTTP routes, and request handling /// for camera control operations like focus, shutter, and multiple shots. /// class HTTPServer { private: /// Pointer to the AsyncWebServer instance AsyncWebServer* server; /// Pointer to the ShutterController interface for camera control IShutterController* shutterController; /// Registers all HTTP API endpoints and their handlers void setupRoutes(); /// /// Handles GET / request to serve the home page. /// Returns a simple HTML control interface for the camera remote. /// /// Async web server request object void handleRoot(AsyncWebServerRequest *request); /// /// Handles GET /api/focus request to perform a half press (focus). /// /// Async web server request object void handleFocus(AsyncWebServerRequest *request); /// /// Handles GET /api/takePhoto request to take a photo with optional delay. /// Accepts optional query parameter "msec" for photo hold duration. /// /// Async web server request object void handleTakePhoto(AsyncWebServerRequest *request); /// /// Handles GET /api/reset request to release the shutter and return to neutral position. /// /// Async web server request object void handleReset(AsyncWebServerRequest *request); /// /// Handles GET /api/multiple request to take multiple photos in sequence. /// Accepts query parameters: "count" (number of photos) and "delay" (ms between shots). /// Optional parameter "msec" specifies duration of each shot. /// /// Async web server request object void handleMultiple(AsyncWebServerRequest *request); /// /// Handles GET /api/healthcheck request as a health check endpoint. /// /// Async web server request object void handleHealthCheck(AsyncWebServerRequest *request); /// /// Logs the start of a request processing and enables the status LED. /// /// Name of the API endpoint being processed void onRequestStart(const char* endpoint); /// /// Logs the completion of a request processing and disables the status LED. /// /// Name of the API endpoint that was processed void onRequestEnd(const char* endpoint); public: /// /// Constructs an HTTPServer instance. /// /// HTTP server port number (typically 80) /// Pointer to ShutterController for camera operations HTTPServer(uint16_t port, IShutterController* controller); /// /// Destructor that cleans up the AsyncWebServer instance. /// ~HTTPServer(); /// /// Initializes the WiFi access point and starts the HTTP server. /// Must be called during application setup. /// /// WiFi network name /// WiFi network password /// Static IP address for the access point /// Gateway IP address /// Subnet mask void begin(const char* ssid, const char* password, IPAddress local_IP, IPAddress gateway, IPAddress subnet); /// /// Configures the ESP8266 as a WiFi access point with the specified credentials. /// /// WiFi network name /// WiFi network password /// Static IP address for the access point /// Gateway IP address /// Subnet mask void setupWiFiAP(const char* ssid, const char* password, IPAddress local_IP, IPAddress gateway, IPAddress subnet); }; #endif // HTTP_SERVER_H