| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /// <summary>
- /// Minolta Remote Control Application
- ///
- /// This application implements a WiFi-controlled remote for Minolta cameras.
- /// Running on an ESP8266 microcontroller, it creates a WiFi access point and provides
- /// an HTTP API for controlling camera focus and shutter functions remotely.
- ///
- /// Features:
- /// - WiFi Access Point for remote connectivity
- /// - HTTP REST API for camera control
- /// - Support for half-press (focus), full-press (capture), and multiple shots
- /// - Status LED feedback (GPIO-2/LED_BUILTIN)
- ///
- /// Hardware:
- /// - ESP8266 D1 Mini microcontroller
- /// - GPIO5 (D1) - Focus control pin
- /// - GPIO4 (D2) - Shutter control pin
- /// - GPIO2 (LED_BUILTIN) - Status LED indicator
- ///
- /// API Endpoints:
- /// - GET / - Home page with web interface for camera control
- /// - GET /api/focus - Perform a half press (focus)
- /// - GET /api/takePhoto[?msec=duration] - Take a photo
- /// - GET /api/reset - Release the shutter
- /// - GET /api/multiple?count=n&delay=ms[&msec=duration] - Take multiple photos
- /// - GET /api/healthcheck - Health check endpoint
- /// </summary>
- #include <ArduinoJson.h>
- #include "Config.h"
- #include "ShutterController.h"
- #include "HTTPServer.h"
- #include <AsyncEventSource.h>
- #include <AsyncJson.h>
- #include <AsyncWebSocket.h>
- #include <AsyncWebSynchronization.h>
- #include <ESPAsyncWebServer.h>
- #include <StringArray.h>
- #include <WebAuthentication.h>
- #include <WebHandlerImpl.h>
- #include <WebResponseImpl.h>
- #include <ArduinoWiFiServer.h>
- #include <BearSSLHelpers.h>
- #include <CertStoreBearSSL.h>
- #include <ESP8266WiFi.h>
- #include <ESP8266WiFiAP.h>
- #include <ESP8266WiFiGeneric.h>
- #include <ESP8266WiFiGratuitous.h>
- #include <ESP8266WiFiMulti.h>
- #include <ESP8266WiFiScan.h>
- #include <ESP8266WiFiSTA.h>
- #include <ESP8266WiFiType.h>
- #include <WiFiClient.h>
- #include <WiFiClientSecure.h>
- #include <WiFiClientSecureBearSSL.h>
- #include <WiFiServer.h>
- #include <WiFiServerSecure.h>
- #include <WiFiServerSecureBearSSL.h>
- #include <WiFiUdp.h>
- static const uint8_t D1 = Config::PIN_FOCUS;
- static const uint8_t D2 = Config::PIN_SHUTTER;
- static const char* ssid = Config::WIFI_SSID;
- static const char* password = Config::WIFI_PASSWORD;
- IPAddress local_IP = Config::WIFI_IP;
- IPAddress gateway = Config::WIFI_GATEWAY;
- IPAddress subnet = Config::WIFI_SUBNET;
- /// <summary>Pointer to the ShutterController instance for camera control operations</summary>
- IShutterController* shutterController = nullptr;
- /// <summary>Pointer to the HTTPServer instance for handling API requests</summary>
- HTTPServer* httpServer = nullptr;
- /// <summary>
- /// Initializes all hardware components: serial communication and GPIO pins.
- /// Sets up serial communication at the configured baud rate,
- /// configures all GPIO pins as outputs, and initializes them to LOW.
- /// Logs a confirmation message to the serial console upon completion.
- /// </summary>
- void initializeHardware()
- {
- Serial.begin(Config::SERIAL_BAUD);
- pinMode(LED_BUILTIN, OUTPUT);
- pinMode(D1, OUTPUT);
- pinMode(D2, OUTPUT);
- digitalWrite(LED_BUILTIN, LOW);
- digitalWrite(D1, LOW);
- digitalWrite(D2, LOW);
- Serial.println("Hardware initialized");
- }
- /// <summary>
- /// Arduino setup function called once on device boot.
- /// Initializes all system components in sequence:
- /// 1. Hardware (serial, GPIO pins)
- /// 2. ShutterController for camera control
- /// 3. HTTPServer with WiFi access point
- /// After setup completes, the device is ready to accept API requests.
- /// </summary>
- void setup() {
- // Initialize hardware (serial and pins)
- initializeHardware();
-
- // Initialize ShutterController
- shutterController = new ShutterController(D1, D2);
-
- // Initialize HTTPServer
- httpServer = new HTTPServer(shutterController);
- httpServer->begin();
- }
- /// <summary>
- /// Arduino loop function called repeatedly after setup completes.
- /// Currently empty as the HTTP server runs asynchronously via interrupts.
- /// Can be extended in the future for periodic tasks or health monitoring.
- /// </summary>
- void loop() {
- // put your main code here, to run repeatedly:
- }
|