@@ -198,6 +198,37 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) {
198
198
if (esp_wifi_sta_get_ap_info (& self -> ap_info .record ) != ESP_OK ){
199
199
return mp_const_none ;
200
200
} else {
201
+ ESP_EARLY_LOGW (TAG , "country before handler country: %s" , (char * )& self -> ap_info .record .country );
202
+ ESP_EARLY_LOGW (TAG , "country memory at: %p" , self -> ap_info .record .country );
203
+ ESP_EARLY_LOGW (TAG , "countryCC memory at: %p" , self -> ap_info .record .country .cc );
204
+ ESP_EARLY_LOGW (TAG , "countryCC strlen: %d" , strlen (self -> ap_info .record .country .cc ));
205
+ // The struct member appears to be <null> (not NULL!), I don't know how to properly test for it.
206
+ // If the ESP-IDF starts working fine, this "if" wouldn't trigger.
207
+ // Note: It is possible that Wi-Fi APs don't have a CC set, then even after this workaround
208
+ // the element would remain empty.
209
+ if (strlen (self -> ap_info .record .country .cc ) == 0 ) {
210
+ // Workaround to fill country related information in ap_info until ESP-IDF carries a fix
211
+ // esp_wifi_sta_get_ap_info does not appear to fill wifi_country_t (e.g. country.cc) details
212
+ // (IDFGH-4437) #6267
213
+ ESP_EARLY_LOGW (TAG , "Triggered missing country workaround" );
214
+ if (esp_wifi_get_country (& self -> ap_info .record .country ) == ESP_OK ) {
215
+ ESP_EARLY_LOGW (TAG , "Workaround worked fine!" );
216
+ ESP_EARLY_LOGW (TAG , "country: %d" , self -> ap_info .record .country );
217
+ ESP_EARLY_LOGW (TAG , "CC: %s" , self -> ap_info .record .country .cc );
218
+ } else {
219
+ ESP_EARLY_LOGW (TAG , "Workaround failed!" );
220
+ }
221
+ //} else {
222
+ // ESP_EARLY_LOGW(TAG, "Triggered missing country workaround IN ELSE");
223
+ // //memset(&self->ap_info.record.country, 0, sizeof(wifi_country_t));
224
+ // if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) {
225
+ // //if (esp_wifi_get_country(&self->ap_info.record.country) == ESP_OK) {
226
+ // ESP_EARLY_LOGW(TAG, "Workaround worked fine!");
227
+ // ESP_EARLY_LOGW(TAG, "CC: %s", self->ap_info.record.country.cc);
228
+ // } else {
229
+ // ESP_EARLY_LOGW(TAG, "Workaround failed!");
230
+ // }
231
+ }
201
232
ESP_EARLY_LOGW (TAG , "ssid: %s" , self -> ap_info .record .ssid );
202
233
ESP_EARLY_LOGW (TAG , "channel: %d" , self -> ap_info .record .primary );
203
234
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) {
209
240
ESP_EARLY_LOGW (TAG , "11g: %d" , self -> ap_info .record .phy_11g );
210
241
ESP_EARLY_LOGW (TAG , "11n: %d" , self -> ap_info .record .phy_11n );
211
242
ESP_EARLY_LOGW (TAG , "phy_lr: %d" , self -> ap_info .record .phy_lr );
212
- ESP_EARLY_LOGW (TAG , "country: %s" , self -> ap_info .record .country );
243
+ ESP_EARLY_LOGW (TAG , "ap_info.record: %s" , self -> ap_info .record );
244
+ ESP_EARLY_LOGW (TAG , "country with cast: %s" , (char * )& self -> ap_info .record .country );
245
+ //ESP_EARLY_LOGW(TAG, "country: %s", self->ap_info.record.country);
246
+ ESP_EARLY_LOGW (TAG , "country memory at: %p" , self -> ap_info .record .country );
213
247
ESP_EARLY_LOGW (TAG , "countryCC: %s" , self -> ap_info .record .country .cc );
248
+ ESP_EARLY_LOGW (TAG , "countryCC memory at: %p" , self -> ap_info .record .country .cc );
249
+ ESP_EARLY_LOGW (TAG , "countryCC strlen: %d" , strlen (self -> ap_info .record .country .cc ));
214
250
memcpy (& ap_info -> record , & self -> ap_info .record , sizeof (wifi_ap_record_t ));
215
251
return MP_OBJ_FROM_PTR (ap_info );
216
252
}
0 commit comments