1 parent bc8863a commit 2fa269cCopy full SHA for 2fa269c
1 file changed
ports/esp32s2/common-hal/wifi/Radio.c
@@ -160,9 +160,15 @@ mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self) {
160
}
161
162
wifi_ap_record_t ap_info;
163
- esp_wifi_sta_get_ap_info(&ap_info);
164
-
165
- return MP_OBJ_NEW_SMALL_INT(ap_info.rssi);
+ // From esp_wifi.h, the possible return values (typos theirs):
+ // ESP_OK: succeed
+ // ESP_ERR_WIFI_CONN: The station interface don't initialized
166
+ // ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
167
+ if (esp_wifi_sta_get_ap_info(&ap_info) != ESP_OK){
168
+ return mp_const_none;
169
+ } else {
170
+ return mp_obj_new_int(ap_info.rssi);
171
+ }
172
173
174
mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self) {
0 commit comments