diff --git a/src/AutoConnect.cpp b/src/AutoConnect.cpp index e5296f9..4de87d3 100644 --- a/src/AutoConnect.cpp +++ b/src/AutoConnect.cpp @@ -27,10 +27,12 @@ * AutoConnect default constructor. This entry activates WebServer * internally and the web server is allocated internal. */ -AutoConnect::AutoConnect() { - _initialize(); - _webServer.reset(nullptr); - _dnsServer.reset(nullptr); +AutoConnect::AutoConnect() +: _scanCount( 0 ) +, _connectTimeout( AUTOCONNECT_TIMEOUT ) +, _menuTitle( _apConfig.title ) +{ + memset(&_credential, 0x00, sizeof(station_config_t)); } /** @@ -38,27 +40,10 @@ AutoConnect::AutoConnect() { * User's added URI handler response can be included in handleClient method. * @param webServer A reference of ESP8266WebServer instance. */ -AutoConnect::AutoConnect(WebServerClass& webServer) { - _initialize(); +AutoConnect::AutoConnect(WebServerClass& webServer) +: AutoConnect() +{ _webServer = WebserverUP(&webServer, [](WebServerClass*){}); - _dnsServer.reset(nullptr); -} - -void AutoConnect::_initialize(void) { - _rfConnect = false; - _rfReset = false; - _rfDisconnect = false; - _responsePage = nullptr; - _currentPageElement = nullptr; - _menuTitle = _apConfig.title; - _connectTimeout = AUTOCONNECT_TIMEOUT; - _scanCount = 0; - memset(&_credential, 0x00, sizeof(station_config_t)); -#ifdef ARDUINO_ARCH_ESP32 - _disconnectEventId = -1; // The member available for ESP32 only -#endif - _aux = nullptr; - _auxUri = String(""); } /** diff --git a/src/AutoConnect.h b/src/AutoConnect.h index ee800fb..afd0d9b 100644 --- a/src/AutoConnect.h +++ b/src/AutoConnect.h @@ -222,7 +222,6 @@ class AutoConnect { AC_RECONNECT_SET, AC_RECONNECT_RESET } AC_STARECONNECT_t; - void _initialize(void); bool _config(void); bool _configSTA(const IPAddress& ip, const IPAddress& gateway, const IPAddress& netmask, const IPAddress& dns1, const IPAddress& dns2); bool _getConfigSTA(station_config_t* config); @@ -275,8 +274,8 @@ class AutoConnect { * Every time a GET/POST HTTP request occurs, an AutoConnect * menu page corresponding to the URI is generated. */ - PageBuilder* _responsePage; - PageElement* _currentPageElement; + PageBuilder* _responsePage = nullptr; + PageElement* _currentPageElement = nullptr; /** Extended pages made up with AutoConnectAux */ AutoConnectAux* _aux = nullptr; /**< A top of registered AutoConnectAux */ @@ -295,12 +294,12 @@ class AutoConnect { unsigned long _portalAccessPeriod; /** The control indicators */ - bool _rfConnect; /**< URI /connect requested */ - bool _rfDisconnect; /**< URI /disc requested */ - bool _rfReset; /**< URI /reset requested */ + bool _rfConnect = false; /**< URI /connect requested */ + bool _rfDisconnect = false; /**< URI /disc requested */ + bool _rfReset = false; /**< URI /reset requested */ wl_status_t _rsConnect; /**< connection result */ #ifdef ARDUINO_ARCH_ESP32 - WiFiEventId_t _disconnectEventId; /**< STA disconnection event handler registered id */ + WiFiEventId_t _disconnectEventId = -1; /**< STA disconnection event handler registered id */ #endif std::unique_ptr _ticker; /**< */