File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -260,10 +260,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_status_obj, esp_status);
260
260
STATIC mp_obj_t * esp_scan_list = NULL ;
261
261
262
262
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
+
263
270
mp_obj_t list = mp_obj_new_list (0 , NULL );
264
271
wifi_scan_config_t config = { 0 };
265
272
// 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.
267
273
esp_err_t status = esp_wifi_scan_start (& config , 1 );
268
274
if (status == 0 ) {
269
275
uint16_t count = 0 ;
You can’t perform that action at this time.
0 commit comments