2018-02-26 00:11:31 +00:00
|
|
|
#ifndef APSettingsConfig_h
|
|
|
|
#define APSettingsConfig_h
|
|
|
|
|
2019-08-10 11:35:26 +00:00
|
|
|
#include <AdminSettingsService.h>
|
2018-03-06 22:39:33 +00:00
|
|
|
#include <DNSServer.h>
|
2018-02-26 00:11:31 +00:00
|
|
|
#include <IPAddress.h>
|
|
|
|
|
|
|
|
#define MANAGE_NETWORK_DELAY 10000
|
|
|
|
|
|
|
|
#define AP_MODE_ALWAYS 0
|
|
|
|
#define AP_MODE_DISCONNECTED 1
|
|
|
|
#define AP_MODE_NEVER 2
|
|
|
|
|
2018-03-06 22:39:33 +00:00
|
|
|
#define DNS_PORT 53
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
#define AP_DEFAULT_SSID "ssid"
|
|
|
|
#define AP_DEFAULT_PASSWORD "password"
|
|
|
|
|
|
|
|
#define AP_SETTINGS_FILE "/config/apSettings.json"
|
2018-04-01 09:35:23 +00:00
|
|
|
#define AP_SETTINGS_SERVICE_PATH "/rest/apSettings"
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2019-05-29 22:48:16 +00:00
|
|
|
class APSettingsService : public AdminSettingsService {
|
2018-02-26 00:11:31 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2019-09-28 20:29:46 +00:00
|
|
|
APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
2018-02-26 00:11:31 +00:00
|
|
|
~APSettingsService();
|
|
|
|
|
2019-09-30 20:28:24 +00:00
|
|
|
void begin();
|
2018-02-26 00:11:31 +00:00
|
|
|
void loop();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void readFromJsonObject(JsonObject& root);
|
|
|
|
void writeToJsonObject(JsonObject& root);
|
|
|
|
void onConfigUpdated();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2018-03-06 22:39:33 +00:00
|
|
|
// access point settings
|
2018-10-23 14:23:46 +00:00
|
|
|
uint8_t _provisionMode;
|
2018-02-26 00:11:31 +00:00
|
|
|
String _ssid;
|
|
|
|
String _password;
|
2018-03-06 22:39:33 +00:00
|
|
|
|
|
|
|
// for the mangement delay loop
|
2018-10-23 12:55:25 +00:00
|
|
|
unsigned long _lastManaged;
|
2018-02-26 00:11:31 +00:00
|
|
|
|
2018-03-06 22:39:33 +00:00
|
|
|
// for the captive portal
|
|
|
|
DNSServer *_dnsServer;
|
|
|
|
|
|
|
|
void manageAP();
|
|
|
|
void startAP();
|
2019-09-30 20:28:24 +00:00
|
|
|
void stopAP() ;
|
2018-03-06 22:39:33 +00:00
|
|
|
void handleDNS();
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
};
|
|
|
|
|
2018-10-23 12:55:25 +00:00
|
|
|
#endif // end APSettingsConfig_h
|