@@ -21,44 +21,26 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
2121 {
2222 unsigned cnt = 0 ;
2323 for (size_t n = 0 ; n < WLED_MAX_WIFI_COUNT; n++) {
24- char et[4 ] = " ET" ; et[2 ] = 48 +n; et[3 ] = 0 ; // WiFi encryption type
2524 char cs[4 ] = " CS" ; cs[2 ] = 48 +n; cs[3 ] = 0 ; // client SSID
26- char ea[4 ] = " EA" ; ea[2 ] = 48 +n; ea[3 ] = 0 ; // enterprise anonymous identity
27- char ei[4 ] = " EI" ; ei[2 ] = 48 +n; ei[3 ] = 0 ; // enterprise identity
2825 char pw[4 ] = " PW" ; pw[2 ] = 48 +n; pw[3 ] = 0 ; // client password
2926 char bs[4 ] = " BS" ; bs[2 ] = 48 +n; bs[3 ] = 0 ; // BSSID
3027 char ip[5 ] = " IP" ; ip[2 ] = 48 +n; ip[4 ] = 0 ; // IP address
3128 char gw[5 ] = " GW" ; gw[2 ] = 48 +n; gw[4 ] = 0 ; // GW address
3229 char sn[5 ] = " SN" ; sn[2 ] = 48 +n; sn[4 ] = 0 ; // subnet mask
30+ #ifdef WLED_ENABLE_WPA_ENTERPRISE
31+ char et[4 ] = " ET" ; et[2 ] = 48 +n; et[3 ] = 0 ; // WiFi encryption type
32+ char ea[4 ] = " EA" ; ea[2 ] = 48 +n; ea[3 ] = 0 ; // enterprise anonymous identity
33+ char ei[4 ] = " EI" ; ei[2 ] = 48 +n; ei[3 ] = 0 ; // enterprise identity
34+ #endif
3335 if (request->hasArg (cs)) {
3436 if (n >= multiWiFi.size ()) multiWiFi.emplace_back (); // expand vector by one
35- byte oldType = multiWiFi[n].encryptionType ;
3637 char oldSSID[33 ]; strcpy (oldSSID, multiWiFi[n].clientSSID );
37- char oldAnon[65 ]; strcpy (oldAnon, multiWiFi[n].enterpriseAnonIdentity );
38- char oldIden[65 ]; strcpy (oldIden, multiWiFi[n].enterpriseIdentity );
3938 char oldPass[65 ]; strcpy (oldPass, multiWiFi[n].clientPass );
4039
41- multiWiFi[n].encryptionType = request->arg (et).toInt ();
42- forceReconnect |= oldType != multiWiFi[n].encryptionType ;
4340 strlcpy (multiWiFi[n].clientSSID , request->arg (cs).c_str (), 33 );
4441 if (strlen (oldSSID) == 0 || strncmp (multiWiFi[n].clientSSID , oldSSID, 32 ) != 0 ) {
4542 forceReconnect = true ;
4643 }
47- if (multiWiFi[n].encryptionType == WIFI_ENCRYPTION_TYPE_PSK) {
48- // PSK - Clear the anonymous identity and identity fields
49- multiWiFi[n].enterpriseAnonIdentity [0 ] = ' \0 ' ;
50- multiWiFi[n].enterpriseIdentity [0 ] = ' \0 ' ;
51- } else {
52- // WPA2-Enterprise
53- strlcpy (multiWiFi[n].enterpriseAnonIdentity , request->arg (ea).c_str (), 65 );
54- strlcpy (multiWiFi[n].enterpriseIdentity , request->arg (ei).c_str (), 65 );
55- }
56- if (strncmp (multiWiFi[n].enterpriseAnonIdentity , oldAnon, 64 ) != 0 ) {
57- forceReconnect = true ;
58- }
59- if (strncmp (multiWiFi[n].enterpriseIdentity , oldIden, 64 ) != 0 ) {
60- forceReconnect = true ;
61- }
6244 if (!isAsterisksOnly (request->arg (pw).c_str (), 65 )) {
6345 strlcpy (multiWiFi[n].clientPass , request->arg (pw).c_str (), 65 );
6446 forceReconnect = true ;
@@ -72,6 +54,34 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
7254 multiWiFi[n].staticGW [i] = request->arg (gw).toInt ();
7355 multiWiFi[n].staticSN [i] = request->arg (sn).toInt ();
7456 }
57+
58+ #ifdef WLED_ENABLE_WPA_ENTERPRISE
59+ byte oldType = multiWiFi[n].encryptionType ;
60+ char oldAnon[65 ]; strcpy (oldAnon, multiWiFi[n].enterpriseAnonIdentity );
61+ char oldIden[65 ]; strcpy (oldIden, multiWiFi[n].enterpriseIdentity );
62+ if (request->hasArg (et) && request->hasArg (ea) && request->hasArg (ei)) {
63+ multiWiFi[n].encryptionType = request->arg (et).toInt ();
64+ strlcpy (multiWiFi[n].enterpriseAnonIdentity , request->arg (ea).c_str (), 65 );
65+ strlcpy (multiWiFi[n].enterpriseIdentity , request->arg (ei).c_str (), 65 );
66+ } else {
67+ // No enterprise settings provided, default to PSK
68+ multiWiFi[n].encryptionType = WIFI_ENCRYPTION_TYPE_PSK;
69+ }
70+
71+ if (multiWiFi[n].encryptionType == WIFI_ENCRYPTION_TYPE_PSK) {
72+ // PSK - Clear the anonymous identity and identity fields
73+ multiWiFi[n].enterpriseAnonIdentity [0 ] = ' \0 ' ;
74+ multiWiFi[n].enterpriseIdentity [0 ] = ' \0 ' ;
75+ }
76+ forceReconnect |= oldType != multiWiFi[n].encryptionType ;
77+ if (strncmp (multiWiFi[n].enterpriseAnonIdentity , oldAnon, 64 ) != 0 ) {
78+ forceReconnect = true ;
79+ }
80+ if (strncmp (multiWiFi[n].enterpriseIdentity , oldIden, 64 ) != 0 ) {
81+ forceReconnect = true ;
82+ }
83+ #endif
84+
7585 cnt++;
7686 }
7787 }
0 commit comments