From 210c0ec89c88b50089067f74c2f0893fdd8613b4 Mon Sep 17 00:00:00 2001 From: BennyE Date: Sun, 13 Dec 2020 13:32:12 +0100 Subject: [PATCH 1/6] add country(code) to wifi network objects) --- ports/esp32s2/common-hal/wifi/Network.c | 6 ++++++ shared-bindings/wifi/Network.c | 17 +++++++++++++++++ shared-bindings/wifi/Network.h | 1 + shared-bindings/wifi/Radio.c | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/wifi/Network.c b/ports/esp32s2/common-hal/wifi/Network.c index e90b3d552c..ab60b98f45 100644 --- a/ports/esp32s2/common-hal/wifi/Network.c +++ b/ports/esp32s2/common-hal/wifi/Network.c @@ -48,3 +48,9 @@ mp_obj_t common_hal_wifi_network_get_rssi(wifi_network_obj_t *self) { mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self) { return mp_obj_new_int(self->record.primary); } + +mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) { + const char* cstr = (const char*) self->record.country.cc; + return mp_obj_new_str(cstr, strlen(cstr)); +} + diff --git a/shared-bindings/wifi/Network.c b/shared-bindings/wifi/Network.c index bf970a9c0f..009712ad19 100644 --- a/shared-bindings/wifi/Network.c +++ b/shared-bindings/wifi/Network.c @@ -108,12 +108,29 @@ const mp_obj_property_t wifi_network_channel_obj = { (mp_obj_t)&mp_const_none_obj }, }; +//| country: str +//| """String id of the country code""" +//| +STATIC mp_obj_t wifi_network_get_country(mp_obj_t self) { + return common_hal_wifi_network_get_country(self); + +} +MP_DEFINE_CONST_FUN_OBJ_1(wifi_network_get_country_obj, wifi_network_get_country); + +const mp_obj_property_t wifi_network_country_obj = { + .base.type = &mp_type_property, + .proxy = { (mp_obj_t)&wifi_network_get_country_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj }, +}; + STATIC const mp_rom_map_elem_t wifi_network_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_ssid), MP_ROM_PTR(&wifi_network_ssid_obj) }, { MP_ROM_QSTR(MP_QSTR_bssid), MP_ROM_PTR(&wifi_network_bssid_obj) }, { MP_ROM_QSTR(MP_QSTR_rssi), MP_ROM_PTR(&wifi_network_rssi_obj) }, { MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&wifi_network_channel_obj) }, + { MP_ROM_QSTR(MP_QSTR_country), MP_ROM_PTR(&wifi_network_country_obj) }, }; STATIC MP_DEFINE_CONST_DICT(wifi_network_locals_dict, wifi_network_locals_dict_table); diff --git a/shared-bindings/wifi/Network.h b/shared-bindings/wifi/Network.h index c9bbc685e6..e672e3108a 100644 --- a/shared-bindings/wifi/Network.h +++ b/shared-bindings/wifi/Network.h @@ -39,5 +39,6 @@ extern mp_obj_t common_hal_wifi_network_get_ssid(wifi_network_obj_t *self); extern mp_obj_t common_hal_wifi_network_get_bssid(wifi_network_obj_t *self); extern mp_obj_t common_hal_wifi_network_get_rssi(wifi_network_obj_t *self); extern mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self); +extern mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_WIFI_NETWORK_H diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index edbd9fd2ff..723572a321 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -295,7 +295,7 @@ const mp_obj_property_t wifi_radio_ipv4_dns_obj = { }; //| ap_info: Optional[Network] -//| """Network object containing BSSID, SSID, channel, and RSSI when connected to an access point. None otherwise.""" +//| """Network object containing BSSID, SSID, channel, country and RSSI when connected to an access point. None otherwise.""" //| STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) { return common_hal_wifi_radio_get_ap_info(self); From 2e393ed1957dae806c8e98e68bbcb82f1fa1ffdb Mon Sep 17 00:00:00 2001 From: BennyE Date: Sun, 20 Dec 2020 22:03:38 +0100 Subject: [PATCH 2/6] adding debug infos --- ports/esp32s2/common-hal/wifi/Radio.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 49cb8ec30f..1a242da058 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -42,6 +42,10 @@ #define MAC_ADDRESS_LENGTH 6 +#include "components/log/include/esp_log.h" + +static const char* TAG = "wifi"; + static void start_station(wifi_radio_obj_t *self) { if (self->sta_mode) { return; @@ -194,6 +198,19 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){ return mp_const_none; } else { + ESP_EARLY_LOGW(TAG, "ssid: %s", self->ap_info.record.ssid); + ESP_EARLY_LOGW(TAG, "channel: %d", self->ap_info.record.primary); + ESP_EARLY_LOGW(TAG, "secondary: %d", self->ap_info.record.second); + ESP_EARLY_LOGW(TAG, "rssi: %d", self->ap_info.record.rssi); + ESP_EARLY_LOGW(TAG, "authmode: %d", self->ap_info.record.authmode); + ESP_EARLY_LOGW(TAG, "pairwise_cipher: %d", self->ap_info.record.pairwise_cipher); + ESP_EARLY_LOGW(TAG, "group_cipher: %d", self->ap_info.record.group_cipher); + ESP_EARLY_LOGW(TAG, "11b: %d", self->ap_info.record.phy_11b); + ESP_EARLY_LOGW(TAG, "11g: %d", self->ap_info.record.phy_11g); + ESP_EARLY_LOGW(TAG, "11n: %d", self->ap_info.record.phy_11n); + ESP_EARLY_LOGW(TAG, "phy_lr: %d", self->ap_info.record.phy_lr); + ESP_EARLY_LOGW(TAG, "country: %s", self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "countryCC: %s", self->ap_info.record.country.cc); memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t)); return MP_OBJ_FROM_PTR(ap_info); } From ae3b4408350e5623ef769a2860984d2d8937be59 Mon Sep 17 00:00:00 2001 From: BennyE Date: Tue, 22 Dec 2020 00:32:48 +0100 Subject: [PATCH 3/6] more fixes and still with debug --- ports/esp32s2/common-hal/wifi/Network.c | 3 +- ports/esp32s2/common-hal/wifi/Radio.c | 38 ++++++++++++++++++- .../esp32s2/common-hal/wifi/ScannedNetworks.c | 6 +++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Network.c b/ports/esp32s2/common-hal/wifi/Network.c index ab60b98f45..d134db057e 100644 --- a/ports/esp32s2/common-hal/wifi/Network.c +++ b/ports/esp32s2/common-hal/wifi/Network.c @@ -51,6 +51,7 @@ mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self) { mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) { const char* cstr = (const char*) self->record.country.cc; - return mp_obj_new_str(cstr, strlen(cstr)); + // We know that we only want the CC thus limiting to two chars + return mp_obj_new_str(cstr, 2); } diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 1a242da058..08d8bbcd50 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -198,6 +198,37 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){ return mp_const_none; } else { + ESP_EARLY_LOGW(TAG, "country before handler country: %s", (char *)&self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "country memory at: %p", self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "countryCC memory at: %p", self->ap_info.record.country.cc); + ESP_EARLY_LOGW(TAG, "countryCC strlen: %d", strlen(self->ap_info.record.country.cc)); + // The struct member appears to be (not NULL!), I don't know how to properly test for it. + // If the ESP-IDF starts working fine, this "if" wouldn't trigger. + // Note: It is possible that Wi-Fi APs don't have a CC set, then even after this workaround + // the element would remain empty. + if (strlen(self->ap_info.record.country.cc) == 0) { + // Workaround to fill country related information in ap_info until ESP-IDF carries a fix + // esp_wifi_sta_get_ap_info does not appear to fill wifi_country_t (e.g. country.cc) details + // (IDFGH-4437) #6267 + ESP_EARLY_LOGW(TAG, "Triggered missing country workaround"); + if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { + ESP_EARLY_LOGW(TAG, "Workaround worked fine!"); + ESP_EARLY_LOGW(TAG, "country: %d", self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "CC: %s", self->ap_info.record.country.cc); + } else { + ESP_EARLY_LOGW(TAG, "Workaround failed!"); + } + //} else { + // ESP_EARLY_LOGW(TAG, "Triggered missing country workaround IN ELSE"); + // //memset(&self->ap_info.record.country, 0, sizeof(wifi_country_t)); + // if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { + // //if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { + // ESP_EARLY_LOGW(TAG, "Workaround worked fine!"); + // ESP_EARLY_LOGW(TAG, "CC: %s", self->ap_info.record.country.cc); + // } else { + // ESP_EARLY_LOGW(TAG, "Workaround failed!"); + // } + } ESP_EARLY_LOGW(TAG, "ssid: %s", self->ap_info.record.ssid); ESP_EARLY_LOGW(TAG, "channel: %d", self->ap_info.record.primary); ESP_EARLY_LOGW(TAG, "secondary: %d", self->ap_info.record.second); @@ -209,8 +240,13 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { ESP_EARLY_LOGW(TAG, "11g: %d", self->ap_info.record.phy_11g); ESP_EARLY_LOGW(TAG, "11n: %d", self->ap_info.record.phy_11n); ESP_EARLY_LOGW(TAG, "phy_lr: %d", self->ap_info.record.phy_lr); - ESP_EARLY_LOGW(TAG, "country: %s", self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "ap_info.record: %s", self->ap_info.record); + ESP_EARLY_LOGW(TAG, "country with cast: %s", (char *)&self->ap_info.record.country); + //ESP_EARLY_LOGW(TAG, "country: %s", self->ap_info.record.country); + ESP_EARLY_LOGW(TAG, "country memory at: %p", self->ap_info.record.country); ESP_EARLY_LOGW(TAG, "countryCC: %s", self->ap_info.record.country.cc); + ESP_EARLY_LOGW(TAG, "countryCC memory at: %p", self->ap_info.record.country.cc); + ESP_EARLY_LOGW(TAG, "countryCC strlen: %d", strlen(self->ap_info.record.country.cc)); memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t)); return MP_OBJ_FROM_PTR(ap_info); } diff --git a/ports/esp32s2/common-hal/wifi/ScannedNetworks.c b/ports/esp32s2/common-hal/wifi/ScannedNetworks.c index cc733308db..0540ffc5cc 100644 --- a/ports/esp32s2/common-hal/wifi/ScannedNetworks.c +++ b/ports/esp32s2/common-hal/wifi/ScannedNetworks.c @@ -39,6 +39,10 @@ #include "components/esp_wifi/include/esp_wifi.h" +#include "components/log/include/esp_log.h" + +static const char* TAG = "wifi"; + static void wifi_scannednetworks_done(wifi_scannednetworks_obj_t *self) { self->done = true; if (self->results != NULL) { @@ -117,6 +121,8 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t); entry->base.type = &wifi_network_type; + // benny remove again + ESP_EARLY_LOGW(TAG, "scan country: %s", &self->results[self->current_result].country); memcpy(&entry->record, &self->results[self->current_result], sizeof(wifi_ap_record_t)); self->current_result++; From e9c9fce15ddf292763cf4375c6e5e0c3f25d9e35 Mon Sep 17 00:00:00 2001 From: BennyE Date: Wed, 23 Dec 2020 14:59:09 +0100 Subject: [PATCH 4/6] Remove debug log messages --- ports/esp32s2/common-hal/wifi/Radio.c | 41 ++----------------- .../esp32s2/common-hal/wifi/ScannedNetworks.c | 6 --- 2 files changed, 3 insertions(+), 44 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index 08d8bbcd50..d4db5d08d3 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -198,55 +198,20 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){ return mp_const_none; } else { - ESP_EARLY_LOGW(TAG, "country before handler country: %s", (char *)&self->ap_info.record.country); - ESP_EARLY_LOGW(TAG, "country memory at: %p", self->ap_info.record.country); - ESP_EARLY_LOGW(TAG, "countryCC memory at: %p", self->ap_info.record.country.cc); - ESP_EARLY_LOGW(TAG, "countryCC strlen: %d", strlen(self->ap_info.record.country.cc)); // The struct member appears to be (not NULL!), I don't know how to properly test for it. - // If the ESP-IDF starts working fine, this "if" wouldn't trigger. + // When the ESP-IDF starts working fine (when their bugfix is available), this "if" wouldn't trigger. // Note: It is possible that Wi-Fi APs don't have a CC set, then even after this workaround // the element would remain empty. if (strlen(self->ap_info.record.country.cc) == 0) { // Workaround to fill country related information in ap_info until ESP-IDF carries a fix // esp_wifi_sta_get_ap_info does not appear to fill wifi_country_t (e.g. country.cc) details // (IDFGH-4437) #6267 - ESP_EARLY_LOGW(TAG, "Triggered missing country workaround"); if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { - ESP_EARLY_LOGW(TAG, "Workaround worked fine!"); - ESP_EARLY_LOGW(TAG, "country: %d", self->ap_info.record.country); - ESP_EARLY_LOGW(TAG, "CC: %s", self->ap_info.record.country.cc); + ESP_EARLY_LOGW(TAG, "Country Code: %s", self->ap_info.record.country.cc); } else { - ESP_EARLY_LOGW(TAG, "Workaround failed!"); + ESP_EARLY_LOGW(TAG, "Country Code - Workaround failed!"); } - //} else { - // ESP_EARLY_LOGW(TAG, "Triggered missing country workaround IN ELSE"); - // //memset(&self->ap_info.record.country, 0, sizeof(wifi_country_t)); - // if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { - // //if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { - // ESP_EARLY_LOGW(TAG, "Workaround worked fine!"); - // ESP_EARLY_LOGW(TAG, "CC: %s", self->ap_info.record.country.cc); - // } else { - // ESP_EARLY_LOGW(TAG, "Workaround failed!"); - // } } - ESP_EARLY_LOGW(TAG, "ssid: %s", self->ap_info.record.ssid); - ESP_EARLY_LOGW(TAG, "channel: %d", self->ap_info.record.primary); - ESP_EARLY_LOGW(TAG, "secondary: %d", self->ap_info.record.second); - ESP_EARLY_LOGW(TAG, "rssi: %d", self->ap_info.record.rssi); - ESP_EARLY_LOGW(TAG, "authmode: %d", self->ap_info.record.authmode); - ESP_EARLY_LOGW(TAG, "pairwise_cipher: %d", self->ap_info.record.pairwise_cipher); - ESP_EARLY_LOGW(TAG, "group_cipher: %d", self->ap_info.record.group_cipher); - ESP_EARLY_LOGW(TAG, "11b: %d", self->ap_info.record.phy_11b); - ESP_EARLY_LOGW(TAG, "11g: %d", self->ap_info.record.phy_11g); - ESP_EARLY_LOGW(TAG, "11n: %d", self->ap_info.record.phy_11n); - ESP_EARLY_LOGW(TAG, "phy_lr: %d", self->ap_info.record.phy_lr); - ESP_EARLY_LOGW(TAG, "ap_info.record: %s", self->ap_info.record); - ESP_EARLY_LOGW(TAG, "country with cast: %s", (char *)&self->ap_info.record.country); - //ESP_EARLY_LOGW(TAG, "country: %s", self->ap_info.record.country); - ESP_EARLY_LOGW(TAG, "country memory at: %p", self->ap_info.record.country); - ESP_EARLY_LOGW(TAG, "countryCC: %s", self->ap_info.record.country.cc); - ESP_EARLY_LOGW(TAG, "countryCC memory at: %p", self->ap_info.record.country.cc); - ESP_EARLY_LOGW(TAG, "countryCC strlen: %d", strlen(self->ap_info.record.country.cc)); memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t)); return MP_OBJ_FROM_PTR(ap_info); } diff --git a/ports/esp32s2/common-hal/wifi/ScannedNetworks.c b/ports/esp32s2/common-hal/wifi/ScannedNetworks.c index 0540ffc5cc..cc733308db 100644 --- a/ports/esp32s2/common-hal/wifi/ScannedNetworks.c +++ b/ports/esp32s2/common-hal/wifi/ScannedNetworks.c @@ -39,10 +39,6 @@ #include "components/esp_wifi/include/esp_wifi.h" -#include "components/log/include/esp_log.h" - -static const char* TAG = "wifi"; - static void wifi_scannednetworks_done(wifi_scannednetworks_obj_t *self) { self->done = true; if (self->results != NULL) { @@ -121,8 +117,6 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t); entry->base.type = &wifi_network_type; - // benny remove again - ESP_EARLY_LOGW(TAG, "scan country: %s", &self->results[self->current_result].country); memcpy(&entry->record, &self->results[self->current_result], sizeof(wifi_ap_record_t)); self->current_result++; From 1a6b1b1953b20a0ddd8b5f76d6dc366399ea1aee Mon Sep 17 00:00:00 2001 From: BennyE Date: Thu, 24 Dec 2020 00:37:37 +0100 Subject: [PATCH 5/6] implementing suggested changes --- ports/esp32s2/common-hal/wifi/Network.c | 5 +++-- ports/esp32s2/common-hal/wifi/Radio.c | 17 +++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Network.c b/ports/esp32s2/common-hal/wifi/Network.c index d134db057e..be4935dba5 100644 --- a/ports/esp32s2/common-hal/wifi/Network.c +++ b/ports/esp32s2/common-hal/wifi/Network.c @@ -51,7 +51,8 @@ mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self) { mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) { const char* cstr = (const char*) self->record.country.cc; - // We know that we only want the CC thus limiting to two chars + // To address esp_wifi_get_country() returned/set wifi_country_t structure + // doesn't follow the documented behaviour (IDFGH-4486) #6315 + // 2 instead of strlen(cstr) which would be 6 and contain full element return mp_obj_new_str(cstr, 2); } - diff --git a/ports/esp32s2/common-hal/wifi/Radio.c b/ports/esp32s2/common-hal/wifi/Radio.c index d4db5d08d3..c498501c7f 100644 --- a/ports/esp32s2/common-hal/wifi/Radio.c +++ b/ports/esp32s2/common-hal/wifi/Radio.c @@ -42,10 +42,6 @@ #define MAC_ADDRESS_LENGTH 6 -#include "components/log/include/esp_log.h" - -static const char* TAG = "wifi"; - static void start_station(wifi_radio_obj_t *self) { if (self->sta_mode) { return; @@ -198,18 +194,15 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) { if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){ return mp_const_none; } else { - // The struct member appears to be (not NULL!), I don't know how to properly test for it. - // When the ESP-IDF starts working fine (when their bugfix is available), this "if" wouldn't trigger. - // Note: It is possible that Wi-Fi APs don't have a CC set, then even after this workaround - // the element would remain empty. if (strlen(self->ap_info.record.country.cc) == 0) { // Workaround to fill country related information in ap_info until ESP-IDF carries a fix // esp_wifi_sta_get_ap_info does not appear to fill wifi_country_t (e.g. country.cc) details // (IDFGH-4437) #6267 - if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) { - ESP_EARLY_LOGW(TAG, "Country Code: %s", self->ap_info.record.country.cc); - } else { - ESP_EARLY_LOGW(TAG, "Country Code - Workaround failed!"); + // Note: It is possible that Wi-Fi APs don't have a CC set, then even after this workaround + // the element would remain empty. + memset(&self->ap_info.record.country, 0, sizeof(wifi_country_t)); + if (esp_wifi_get_country(&self->ap_info.record.country) != ESP_OK) { + return mp_const_none; } } memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t)); From 64bb055700d425617adff7748890354d925248fd Mon Sep 17 00:00:00 2001 From: BennyE Date: Thu, 24 Dec 2020 15:40:53 +0100 Subject: [PATCH 6/6] Updating comment to reflect feedback of espressif from IDFGH-4486 -> works correct as per the protocol --- ports/esp32s2/common-hal/wifi/Network.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ports/esp32s2/common-hal/wifi/Network.c b/ports/esp32s2/common-hal/wifi/Network.c index be4935dba5..2674df0651 100644 --- a/ports/esp32s2/common-hal/wifi/Network.c +++ b/ports/esp32s2/common-hal/wifi/Network.c @@ -51,8 +51,6 @@ mp_obj_t common_hal_wifi_network_get_channel(wifi_network_obj_t *self) { mp_obj_t common_hal_wifi_network_get_country(wifi_network_obj_t *self) { const char* cstr = (const char*) self->record.country.cc; - // To address esp_wifi_get_country() returned/set wifi_country_t structure - // doesn't follow the documented behaviour (IDFGH-4486) #6315 - // 2 instead of strlen(cstr) which would be 6 and contain full element + // 2 instead of strlen(cstr) as this gives us only the country-code return mp_obj_new_str(cstr, 2); }