2018-02-26 00:11:31 +00:00
|
|
|
#ifndef APSettingsConfig_h
|
|
|
|
#define APSettingsConfig_h
|
|
|
|
|
2018-11-11 16:36:41 +00:00
|
|
|
#include <SettingsService.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
|
|
|
|
|
|
|
class APSettingsService : public SettingsService {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
APSettingsService(AsyncWebServer* server, FS* fs);
|
|
|
|
~APSettingsService();
|
|
|
|
|
|
|
|
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();
|
|
|
|
void stopAP();
|
|
|
|
void handleDNS();
|
|
|
|
|
2018-02-26 00:11:31 +00:00
|
|
|
};
|
|
|
|
|
2018-10-23 12:55:25 +00:00
|
|
|
#endif // end APSettingsConfig_h
|