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.

52 lines
1.1 KiB

  1. #ifndef APSettingsConfig_h
  2. #define APSettingsConfig_h
  3. #include <AdminSettingsService.h>
  4. #include <DNSServer.h>
  5. #include <IPAddress.h>
  6. #define MANAGE_NETWORK_DELAY 10000
  7. #define AP_MODE_ALWAYS 0
  8. #define AP_MODE_DISCONNECTED 1
  9. #define AP_MODE_NEVER 2
  10. #define DNS_PORT 53
  11. #define AP_DEFAULT_SSID "ssid"
  12. #define AP_DEFAULT_PASSWORD "password"
  13. #define AP_SETTINGS_FILE "/config/apSettings.json"
  14. #define AP_SETTINGS_SERVICE_PATH "/rest/apSettings"
  15. class APSettingsService : public AdminSettingsService {
  16. public:
  17. APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
  18. ~APSettingsService();
  19. void begin();
  20. void loop();
  21. protected:
  22. void readFromJsonObject(JsonObject& root);
  23. void writeToJsonObject(JsonObject& root);
  24. void onConfigUpdated();
  25. private:
  26. // access point settings
  27. uint8_t _provisionMode;
  28. String _ssid;
  29. String _password;
  30. // for the mangement delay loop
  31. unsigned long _lastManaged;
  32. // for the captive portal
  33. DNSServer* _dnsServer;
  34. void manageAP();
  35. void startAP();
  36. void stopAP();
  37. void handleDNS();
  38. };
  39. #endif // end APSettingsConfig_h