Files
WordClockESP/lib/framework/OTASettingsService.h
T

55 lines
1.2 KiB
C++
Raw Normal View History

#ifndef OTASettingsService_h
#define OTASettingsService_h
2019-08-10 12:35:26 +01:00
#include <AdminSettingsService.h>
2019-12-24 11:19:19 +00:00
#ifdef ESP32
#include <ESPmDNS.h>
2019-12-24 11:19:19 +00:00
#elif defined(ESP8266)
#include <ESP8266mDNS.h>
#endif
#include <ArduinoOTA.h>
#include <WiFiUdp.h>
// Emergency defaults
#define DEFAULT_OTA_PORT 8266
#define DEFAULT_OTA_PASSWORD "esp-react"
2020-01-08 23:02:36 +00:00
#define DEFAULT_OTA_ENABLED true
#define OTA_SETTINGS_FILE "/config/otaSettings.json"
2018-04-01 10:35:23 +01:00
#define OTA_SETTINGS_SERVICE_PATH "/rest/otaSettings"
2020-02-01 08:44:26 +00:00
class OTASettings {
public:
bool enabled;
int port;
String password;
};
class OTASettingsService : public AdminSettingsService<OTASettings> {
public:
OTASettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
~OTASettingsService();
void loop();
protected:
void onConfigUpdated();
void readFromJsonObject(JsonObject& root);
void writeToJsonObject(JsonObject& root);
private:
ArduinoOTAClass* _arduinoOTA;
void configureArduinoOTA();
2019-12-24 11:19:19 +00:00
#ifdef ESP32
void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
#elif defined(ESP8266)
WiFiEventHandler _onStationModeGotIPHandler;
void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
#endif
};
#endif // end OTASettingsService_h