@@ -123,82 +123,18 @@ void WiFiConnectionHandler::update() {
123123 PRIVATE MEMBER FUNCTIONS
124124 ******************************************************************************/
125125
126- void WiFiConnectionHandler::changeConnectionState (NetworkConnectionState _newState) {
127- if (_newState == netConnectionState) {
128- return ;
129- }
130- int newInterval = CHECK_INTERVAL_INIT;
131- switch (_newState) {
132- case NetworkConnectionState::INIT: {
133- Debug.print (DBG_VERBOSE, " CHANGING STATE TO ::INIT" );
134- newInterval = CHECK_INTERVAL_INIT;
135- }
136- break ;
137- case NetworkConnectionState::CONNECTING: {
138- Debug.print (DBG_INFO, " Connecting to \" %s\" " , ssid);
139- newInterval = CHECK_INTERVAL_CONNECTING;
140- }
141- break ;
142- case NetworkConnectionState::CONNECTED: {
143- execNetworkEventCallback (_on_connect_event_callback, 0 );
144- newInterval = CHECK_INTERVAL_CONNECTED;
145- }
146- break ;
147- case NetworkConnectionState::GETTIME: {
148- }
149- break ;
150- case NetworkConnectionState::DISCONNECTING: {
151- Debug.print (DBG_VERBOSE, " Disconnecting from \" %s\" " , ssid);
152- WiFi.disconnect ();
153- }
154- break ;
155- case NetworkConnectionState::DISCONNECTED: {
156- execNetworkEventCallback (_on_disconnect_event_callback, 0 );
157- Debug.print (DBG_VERBOSE, " WiFi.status(): %d" , WiFi.status ());
158-
159- Debug.print (DBG_ERROR, " Connection to \" %s\" lost." , ssid);
160- if (keepAlive) {
161- Debug.print (DBG_ERROR, " Attempting reconnection" );
162- }
163-
164- newInterval = CHECK_INTERVAL_DISCONNECTED;
165- }
166- break ;
167- case NetworkConnectionState::CLOSED: {
168-
169- #if !defined(BOARD_ESP8266)
170- WiFi.end ();
171- #endif
172-
173- Debug.print (DBG_VERBOSE, " Connection to \" %s\" closed" , ssid);
174- }
175- break ;
176- case NetworkConnectionState::ERROR: {
177- execNetworkEventCallback (_on_error_event_callback, 0 );
178- Debug.print (DBG_ERROR, " WiFi Hardware failure.\n Make sure you are using a WiFi enabled board/shield." );
179- Debug.print (DBG_ERROR, " Then reset and retry." );
180- }
181- break ;
182- }
183- connectionTickTimeInterval = newInterval;
184- lastConnectionTickTime = millis ();
185- netConnectionState = _newState;
186- // connectionStateChanged(netConnectionState);
187- }
188-
189126void WiFiConnectionHandler::connect () {
190127 if (netConnectionState == NetworkConnectionState::INIT || netConnectionState == NetworkConnectionState::CONNECTING) {
191128 return ;
192129 }
193130 keepAlive = true ;
194- changeConnectionState (NetworkConnectionState::INIT) ;
195-
131+ connectionTickTimeInterval = CHECK_INTERVAL_INIT ;
132+ netConnectionState = NetworkConnectionState::INIT;
196133}
197- void WiFiConnectionHandler::disconnect () {
198- // WiFi.end();
199134
200- changeConnectionState (NetworkConnectionState::DISCONNECTING);
135+ void WiFiConnectionHandler::disconnect () {
201136 keepAlive = false ;
137+ netConnectionState = NetworkConnectionState::DISCONNECTING;
202138}
203139
204140NetworkConnectionState WiFiConnectionHandler::update_handleInit (int & networkStatus) {
0 commit comments