Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 63d9473

Browse files
geza-pycompeter-pycom
authored andcommitted
Fix a crash what happens when espnow.init() is called without previous WLAN init
1 parent e805c01 commit 63d9473

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

esp32/mods/modespnow.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_espnow_peer_send_obj, mod_espnow_peer_send)
367367

368368
STATIC mp_obj_t mod_espnow_init() {
369369

370-
if(initialized == false) {
370+
if(wlan_obj.started == false) {
371+
nlr_raise(mp_obj_new_exception_msg(&mp_type_RuntimeError, "ESP-NOW module needs that WLAN is already initialized!"));
372+
}
373+
else if(initialized == false) {
371374

372375
mod_esp_espnow_exceptions(esp_now_init());
373376
mod_esp_espnow_exceptions(esp_now_register_recv_cb(recv_cb));

0 commit comments

Comments
 (0)