diff --git a/src/src/DataStructs/WiFi_AP_Candidate.cpp b/src/src/DataStructs/WiFi_AP_Candidate.cpp index 9c1f41e982..2851420eaa 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.cpp +++ b/src/src/DataStructs/WiFi_AP_Candidate.cpp @@ -20,6 +20,14 @@ WiFi_AP_Candidate::WiFi_AP_Candidate() : +#ifdef ESP32 +country({ + .cc = "01", + .schan = 1, + .nchan = 11, + .policy = WIFI_COUNTRY_POLICY_AUTO, +}), +#endif last_seen(0), rssi(0), channel(0), index(0), enc_type(0) { memset(&bits, 0, sizeof(bits)); @@ -82,6 +90,8 @@ WiFi_AP_Candidate::WiFi_AP_Candidate(uint8_t networkItem) : index(0) { bits.wps = it->wps; // FIXME TD-er: Maybe also add other info like 2nd channel, ftm and phy_lr support? + + memcpy(&country, &(it->country), sizeof(wifi_country_t)); } #endif // ifdef ESP32 last_seen = millis(); @@ -196,6 +206,23 @@ String WiFi_AP_Candidate::toString(const String& separator) const { result += encryption_type(); +#ifdef ESP32 + // Country code string + if (country.cc[0] != '\0' && country.cc[1] != '\0') { + result += strformat(F(" '%c%c'"), country.cc[0], country.cc[1]); + switch (country.cc[2]) { + case 'O': // Outdoor + case 'I': // Indoor + case 'X': // "non-country" + result += strformat(F("(%c)"), country.cc[2]); + break; + } + } + if (country.nchan > 0) { + result += strformat(F(" ch: %d..%d"), country.schan, country.schan + country.nchan - 1); + } +#endif + if (phy_known()) { String phy_str; diff --git a/src/src/DataStructs/WiFi_AP_Candidate.h b/src/src/DataStructs/WiFi_AP_Candidate.h index b3ce8f8c35..1be00baeef 100644 --- a/src/src/DataStructs/WiFi_AP_Candidate.h +++ b/src/src/DataStructs/WiFi_AP_Candidate.h @@ -72,6 +72,10 @@ struct WiFi_AP_Candidate { // String key; + #ifdef ESP32 + wifi_country_t country; + #endif + unsigned long last_seen = 0u; MAC_address bssid; int8_t rssi{}; diff --git a/src/src/ESPEasyCore/ESPEasyWifi.cpp b/src/src/ESPEasyCore/ESPEasyWifi.cpp index 808da27408..7d127e78c9 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi.cpp @@ -504,7 +504,7 @@ void AttemptWiFiConnect() { wifi_country_t config = { .cc = "01", .schan = 1, - .nchan = 13, + .nchan = 14, .policy = WIFI_COUNTRY_POLICY_MANUAL, }; esp_wifi_set_country(&config); @@ -1049,7 +1049,7 @@ void WifiScan(bool async, uint8_t channel) { wifi_country_t config = { .cc = "01", .schan = 1, - .nchan = 13, + .nchan = 14, .policy = WIFI_COUNTRY_POLICY_MANUAL, }; esp_wifi_set_country(&config);