Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for WPA2 Enterprise #65

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/Arduino_WiFiConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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}
{

}
Expand Down Expand Up @@ -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) */

Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/Arduino_WiFiConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -54,6 +54,7 @@ class WiFiConnectionHandler : public ConnectionHandler

char const * _ssid;
char const * _pass;
char const * _user;

WiFiUDP _wifi_udp;
WiFiClient _wifi_client;
Expand Down