You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1010 B
40 lines
1010 B
#include "wifi.h" |
|
|
|
void processWifiState() |
|
{ |
|
switch (wifiState) { |
|
case WIFI_DISCONNECTED: |
|
commState = COMM_INIT; |
|
|
|
if (SERIAL_LOGGING) Serial.println("[INFO] Wifi attempting to connect..."); |
|
|
|
WiFi.begin(LOCKOUT_WIFI_SSID, LOCKOUT_WIFI_PASS); |
|
|
|
wifiState = WIFI_CONNECTING; |
|
break; |
|
case WIFI_CONNECTING: |
|
commState = COMM_INIT; |
|
|
|
if (WiFi.status() == WL_CONNECTED) { |
|
if (SERIAL_LOGGING) Serial.println("[INFO] Wifi is connected."); |
|
logEvent(LOG_WIFI_CONNECTED); |
|
|
|
if (SERIAL_LOGGING) Serial.print("[INFO] Wifi IP Address: "); |
|
if (SERIAL_LOGGING) Serial.println(WiFi.localIP()); |
|
|
|
wifiState = WIFI_CONNECTED; |
|
} |
|
break; |
|
case WIFI_CONNECTED: |
|
if (WiFi.status() != WL_CONNECTED) { |
|
if (SERIAL_LOGGING) Serial.println("[INFO] Wifi disconnected."); |
|
logEvent(LOG_WIFI_DISCONNECTED); |
|
wifiState = WIFI_DISCONNECTED; |
|
} |
|
break; |
|
default: |
|
if (SERIAL_LOGGING) Serial.println("[ERROR] Invalid wifi state."); |
|
wifiState = WIFI_DISCONNECTED; |
|
break; |
|
} |
|
}
|
|
|