diff --git a/src/AutoConnectCore.hpp b/src/AutoConnectCore.hpp index dd9165fa..f47ba642 100644 --- a/src/AutoConnectCore.hpp +++ b/src/AutoConnectCore.hpp @@ -69,6 +69,8 @@ class AutoConnectCore { template bool restoreCredential(const char* filename = "/" AC_IDENTIFIER, U& fs = AUTOCONNECT_APPLIED_FILESYSTEM); + bool portalAvailable() { return _portalAvailable; } + protected: typedef enum { AC_RECONNECT_SET, @@ -160,6 +162,8 @@ class AutoConnectCore { #ifdef ARDUINO_ARCH_ESP32 WiFiEventId_t _disconnectEventId = -1; /**< STA disconnection event handler registered id */ #endif + bool _portalAvailable = false; /** will be true when the portal is available **/ + /** Only available with ticker enabled */ std::unique_ptr _ticker; diff --git a/src/AutoConnectCoreImpl.hpp b/src/AutoConnectCoreImpl.hpp index 3a691ace..44fb5812 100644 --- a/src/AutoConnectCoreImpl.hpp +++ b/src/AutoConnectCoreImpl.hpp @@ -1040,6 +1040,7 @@ template void AutoConnectCore::_startDNSServer(void) { // Boot DNS server, set up for captive portal redirection. if (!_dnsServer) { + _portalAvailable = true; _dnsServer.reset(new DNSServer()); _dnsServer->setErrorReplyCode(DNSReplyCode::NoError); _dnsServer->start(AUTOCONNECT_DNSPORT, "*", WiFi.softAPIP()); @@ -1054,6 +1055,7 @@ void AutoConnectCore::_startDNSServer(void) { template void AutoConnectCore::_stopDNSServer(void) { if (_dnsServer) { + _portalAvailable = false; _dnsServer->stop(); _dnsServer.reset(); AC_DBG("DNS server stopped\n");