diff --git a/src/Arduino_WiFiConnectionHandler.cpp b/src/Arduino_WiFiConnectionHandler.cpp index e1a1f12d..a24e737b 100644 --- a/src/Arduino_WiFiConnectionHandler.cpp +++ b/src/Arduino_WiFiConnectionHandler.cpp @@ -27,10 +27,11 @@ CTOR/DTOR ******************************************************************************/ -WiFiConnectionHandler::WiFiConnectionHandler(char const * ssid, char const * pass, bool const keep_alive) +WiFiConnectionHandler::WiFiConnectionHandler(char const * ssid, char const * pass, char const * user, bool const keep_alive) : ConnectionHandler{keep_alive} , _ssid{ssid} , _pass{pass} +, _user{user} { } @@ -85,7 +86,17 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit() Debug.print(DBG_ERROR, F("WiFi status ESP: %d"), WiFi.status()); WiFi.disconnect(); delay(300); +#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \ +defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined (ARDUINO_NANO_RP2040_CONNECT) + if (strcmp(_user,"default")){ + WiFi.beginEnterprise(_ssid, _user, _pass); + } + else{ + WiFi.begin(_ssid, _pass); + } +#else WiFi.begin(_ssid, _pass); +#endif delay(1000); #endif /* #if !defined(BOARD_ESP8266) && !defined(ESP32) */ @@ -95,10 +106,21 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit() NetworkConnectionState WiFiConnectionHandler::update_handleConnecting() { #if !defined(BOARD_ESP8266) && !defined(ESP32) - if (WiFi.status() != WL_CONNECTED) - { +#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \ +defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined (ARDUINO_NANO_RP2040_CONNECT) + if (WiFi.status() != WL_CONNECTED){ + if (strcmp(_user,"default")){ + WiFi.beginEnterprise(_ssid, _user, _pass); + } + else{ + WiFi.begin(_ssid, _pass); + } + } +#else + if (WiFi.status() != WL_CONNECTED){ WiFi.begin(_ssid, _pass); } +#endif #endif /* ifndef BOARD_ESP8266 */ if (WiFi.status() != NETWORK_CONNECTED) diff --git a/src/Arduino_WiFiConnectionHandler.h b/src/Arduino_WiFiConnectionHandler.h index 56670793..a771df35 100644 --- a/src/Arduino_WiFiConnectionHandler.h +++ b/src/Arduino_WiFiConnectionHandler.h @@ -34,7 +34,7 @@ class WiFiConnectionHandler : public ConnectionHandler { public: - WiFiConnectionHandler(char const * ssid, char const * pass, bool const keep_alive = true); + WiFiConnectionHandler(char const * ssid, char const * pass, char const * user = "default", bool const keep_alive = true); virtual unsigned long getTime() override; @@ -54,6 +54,7 @@ class WiFiConnectionHandler : public ConnectionHandler char const * _ssid; char const * _pass; + char const * _user; WiFiUDP _wifi_udp; WiFiClient _wifi_client;