Skip to content

Commit fc86a63

Browse files
committed
Fix wifiscan encryption types
Fix wifiscan encryption types (#16141)
1 parent e327c61 commit fc86a63

File tree

5 files changed

+56
-38
lines changed

5 files changed

+56
-38
lines changed

tasmota/include/tasmota.h

+2
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ enum InitStates {INIT_NONE, INIT_GPIOS, INIT_DONE};
314314

315315
enum WifiConfigOptions {WIFI_RESTART, EX_WIFI_SMARTCONFIG, WIFI_MANAGER, EX_WIFI_WPSCONFIG, WIFI_RETRY, WIFI_WAIT, WIFI_SERIAL, WIFI_MANAGER_RESET_ONLY, MAX_WIFI_OPTION};
316316

317+
enum WifiTestOptions {WIFI_NOT_TESTING, WIFI_TESTING, WIFI_TEST_FINISHED, WIFI_TEST_FINISHED_BAD};
318+
317319
enum SwitchModeOptions {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, PUSHBUTTON_TOGGLE, TOGGLEMULTI,
318320
FOLLOWMULTI, FOLLOWMULTI_INV, PUSHHOLDMULTI, PUSHHOLDMULTI_INV, PUSHON, PUSHON_INV, PUSH_IGNORE, MAX_SWITCH_OPTION};
319321

tasmota/include/tasmota_globals.h

-34
Original file line numberDiff line numberDiff line change
@@ -593,38 +593,4 @@ bool first_device_group_is_local = true;
593593

594594
/*********************************************************************************************/
595595

596-
597-
enum WifiTestOptions { WIFI_NOT_TESTING, WIFI_TESTING, WIFI_TEST_FINISHED, WIFI_TEST_FINISHED_BAD };
598-
599-
struct WIFI {
600-
uint32_t last_event = 0; // Last wifi connection event
601-
uint32_t downtime = 0; // Wifi down duration
602-
uint16_t link_count = 0; // Number of wifi re-connect
603-
uint8_t counter;
604-
uint8_t retry_init;
605-
uint8_t retry;
606-
uint8_t max_retry;
607-
uint8_t status;
608-
uint8_t config_type = 0;
609-
uint8_t config_counter = 0;
610-
uint8_t scan_state;
611-
uint8_t bssid[6];
612-
int8_t best_network_db;
613-
uint8_t wifiTest = WIFI_NOT_TESTING;
614-
uint8_t wifi_test_counter = 0;
615-
uint16_t save_data_counter = 0;
616-
uint8_t old_wificonfig = MAX_WIFI_OPTION; // means "nothing yet saved here"
617-
bool wifi_test_AP_TIMEOUT = false;
618-
bool wifi_Test_Restart = false;
619-
bool wifi_Test_Save_SSID2 = false;
620-
} Wifi;
621-
622-
// Reference. WiFi.encryptionType =
623-
// 2 : ENC_TYPE_TKIP - WPA / PSK
624-
// 4 : ENC_TYPE_CCMP - WPA2 / PSK
625-
// 5 : ENC_TYPE_WEP - WEP
626-
// 7 : ENC_TYPE_NONE - open network
627-
// 8 : ENC_TYPE_AUTO - WPA / WPA2 / PSK
628-
const char kWifiEncryptionTypes[] PROGMEM = "0" "|" "1" "|" "WPA/PSK" "|" "3" "|" "WPA2/PSK" "|" "WEP" "|" "6" "|" "OPEN" "|" "WPA/WPA2/PSK";
629-
630596
#endif // _TASMOTA_GLOBALS_H_

tasmota/tasmota.ino

+23
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,29 @@
9696

9797
const uint32_t VERSION_MARKER[] PROGMEM = { 0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A };
9898

99+
struct WIFI {
100+
uint32_t last_event = 0; // Last wifi connection event
101+
uint32_t downtime = 0; // Wifi down duration
102+
uint16_t link_count = 0; // Number of wifi re-connect
103+
uint8_t counter;
104+
uint8_t retry_init;
105+
uint8_t retry;
106+
uint8_t max_retry;
107+
uint8_t status;
108+
uint8_t config_type = 0;
109+
uint8_t config_counter = 0;
110+
uint8_t scan_state;
111+
uint8_t bssid[6];
112+
int8_t best_network_db;
113+
uint8_t wifiTest = WIFI_NOT_TESTING;
114+
uint8_t wifi_test_counter = 0;
115+
uint16_t save_data_counter = 0;
116+
uint8_t old_wificonfig = MAX_WIFI_OPTION; // means "nothing yet saved here"
117+
bool wifi_test_AP_TIMEOUT = false;
118+
bool wifi_Test_Restart = false;
119+
bool wifi_Test_Save_SSID2 = false;
120+
} Wifi;
121+
99122
typedef struct {
100123
uint16_t valid; // 280 (RTC memory offset 100 - sizeof(RTCRBT))
101124
uint8_t fast_reboot_count; // 282

tasmota/tasmota_support/support_command.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ void CmndWifiScan(void)
137137
WiFi.channel(indexes[i]),
138138
WiFi.RSSI(indexes[i]),
139139
WifiGetRssiAsQuality(WiFi.RSSI(indexes[i])),
140-
GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes));
140+
// GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes));
141+
WifiEncryptionType(indexes[i]).c_str());
141142
if ( ResponseSize() < ResponseLength() + 300 ) { break; }
142143
if ( i < WiFi.scanComplete() -1 ) { ResponseAppend_P(PSTR(",")); }
143144
//AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "MAX SIZE: %d, SIZE: %d"),ResponseSize(),ResponseLength());

tasmota/tasmota_support/support_wifi.ino

+29-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ const uint8_t WIFI_RETRY_OFFSET_SEC = WIFI_RETRY_SECONDS; // seconds
4545
#include <AddrList.h> // IPv6 DualStack
4646
#endif // LWIP_IPV6=1
4747

48-
int WifiGetRssiAsQuality(int rssi)
49-
{
48+
int WifiGetRssiAsQuality(int rssi) {
5049
int quality = 0;
5150

5251
if (rssi <= -100) {
@@ -59,6 +58,32 @@ int WifiGetRssiAsQuality(int rssi)
5958
return quality;
6059
}
6160

61+
// 0 1 2 3 4
62+
const char kWifiEncryptionTypes[] PROGMEM = "OPEN|WEP|WPA/PSK|WPA2/PSK|WPA/WPA2/PSK"
63+
#ifdef ESP32
64+
// 5 6 7 8
65+
"|WPA2ENTERPRISE|WPA3/PSK|WPA2/WPA3/PSK|WAPI/PSK"
66+
#endif // ESP32
67+
;
68+
69+
String WifiEncryptionType(uint32_t i) {
70+
#ifdef ESP8266
71+
// Reference. WiFi.encryptionType =
72+
// 2 : ENC_TYPE_TKIP - WPA / PSK
73+
// 4 : ENC_TYPE_CCMP - WPA2 / PSK
74+
// 5 : ENC_TYPE_WEP - WEP
75+
// 7 : ENC_TYPE_NONE - open network
76+
// 8 : ENC_TYPE_AUTO - WPA / WPA2 / PSK
77+
uint8_t typea[] = { 0,2,0,3,1,0,0,4 };
78+
uint32_t type = typea[WiFi.encryptionType(i) -1 &7];
79+
#else
80+
uint32_t type = WiFi.encryptionType(i);
81+
#endif
82+
char stemp1[20];
83+
GetTextIndexed(stemp1, sizeof(stemp1), type, kWifiEncryptionTypes);
84+
return stemp1;
85+
}
86+
6287
bool WifiConfigCounter(void)
6388
{
6489
if (Wifi.config_counter) {
@@ -388,7 +413,8 @@ void WifiBeginAfterScan(void)
388413
WiFi.channel(indexes[i]),
389414
WiFi.RSSI(indexes[i]),
390415
WifiGetRssiAsQuality(WiFi.RSSI(indexes[i])),
391-
GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes));
416+
// GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes));
417+
WifiEncryptionType(indexes[i]).c_str());
392418
MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_CMND_WIFISCAN));
393419
}
394420
} else if (9 == Wifi.scan_state) {

0 commit comments

Comments
 (0)