Skip to content

Commit b005175

Browse files
committed
Moving state transition into function update_handleConnecting (from changeConnectionState)
1 parent 61c0e29 commit b005175

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/Arduino_WiFiConnectionHandler.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void WiFiConnectionHandler::update() {
108108

109109
switch (netConnectionState) {
110110
case NetworkConnectionState::INIT: update_handleInit (networkStatus); break;
111-
case NetworkConnectionState::CONNECTING: update_handleConnecting (networkStatus); break;
111+
case NetworkConnectionState::CONNECTING: netConnectionState = update_handleConnecting (networkStatus); break;
112112
case NetworkConnectionState::CONNECTED: update_handleConnected (networkStatus); break;
113113
case NetworkConnectionState::GETTIME: netConnectionState = update_handleGetTime (); break;
114114
case NetworkConnectionState::DISCONNECTING: update_handleDisconnecting(networkStatus); break;
@@ -231,13 +231,12 @@ void WiFiConnectionHandler::update_handleInit(int & networkStatus) {
231231
changeConnectionState(NetworkConnectionState::CONNECTING);
232232
}
233233

234-
void WiFiConnectionHandler::update_handleConnecting(int & networkStatus) {
234+
NetworkConnectionState WiFiConnectionHandler::update_handleConnecting(int & networkStatus) {
235235
Debug.print(DBG_VERBOSE, "::CONNECTING");
236236

237237
networkStatus = WiFi.status();
238238

239239
#ifndef BOARD_ESP8266
240-
241240
if (networkStatus != WL_CONNECTED) {
242241
networkStatus = WiFi.begin(ssid, pass);
243242
}
@@ -249,14 +248,13 @@ void WiFiConnectionHandler::update_handleConnecting(int & networkStatus) {
249248
if (networkStatus != NETWORK_CONNECTED) {
250249
Debug.print(DBG_ERROR, "Connection to \"%s\" failed", ssid);
251250
Debug.print(DBG_INFO, "Retrying in \"%d\" milliseconds", connectionTickTimeInterval);
252-
return;
251+
return NetworkConnectionState::CONNECTING;
253252
}
254253
else {
255254
Debug.print(DBG_INFO, "Connected to \"%s\"", ssid);
256255
execNetworkEventCallback(_on_connect_event_callback, 0);
257256
connectionTickTimeInterval = CHECK_INTERVAL_CONNECTED;
258-
changeConnectionState(NetworkConnectionState::GETTIME);
259-
return;
257+
return NetworkConnectionState::GETTIME;
260258
}
261259
}
262260

src/Arduino_WiFiConnectionHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class WiFiConnectionHandler : public ConnectionHandler {
8585
static void execNetworkEventCallback(OnNetworkEventCallback & callback, void * callback_arg);
8686

8787
void update_handleInit (int & networkStatus);
88-
void update_handleConnecting (int & networkStatus);
88+
NetworkConnectionState update_handleConnecting (int & networkStatus);
8989
void update_handleConnected (int & networkStatus);
9090
NetworkConnectionState update_handleGetTime ();
9191
void update_handleDisconnecting(int const networkStatus);

0 commit comments

Comments
 (0)