@@ -251,6 +251,37 @@ uint8_t JustWifi::_doSTA(uint8_t id) {
251251 _doCallback (MESSAGE_CONNECTING , buffer);
252252 }
253253
254+ #ifdef JUSTWIFI_ENABLE_ENTERPRISE
255+ if (entry.enterprise_username && entry.enterprise_password ) {
256+ // Create config
257+ struct station_config wifi_config;
258+ memset (&wifi_config, 0 , sizeof (wifi_config));
259+ strcpy ((char *)wifi_config.ssid , entry.ssid );
260+ wifi_config.bssid_set = 0 ;
261+ *wifi_config.password = 0 ;
262+
263+ // Set some defaults
264+ wifi_set_opmode (STATION_MODE );
265+ wifi_station_set_config_current (&wifi_config);
266+ wifi_station_set_enterprise_disable_time_check (1 );
267+ wifi_station_clear_cert_key ();
268+ wifi_station_clear_enterprise_ca_cert ();
269+ wifi_station_set_wpa2_enterprise_auth (1 );
270+
271+ // Set user/pass
272+ wifi_station_set_enterprise_identity ((uint8*)entry.enterprise_username , strlen (entry.enterprise_username ));
273+ wifi_station_set_enterprise_username ((uint8*)entry.enterprise_username , strlen (entry.enterprise_username ));
274+ wifi_station_set_enterprise_password ((uint8*)entry.enterprise_password , strlen (entry.enterprise_password ));
275+
276+ // Connect, free resources after
277+ wifi_station_connect ();
278+ wifi_station_clear_enterprise_identity ();
279+ wifi_station_clear_enterprise_username ();
280+ wifi_station_clear_enterprise_password ();
281+ wifi_station_clear_cert_key ();
282+ wifi_station_clear_enterprise_ca_cert ();
283+ } else
284+ #endif
254285 if (entry.channel == 0 ) {
255286 WiFi.begin (entry.ssid , entry.pass );
256287 } else {
@@ -628,7 +659,9 @@ bool JustWifi::addNetwork(
628659 const char * gw,
629660 const char * netmask,
630661 const char * dns,
631- bool front
662+ bool front,
663+ const char * enterprise_username,
664+ const char * enterprise_password
632665) {
633666
634667 network_t new_network;
@@ -672,6 +705,10 @@ bool JustWifi::addNetwork(
672705 if (dns && *dns != 0x00 ) {
673706 new_network.dns .fromString (dns);
674707 }
708+ if (enterprise_username && enterprise_password && *enterprise_username != 0x00 && *enterprise_password != 0x00 ) {
709+ new_network.enterprise_username = strdup (enterprise_username);
710+ new_network.enterprise_password = strdup (enterprise_password);
711+ }
675712
676713 // Defaults
677714 new_network.rssi = 0 ;
0 commit comments