implementing suggested changes
This commit is contained in:
parent
e9c9fce15d
commit
1a6b1b1953
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 <null> (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));
|
||||
|
Loading…
Reference in New Issue
Block a user