diff --git a/tasmota/include/tasmota.h b/tasmota/include/tasmota.h index e993167e6..4a2aaa813 100644 --- a/tasmota/include/tasmota.h +++ b/tasmota/include/tasmota.h @@ -314,6 +314,8 @@ enum InitStates {INIT_NONE, INIT_GPIOS, INIT_DONE}; 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}; +enum WifiTestOptions {WIFI_NOT_TESTING, WIFI_TESTING, WIFI_TEST_FINISHED, WIFI_TEST_FINISHED_BAD}; + enum SwitchModeOptions {TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON, PUSHBUTTON_INV, PUSHBUTTONHOLD, PUSHBUTTONHOLD_INV, PUSHBUTTON_TOGGLE, TOGGLEMULTI, FOLLOWMULTI, FOLLOWMULTI_INV, PUSHHOLDMULTI, PUSHHOLDMULTI_INV, PUSHON, PUSHON_INV, PUSH_IGNORE, MAX_SWITCH_OPTION}; diff --git a/tasmota/include/tasmota_globals.h b/tasmota/include/tasmota_globals.h index deaebd316..abdb5deb2 100644 --- a/tasmota/include/tasmota_globals.h +++ b/tasmota/include/tasmota_globals.h @@ -593,38 +593,4 @@ bool first_device_group_is_local = true; /*********************************************************************************************/ - -enum WifiTestOptions { WIFI_NOT_TESTING, WIFI_TESTING, WIFI_TEST_FINISHED, WIFI_TEST_FINISHED_BAD }; - -struct WIFI { - uint32_t last_event = 0; // Last wifi connection event - uint32_t downtime = 0; // Wifi down duration - uint16_t link_count = 0; // Number of wifi re-connect - uint8_t counter; - uint8_t retry_init; - uint8_t retry; - uint8_t max_retry; - uint8_t status; - uint8_t config_type = 0; - uint8_t config_counter = 0; - uint8_t scan_state; - uint8_t bssid[6]; - int8_t best_network_db; - uint8_t wifiTest = WIFI_NOT_TESTING; - uint8_t wifi_test_counter = 0; - uint16_t save_data_counter = 0; - uint8_t old_wificonfig = MAX_WIFI_OPTION; // means "nothing yet saved here" - bool wifi_test_AP_TIMEOUT = false; - bool wifi_Test_Restart = false; - bool wifi_Test_Save_SSID2 = false; -} Wifi; - -// Reference. WiFi.encryptionType = -// 2 : ENC_TYPE_TKIP - WPA / PSK -// 4 : ENC_TYPE_CCMP - WPA2 / PSK -// 5 : ENC_TYPE_WEP - WEP -// 7 : ENC_TYPE_NONE - open network -// 8 : ENC_TYPE_AUTO - WPA / WPA2 / PSK -const char kWifiEncryptionTypes[] PROGMEM = "0" "|" "1" "|" "WPA/PSK" "|" "3" "|" "WPA2/PSK" "|" "WEP" "|" "6" "|" "OPEN" "|" "WPA/WPA2/PSK"; - #endif // _TASMOTA_GLOBALS_H_ diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 64edd25f5..ba44c8192 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -96,6 +96,29 @@ const uint32_t VERSION_MARKER[] PROGMEM = { 0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A }; +struct WIFI { + uint32_t last_event = 0; // Last wifi connection event + uint32_t downtime = 0; // Wifi down duration + uint16_t link_count = 0; // Number of wifi re-connect + uint8_t counter; + uint8_t retry_init; + uint8_t retry; + uint8_t max_retry; + uint8_t status; + uint8_t config_type = 0; + uint8_t config_counter = 0; + uint8_t scan_state; + uint8_t bssid[6]; + int8_t best_network_db; + uint8_t wifiTest = WIFI_NOT_TESTING; + uint8_t wifi_test_counter = 0; + uint16_t save_data_counter = 0; + uint8_t old_wificonfig = MAX_WIFI_OPTION; // means "nothing yet saved here" + bool wifi_test_AP_TIMEOUT = false; + bool wifi_Test_Restart = false; + bool wifi_Test_Save_SSID2 = false; +} Wifi; + typedef struct { uint16_t valid; // 280 (RTC memory offset 100 - sizeof(RTCRBT)) uint8_t fast_reboot_count; // 282 diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index e82314f00..2772cdcd6 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -137,7 +137,8 @@ void CmndWifiScan(void) WiFi.channel(indexes[i]), WiFi.RSSI(indexes[i]), WifiGetRssiAsQuality(WiFi.RSSI(indexes[i])), - GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes)); +// GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes)); + WifiEncryptionType(indexes[i]).c_str()); if ( ResponseSize() < ResponseLength() + 300 ) { break; } if ( i < WiFi.scanComplete() -1 ) { ResponseAppend_P(PSTR(",")); } //AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "MAX SIZE: %d, SIZE: %d"),ResponseSize(),ResponseLength()); diff --git a/tasmota/tasmota_support/support_wifi.ino b/tasmota/tasmota_support/support_wifi.ino index 9b51525de..00608dc1d 100644 --- a/tasmota/tasmota_support/support_wifi.ino +++ b/tasmota/tasmota_support/support_wifi.ino @@ -45,8 +45,7 @@ const uint8_t WIFI_RETRY_OFFSET_SEC = WIFI_RETRY_SECONDS; // seconds #include // IPv6 DualStack #endif // LWIP_IPV6=1 -int WifiGetRssiAsQuality(int rssi) -{ +int WifiGetRssiAsQuality(int rssi) { int quality = 0; if (rssi <= -100) { @@ -59,6 +58,32 @@ int WifiGetRssiAsQuality(int rssi) return quality; } +// 0 1 2 3 4 +const char kWifiEncryptionTypes[] PROGMEM = "OPEN|WEP|WPA/PSK|WPA2/PSK|WPA/WPA2/PSK" +#ifdef ESP32 +// 5 6 7 8 + "|WPA2ENTERPRISE|WPA3/PSK|WPA2/WPA3/PSK|WAPI/PSK" +#endif // ESP32 +; + +String WifiEncryptionType(uint32_t i) { +#ifdef ESP8266 + // Reference. WiFi.encryptionType = + // 2 : ENC_TYPE_TKIP - WPA / PSK + // 4 : ENC_TYPE_CCMP - WPA2 / PSK + // 5 : ENC_TYPE_WEP - WEP + // 7 : ENC_TYPE_NONE - open network + // 8 : ENC_TYPE_AUTO - WPA / WPA2 / PSK + uint8_t typea[] = { 0,2,0,3,1,0,0,4 }; + uint32_t type = typea[WiFi.encryptionType(i) -1 &7]; +#else + uint32_t type = WiFi.encryptionType(i); +#endif + char stemp1[20]; + GetTextIndexed(stemp1, sizeof(stemp1), type, kWifiEncryptionTypes); + return stemp1; +} + bool WifiConfigCounter(void) { if (Wifi.config_counter) { @@ -388,7 +413,8 @@ void WifiBeginAfterScan(void) WiFi.channel(indexes[i]), WiFi.RSSI(indexes[i]), WifiGetRssiAsQuality(WiFi.RSSI(indexes[i])), - GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes)); +// GetTextIndexed(stemp1, sizeof(stemp1), WiFi.encryptionType(indexes[i]), kWifiEncryptionTypes)); + WifiEncryptionType(indexes[i]).c_str()); MqttPublishPrefixTopicRulesProcess_P(RESULT_OR_STAT, PSTR(D_CMND_WIFISCAN)); } } else if (9 == Wifi.scan_state) {