| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #ifndef HTTP_SERVER_H
- #define HTTP_SERVER_H
- #include <ESPAsyncWebServer.h>
- #include <ESP8266WiFi.h>
- #include "ShutterController.h"
- /// <summary>
- /// 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.
- /// </summary>
- class HTTPServer
- {
- private:
- /// <summary>Pointer to the AsyncWebServer instance</summary>
- AsyncWebServer* server;
-
- /// <summary>Pointer to the ShutterController interface for camera control</summary>
- IShutterController* shutterController;
-
- /// <summary>Registers all HTTP API endpoints and their handlers</summary>
- void setupRoutes();
-
- /// <summary>
- /// Handles GET / request to serve the home page.
- /// Returns a simple HTML control interface for the camera remote.
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleRoot(AsyncWebServerRequest *request);
-
- /// <summary>
- /// Handles GET /api/focus request to perform a half press (focus).
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleFocus(AsyncWebServerRequest *request);
-
- /// <summary>
- /// Handles GET /api/takePhoto request to take a photo with optional delay.
- /// Accepts optional query parameter "msec" for photo hold duration.
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleTakePhoto(AsyncWebServerRequest *request);
-
- /// <summary>
- /// Handles GET /api/reset request to release the shutter and return to neutral position.
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleReset(AsyncWebServerRequest *request);
-
- /// <summary>
- /// 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.
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleMultiple(AsyncWebServerRequest *request);
-
- /// <summary>
- /// Handles GET /api/healthcheck request as a health check endpoint.
- /// </summary>
- /// <param name="request">Async web server request object</param>
- void handleHealthCheck(AsyncWebServerRequest *request);
-
- /// <summary>
- /// Logs the start of a request processing and enables the status LED.
- /// </summary>
- /// <param name="endpoint">Name of the API endpoint being processed</param>
- void onRequestStart(const char* endpoint);
-
- /// <summary>
- /// Logs the completion of a request processing and disables the status LED.
- /// </summary>
- /// <param name="endpoint">Name of the API endpoint that was processed</param>
- void onRequestEnd(const char* endpoint);
-
- public:
- /// <summary>
- /// Constructs an HTTPServer instance using Config::HTTP_PORT.
- /// </summary>
- /// <param name="controller">Pointer to ShutterController for camera operations</param>
- HTTPServer(IShutterController* controller);
-
- /// <summary>
- /// Destructor that cleans up the AsyncWebServer instance.
- /// </summary>
- ~HTTPServer();
-
- /// <summary>
- /// Initializes the WiFi access point and starts the HTTP server.
- /// Uses WiFi settings from Config class constants.
- /// Must be called during application setup.
- /// </summary>
- void begin();
-
- /// <summary>
- /// Configures the ESP8266 as a WiFi access point using Config WiFi settings.
- /// Uses Config::WIFI_SSID, Config::WIFI_PASSWORD, Config::WIFI_IP, Config::WIFI_GATEWAY, and Config::WIFI_SUBNET.
- /// </summary>
- void setupWiFiAP();
- };
- #endif // HTTP_SERVER_H
|