Resolve issue with AP.
Fix newly introduced null pointer in AuthenticationService.
This commit is contained in:
parent
f77428e4dc
commit
41f7579bd5
@ -1,11 +1,14 @@
|
|||||||
#include <APSettingsService.h>
|
#include <APSettingsService.h>
|
||||||
|
|
||||||
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : AdminSettingsService(server, fs, securityManager, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {
|
APSettingsService::APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager) : AdminSettingsService(server, fs, securityManager, AP_SETTINGS_SERVICE_PATH, AP_SETTINGS_FILE) {}
|
||||||
onConfigUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
APSettingsService::~APSettingsService() {}
|
APSettingsService::~APSettingsService() {}
|
||||||
|
|
||||||
|
void APSettingsService::begin() {
|
||||||
|
SettingsService::begin();
|
||||||
|
onConfigUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
void APSettingsService::loop() {
|
void APSettingsService::loop() {
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
unsigned long manageElapsed = (unsigned long)(currentMillis - _lastManaged);
|
unsigned long manageElapsed = (unsigned long)(currentMillis - _lastManaged);
|
||||||
@ -80,7 +83,4 @@ void APSettingsService::writeToJsonObject(JsonObject& root) {
|
|||||||
|
|
||||||
void APSettingsService::onConfigUpdated() {
|
void APSettingsService::onConfigUpdated() {
|
||||||
_lastManaged = millis() - MANAGE_NETWORK_DELAY;
|
_lastManaged = millis() - MANAGE_NETWORK_DELAY;
|
||||||
|
|
||||||
// stop softAP - forces reconfiguration in loop()
|
|
||||||
stopAP();
|
|
||||||
}
|
}
|
@ -26,6 +26,7 @@ class APSettingsService : public AdminSettingsService {
|
|||||||
APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
APSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
||||||
~APSettingsService();
|
~APSettingsService();
|
||||||
|
|
||||||
|
void begin();
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -49,7 +50,7 @@ class APSettingsService : public AdminSettingsService {
|
|||||||
|
|
||||||
void manageAP();
|
void manageAP();
|
||||||
void startAP();
|
void startAP();
|
||||||
void stopAP();
|
void stopAP() ;
|
||||||
void handleDNS();
|
void handleDNS();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <AuthenticationService.h>
|
#include <AuthenticationService.h>
|
||||||
|
|
||||||
AuthenticationService::AuthenticationService(AsyncWebServer* server, SecurityManager* securityManager) {
|
AuthenticationService::AuthenticationService(AsyncWebServer* server, SecurityManager* securityManager) : _securityManager(securityManager) {
|
||||||
server->on(VERIFY_AUTHORIZATION_PATH, HTTP_GET, std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
|
server->on(VERIFY_AUTHORIZATION_PATH, HTTP_GET, std::bind(&AuthenticationService::verifyAuthorization, this, std::placeholders::_1));
|
||||||
|
|
||||||
_signInHandler.setUri(SIGN_IN_PATH);
|
_signInHandler.setUri(SIGN_IN_PATH);
|
||||||
|
@ -39,6 +39,14 @@ ESP8266React::ESP8266React(AsyncWebServer* server, FS* fs):
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ESP8266React::begin() {
|
||||||
|
_securitySettingsService.begin();
|
||||||
|
_wifiSettingsService.begin();
|
||||||
|
_apSettingsService.begin();
|
||||||
|
_ntpSettingsService.begin();
|
||||||
|
_otaSettingsService.begin();
|
||||||
|
}
|
||||||
|
|
||||||
void ESP8266React::loop() {
|
void ESP8266React::loop() {
|
||||||
_wifiSettingsService.loop();
|
_wifiSettingsService.loop();
|
||||||
_apSettingsService.loop();
|
_apSettingsService.loop();
|
||||||
|
@ -31,6 +31,7 @@ class ESP8266React {
|
|||||||
|
|
||||||
ESP8266React(AsyncWebServer* server, FS* fs);
|
ESP8266React(AsyncWebServer* server, FS* fs);
|
||||||
|
|
||||||
|
void begin();
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
SecurityManager* getSecurityManager(){
|
SecurityManager* getSecurityManager(){
|
||||||
|
@ -31,13 +31,15 @@ class SettingsService : public SettingsPersistence {
|
|||||||
_updateHandler.setMaxContentLength(MAX_SETTINGS_SIZE);
|
_updateHandler.setMaxContentLength(MAX_SETTINGS_SIZE);
|
||||||
_updateHandler.onRequest(std::bind(&SettingsService::updateConfig, this, std::placeholders::_1, std::placeholders::_2));
|
_updateHandler.onRequest(std::bind(&SettingsService::updateConfig, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
server->addHandler(&_updateHandler);
|
server->addHandler(&_updateHandler);
|
||||||
|
|
||||||
// read the initial data from the file system
|
|
||||||
readFromFS();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~SettingsService() {}
|
virtual ~SettingsService() {}
|
||||||
|
|
||||||
|
void begin() {
|
||||||
|
// read the initial data from the file system
|
||||||
|
readFromFS();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
char const* _servicePath;
|
char const* _servicePath;
|
||||||
AsyncJsonWebHandler _updateHandler;
|
AsyncJsonWebHandler _updateHandler;
|
||||||
|
@ -5,9 +5,6 @@ WiFiSettingsService::WiFiSettingsService(AsyncWebServer* server, FS* fs, Securit
|
|||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.setAutoReconnect(false);
|
WiFi.setAutoReconnect(false);
|
||||||
|
|
||||||
// Force WiFi config to be applied when loop() called
|
|
||||||
reconfigureWiFiConnection();
|
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(std::bind(&WiFiSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
|
_onStationModeDisconnectedHandler = WiFi.onStationModeDisconnected(std::bind(&WiFiSettingsService::onStationModeDisconnected, this, std::placeholders::_1));
|
||||||
#elif defined(ESP_PLATFORM)
|
#elif defined(ESP_PLATFORM)
|
||||||
@ -20,6 +17,11 @@ WiFiSettingsService::WiFiSettingsService(AsyncWebServer* server, FS* fs, Securit
|
|||||||
|
|
||||||
WiFiSettingsService::~WiFiSettingsService() {}
|
WiFiSettingsService::~WiFiSettingsService() {}
|
||||||
|
|
||||||
|
void WiFiSettingsService::begin() {
|
||||||
|
SettingsService::begin();
|
||||||
|
reconfigureWiFiConnection();
|
||||||
|
}
|
||||||
|
|
||||||
void WiFiSettingsService::readFromJsonObject(JsonObject& root){
|
void WiFiSettingsService::readFromJsonObject(JsonObject& root){
|
||||||
_ssid = root["ssid"] | "";
|
_ssid = root["ssid"] | "";
|
||||||
_password = root["password"] | "";
|
_password = root["password"] | "";
|
||||||
|
@ -15,6 +15,7 @@ class WiFiSettingsService : public AdminSettingsService {
|
|||||||
WiFiSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
WiFiSettingsService(AsyncWebServer* server, FS* fs, SecurityManager* securityManager);
|
||||||
~WiFiSettingsService();
|
~WiFiSettingsService();
|
||||||
|
|
||||||
|
void begin();
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
12
src/main.cpp
12
src/main.cpp
@ -5,21 +5,27 @@
|
|||||||
#define SERIAL_BAUD_RATE 115200
|
#define SERIAL_BAUD_RATE 115200
|
||||||
|
|
||||||
AsyncWebServer server(80);
|
AsyncWebServer server(80);
|
||||||
ESP8266React framework(&server, &SPIFFS);
|
ESP8266React esp8266React(&server, &SPIFFS);
|
||||||
DemoProject demoProject = DemoProject(&server, &SPIFFS, framework.getSecurityManager());
|
DemoProject demoProject = DemoProject(&server, &SPIFFS, esp8266React.getSecurityManager());
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// start serial and filesystem
|
// start serial and filesystem
|
||||||
Serial.begin(SERIAL_BAUD_RATE);
|
Serial.begin(SERIAL_BAUD_RATE);
|
||||||
|
|
||||||
|
// start the file system (must be done before starting the framework)
|
||||||
SPIFFS.begin();
|
SPIFFS.begin();
|
||||||
|
|
||||||
|
// start the framework and demo project
|
||||||
|
esp8266React.begin();
|
||||||
|
demoProject.begin();
|
||||||
|
|
||||||
// start the server
|
// start the server
|
||||||
server.begin();
|
server.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// run the framework's loop function
|
// run the framework's loop function
|
||||||
framework.loop();
|
esp8266React.loop();
|
||||||
|
|
||||||
// run the demo project's loop function
|
// run the demo project's loop function
|
||||||
demoProject.loop();
|
demoProject.loop();
|
||||||
|
Loading…
Reference in New Issue
Block a user