Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

  1. #ifndef OTASettingsService_h
  2. #define OTASettingsService_h
  3. #include <SettingsService.h>
  4. #if defined(ESP8266)
  5. #include <ESP8266mDNS.h>
  6. #elif defined(ESP_PLATFORM)
  7. #include <ESPmDNS.h>
  8. #endif
  9. #include <WiFiUdp.h>
  10. #include <ArduinoOTA.h>
  11. // Emergency defaults
  12. #define DEFAULT_OTA_PORT 8266
  13. #define DEFAULT_OTA_PASSWORD "esp-react"
  14. #define OTA_SETTINGS_FILE "/config/otaSettings.json"
  15. #define OTA_SETTINGS_SERVICE_PATH "/rest/otaSettings"
  16. class OTASettingsService : public AdminSettingsService {
  17. public:
  18. OTASettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
  19. ~OTASettingsService();
  20. void loop();
  21. protected:
  22. void onConfigUpdated();
  23. void readFromJsonObject(JsonObject& root);
  24. void writeToJsonObject(JsonObject& root);
  25. private:
  26. ArduinoOTAClass *_arduinoOTA;
  27. bool _enabled;
  28. int _port;
  29. String _password;
  30. void configureArduinoOTA();
  31. #if defined(ESP8266)
  32. WiFiEventHandler _onStationModeGotIPHandler;
  33. void onStationModeGotIP(const WiFiEventStationModeGotIP& event);
  34. #elif defined(ESP_PLATFORM)
  35. void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
  36. #endif
  37. };
  38. #endif // end NTPSettingsService_h