Correspond to begin() after timeout

pull/41/head
Hieromon Ikasamo 6 years ago
parent 43bb6d2c12
commit 1976b88f9d
  1. 26
      src/AutoConnect.cpp

@ -216,7 +216,7 @@ bool AutoConnect::begin(const char* ssid, const char* passphrase, unsigned long
_dnsServer->stop(); _dnsServer->stop();
_dnsServer.reset(); _dnsServer.reset();
} }
// Captive portal styaing time exceeds timeout, // Captive portal staying time exceeds timeout,
// Close the portal if an option for keeping the portal is false. // Close the portal if an option for keeping the portal is false.
else if (hasTimeout) { else if (hasTimeout) {
if (_apConfig.retainPortal) { if (_apConfig.retainPortal) {
@ -284,9 +284,12 @@ void AutoConnect::end() {
if (_responsePage != nullptr) { if (_responsePage != nullptr) {
_responsePage->~PageBuilder(); _responsePage->~PageBuilder();
delete _responsePage; delete _responsePage;
_responsePage = nullptr;
} }
if (_currentPageElement != nullptr) if (_currentPageElement != nullptr) {
_currentPageElement->~PageElement(); _currentPageElement->~PageElement();
_currentPageElement = nullptr;
}
_stopPortal(); _stopPortal();
if (_webServer) { if (_webServer) {
@ -366,13 +369,18 @@ void AutoConnect::_startWebServer() {
// It is supposed to evacuate but ESP8266WebServer::_notFoundHandler is not accessible. // It is supposed to evacuate but ESP8266WebServer::_notFoundHandler is not accessible.
_webServer->onNotFound(std::bind(&AutoConnect::_handleNotFound, this)); _webServer->onNotFound(std::bind(&AutoConnect::_handleNotFound, this));
// here, Prepare PageBuilders for captive portal // here, Prepare PageBuilders for captive portal
_responsePage = new PageBuilder(); if (!_responsePage) {
_responsePage->chunked(PB_ByteStream); _responsePage = new PageBuilder();
_responsePage->exitCanHandle(std::bind(&AutoConnect::_classifyHandle, this, std::placeholders::_1, std::placeholders::_2)); _responsePage->chunked(PB_ByteStream);
_responsePage->insert(*_webServer); _responsePage->exitCanHandle(std::bind(&AutoConnect::_classifyHandle, this, std::placeholders::_1, std::placeholders::_2));
_responsePage->insert(*_webServer);
_webServer->begin();
AC_DBG("http server started\n"); _webServer->begin();
AC_DBG("http server started\n");
}
else {
AC_DBG("http server readied\n");
}
} }
/** /**

Loading…
Cancel
Save