File tree Expand file tree Collapse file tree 3 files changed +43
-15
lines changed Expand file tree Collapse file tree 3 files changed +43
-15
lines changed Original file line number Diff line number Diff line change 1
- export const WIFI_SECURITY_WPA_TKIP = 2 ;
2
- export const WIFI_SECURITY_WEP = 5 ;
3
- export const WIFI_SECURITY_WPA_CCMP = 4 ;
4
- export const WIFI_SECURITY_NONE = 7 ;
5
- export const WIFI_SECURITY_AUTO = 8 ;
1
+ export const WIFI_AUTH_OPEN = 0 ;
2
+ export const WIFI_AUTH_WEP = 1 ;
3
+ export const WIFI_AUTH_WEP_PSK = 2 ;
4
+ export const WIFI_AUTH_WEP2_PSK = 3 ;
5
+ export const WIFI_AUTH_WPA_WPA2_PSK = 4 ;
6
+ export const WIFI_AUTH_WPA2_ENTERPRISE = 5 ;
6
7
7
- export const isNetworkOpen = selectedNetwork => selectedNetwork && selectedNetwork . encryption_type === WIFI_SECURITY_NONE ;
8
+ export const isNetworkOpen = selectedNetwork => selectedNetwork && selectedNetwork . encryption_type === WIFI_AUTH_OPEN ;
8
9
9
10
export const networkSecurityMode = selectedNetwork => {
10
11
switch ( selectedNetwork . encryption_type ) {
11
- case WIFI_SECURITY_WPA_TKIP :
12
- case WIFI_SECURITY_WPA_CCMP :
13
- return "WPA" ;
14
- case WIFI_SECURITY_WEP :
12
+ case WIFI_AUTH_WEP :
13
+ case WIFI_AUTH_WEP_PSK :
15
14
return "WEP" ;
16
- case WIFI_SECURITY_AUTO :
17
- return "Auto" ;
18
- case WIFI_SECURITY_NONE :
15
+ case WIFI_AUTH_WEP2_PSK :
16
+ return "WEP2" ;
17
+ case WIFI_AUTH_WPA_WPA2_PSK :
18
+ return "WPA/WEP2" ;
19
+ case WIFI_AUTH_WPA2_ENTERPRISE :
20
+ return "WEP2 Enterprise" ;
21
+ case WIFI_AUTH_OPEN :
19
22
return "None" ;
20
23
default :
21
24
return "Unknown" ;
22
25
}
23
- }
26
+ }
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ void WiFiScanner::listNetworks(AsyncWebServerRequest *request) {
26
26
network[" bssid" ] = WiFi.BSSIDstr (i);
27
27
network[" channel" ] = WiFi.channel (i);
28
28
#if defined(ESP8266)
29
- network[" encryption_type" ] = WiFi.encryptionType (i);
29
+ network[" encryption_type" ] = convertEncryptionType ( WiFi.encryptionType (i) );
30
30
#elif defined(ESP_PLATFORM)
31
31
network[" encryption_type" ] = (uint8_t ) WiFi.encryptionType (i);
32
32
#endif
@@ -39,3 +39,24 @@ void WiFiScanner::listNetworks(AsyncWebServerRequest *request) {
39
39
scanNetworks (request);
40
40
}
41
41
}
42
+
43
+ /*
44
+ * Convert encryption type to standard used by ESP32 rather than the translated form which the esp8266 libaries expose.
45
+ *
46
+ * This allows us to use a single set of mappings in the UI.
47
+ */
48
+ uint8_t convertEncryptionType (uint8_t encryptionType){
49
+ switch (encryptionType){
50
+ case ENC_TYPE_NONE:
51
+ return AUTH_OPEN;
52
+ case ENC_TYPE_WEP:
53
+ return AUTH_WEP;
54
+ case ENC_TYPE_TKIP:
55
+ return AUTH_WPA_PSK;
56
+ case ENC_TYPE_CCMP:
57
+ return AUTH_WPA2_PSK;
58
+ case ENC_TYPE_AUTO:
59
+ return AUTH_WPA_WPA2_PSK;
60
+ }
61
+ return -1 ;
62
+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ class WiFiScanner {
30
30
void scanNetworks (AsyncWebServerRequest *request);
31
31
void listNetworks (AsyncWebServerRequest *request);
32
32
33
+ #if defined(ESP8266)
34
+ uint8_t convertEncryptionType (uint8_t encryptionType);
35
+ #endif
36
+
33
37
};
34
38
35
39
#endif // end WiFiScanner_h
You can’t perform that action at this time.
0 commit comments