Skip to content

Commit

Permalink
[ESP32 WiFi] Add info about found AP from scan
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-er committed May 1, 2024
1 parent 406450c commit aad024e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
27 changes: 27 additions & 0 deletions src/src/DataStructs/WiFi_AP_Candidate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/src/DataStructs/WiFi_AP_Candidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
4 changes: 2 additions & 2 deletions src/src/ESPEasyCore/ESPEasyWifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit aad024e

Please sign in to comment.