| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #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 /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 /get 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.
- /// </summary>
- /// <param name="port">HTTP server port number (typically 80)</param>
- /// <param name="controller">Pointer to ShutterController for camera operations</param>
- HTTPServer(uint16_t port, IShutterController* controller);
-
- /// <summary>
- /// Destructor that cleans up the AsyncWebServer instance.
- /// </summary>
- ~HTTPServer();
-
- /// <summary>
- /// Initializes the WiFi access point and starts the HTTP server.
- /// Must be called during application setup.
- /// </summary>
- /// <param name="ssid">WiFi network name</param>
- /// <param name="password">WiFi network password</param>
- /// <param name="local_IP">Static IP address for the access point</param>
- /// <param name="gateway">Gateway IP address</param>
- /// <param name="subnet">Subnet mask</param>
- void begin(const char* ssid, const char* password,
- IPAddress local_IP, IPAddress gateway, IPAddress subnet);
-
- /// <summary>
- /// Configures the ESP8266 as a WiFi access point with the specified credentials.
- /// </summary>
- /// <param name="ssid">WiFi network name</param>
- /// <param name="password">WiFi network password</param>
- /// <param name="local_IP">Static IP address for the access point</param>
- /// <param name="gateway">Gateway IP address</param>
- /// <param name="subnet">Subnet mask</param>
- void setupWiFiAP(const char* ssid, const char* password,
- IPAddress local_IP, IPAddress gateway, IPAddress subnet);
- };
- #endif // HTTP_SERVER_H
|