more fixes and still with debug

This commit is contained in:
BennyE 2020-12-22 00:32:48 +01:00
parent 2e393ed195
commit ae3b440835
3 changed files with 45 additions and 2 deletions

View File

@ -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);
}

View File

@ -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 <null> (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);
}

View File

@ -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++;