Skip to content

Commit 60eda02

Browse files
committed
esp32/modnetwork: Check that STA is active before trying to scan.
1 parent f59b735 commit 60eda02

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

esp32/modnetwork.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_status_obj, esp_status);
260260
STATIC mp_obj_t *esp_scan_list = NULL;
261261

262262
STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
263+
// check that STA mode is active
264+
wifi_mode_t mode;
265+
ESP_EXCEPTIONS(esp_wifi_get_mode(&mode));
266+
if ((mode & WIFI_MODE_STA) == 0) {
267+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "STA must be active"));
268+
}
269+
263270
mp_obj_t list = mp_obj_new_list(0, NULL);
264271
wifi_scan_config_t config = { 0 };
265272
// XXX how do we scan hidden APs (and if we can scan them, are they really hidden?)
266-
// XXX hangs if interface isn't active yet.
267273
esp_err_t status = esp_wifi_scan_start(&config, 1);
268274
if (status == 0) {
269275
uint16_t count = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy