From 35c1b9a3389aa5be7cacbcee8088adce3bbfe1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 17 Feb 2017 23:42:22 +0100 Subject: [PATCH] Move WIFI status code to its own routine --- code/espurna/wifi.ino | 50 ++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/code/espurna/wifi.ino b/code/espurna/wifi.ino index 45afe9fc..26048ad6 100644 --- a/code/espurna/wifi.ino +++ b/code/espurna/wifi.ino @@ -80,6 +80,39 @@ void wifiConfigure() { } +void wifiStatus() { + + if ((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) { + + DEBUG_MSG("[WIFI] MODE AP --------------------------------------\n"); + DEBUG_MSG("[WIFI] SSID %s\n", jw.getAPSSID().c_str()); + DEBUG_MSG("[WIFI] PASS %s\n", getSetting("adminPass", ADMIN_PASS).c_str()); + DEBUG_MSG("[WIFI] IP %s\n", WiFi.softAPIP().toString().c_str()); + DEBUG_MSG("[WIFI] MAC %s\n", WiFi.softAPmacAddress().c_str()); + DEBUG_MSG("[WIFI] ----------------------------------------------\n"); + + } + + if ((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) { + + DEBUG_MSG("[WIFI] MODE STA -------------------------------------\n"); + DEBUG_MSG("[WIFI] SSID %s\n", WiFi.SSID().c_str()); + DEBUG_MSG("[WIFI] IP %s\n", WiFi.localIP().toString().c_str()); + DEBUG_MSG("[WIFI] MAC %s\n", WiFi.macAddress().c_str()); + DEBUG_MSG("[WIFI] GW %s\n", WiFi.gatewayIP().toString().c_str()); + DEBUG_MSG("[WIFI] MASK %s\n", WiFi.subnetMask().toString().c_str()); + DEBUG_MSG("[WIFI] DNS %s\n", WiFi.dnsIP().toString().c_str()); + DEBUG_MSG("[WIFI] HOST %s\n", WiFi.hostname().c_str()); + DEBUG_MSG("[WIFI] ----------------------------------------------\n"); + + } + + if (WiFi.getMode() == WIFI_OFF) { + DEBUG_MSG("[WIFI] No connection\n"); + } + +} + void wifiSetup() { wifiConfigure(); @@ -122,24 +155,11 @@ void wifiSetup() { } if (code == MESSAGE_CONNECTED) { - DEBUG_MSG("[WIFI] MODE STA -------------------------------------\n"); - DEBUG_MSG("[WIFI] SSID %s\n", WiFi.SSID().c_str()); - DEBUG_MSG("[WIFI] IP %s\n", WiFi.localIP().toString().c_str()); - DEBUG_MSG("[WIFI] MAC %s\n", WiFi.macAddress().c_str()); - DEBUG_MSG("[WIFI] GW %s\n", WiFi.gatewayIP().toString().c_str()); - DEBUG_MSG("[WIFI] MASK %s\n", WiFi.subnetMask().toString().c_str()); - DEBUG_MSG("[WIFI] DNS %s\n", WiFi.dnsIP().toString().c_str()); - DEBUG_MSG("[WIFI] HOST %s\n", WiFi.hostname().c_str()); - DEBUG_MSG("[WIFI] ----------------------------------------------\n"); + wifiStatus(); } if (code == MESSAGE_ACCESSPOINT_CREATED) { - DEBUG_MSG("[WIFI] MODE AP --------------------------------------\n"); - DEBUG_MSG("[WIFI] SSID %s\n", jw.getAPSSID().c_str()); - DEBUG_MSG("[WIFI] PASS %s\n", getSetting("adminPass", ADMIN_PASS).c_str()); - DEBUG_MSG("[WIFI] IP %s\n", WiFi.softAPIP().toString().c_str()); - DEBUG_MSG("[WIFI] MAC %s\n", WiFi.softAPmacAddress().c_str()); - DEBUG_MSG("[WIFI] ----------------------------------------------\n"); + wifiStatus(); } if (code == MESSAGE_DISCONNECTED) {