// SPDX-License-Identifier: LGPL-3.0-or-later // ST4-ESP32: ASCOM Alpaca REST API (optional) // Enable by defining ST4_ALPACA_ENABLED before including ST4.h // Implements ASCOM Alpaca Telescope interface v3 #pragma once #ifdef ST4_ALPACA_ENABLED #include #include #include #include #include "ST4Controller.h" struct ST4AlpacaConfig { uint16_t httpPort = 32323; uint16_t discoveryPort = 32227; }; class ST4Alpaca { ST4Controller* controller_; AsyncWebServer* server_; AsyncUDP udp_; ST4AlpacaConfig config_; uint32_t serverTransactionId_; // Response helpers void sendValue(AsyncWebServerRequest* req, JsonDocument& doc); void sendBool(AsyncWebServerRequest* req, bool value); void sendDouble(AsyncWebServerRequest* req, double value); void sendString(AsyncWebServerRequest* req, const char* value); void sendInt(AsyncWebServerRequest* req, int value); void sendError(AsyncWebServerRequest* req, int errNum, const char* errMsg); void addCors(AsyncWebServerResponse* resp); // Parameter parsing (PUT uses form-encoded body) int clientTransactionId(AsyncWebServerRequest* req); bool paramBool(AsyncWebServerRequest* req, const char* name, bool& out); bool paramInt(AsyncWebServerRequest* req, const char* name, int& out); bool paramDouble(AsyncWebServerRequest* req, const char* name, double& out); String paramString(AsyncWebServerRequest* req, const char* name); // Route registration void registerManagement(); void registerDiscovery(); void registerCapabilities(); void registerState(); void registerActions(); public: ST4Alpaca(); ~ST4Alpaca(); void begin(ST4Controller& controller, const ST4AlpacaConfig& config = {}); void update(); }; #endif // ST4_ALPACA_ENABLED