From 832ec44c67fe1048b82b21c14a1a6d0e4fcae221 Mon Sep 17 00:00:00 2001 From: travis-farmer Date: Tue, 7 Nov 2023 06:37:17 -0500 Subject: [PATCH] clean up IP reading --- Wifi_NINA.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Wifi_NINA.cpp b/Wifi_NINA.cpp index 9664d84..0b595ff 100644 --- a/Wifi_NINA.cpp +++ b/Wifi_NINA.cpp @@ -114,8 +114,8 @@ bool WifiNINA::setup(const char *SSid, delay(500); } if (WiFi.status() == WL_CONNECTED) { - // String ip_str = sprintf("%xl", WiFi.localIP()); - DIAG(F("Wifi STA IP %d.%d.%d.%d"), WiFi.localIP()[0], WiFi.localIP()[1],WiFi.localIP()[2],WiFi.localIP()[3]); + IPAddress ip = WiFi.localIP(); + DIAG(F("Wifi STA IP %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); wifiUp = true; } else { DIAG(F("Could not connect to Wifi SSID %s"),SSid); @@ -124,17 +124,17 @@ bool WifiNINA::setup(const char *SSid, // esp_wifi_connect(); tries=40; while (WiFi.status() != WL_CONNECTED && tries) { - Serial.print('.'); - tries--; - delay(500); + Serial.print('.'); + tries--; + delay(500); } if (WiFi.status() == WL_CONNECTED) { - ip = WiFi.localIP(); - DIAG(F("Wifi STA IP 2nd try %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); - wifiUp = true; - } else { - DIAG(F("Wifi STA mode FAIL. Will revert to AP mode")); - haveSSID=false; + ip = WiFi.localIP(); + DIAG(F("Wifi STA IP 2nd try %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); + wifiUp = true; + } else { + DIAG(F("Wifi STA mode FAIL. Will revert to AP mode")); + haveSSID=false; } } }