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

Commit e805c01

Browse files
geza-pycompeter-pycom
authored andcommitted
Fix an issue which results that ESP_ERR_ESPNOW_IF is dropped if WIFI is configured in AP mode
1 parent e7f83a7 commit e805c01

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

esp32/mods/modespnow.c

+13
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "modespnow.h"
6161
#include "mpirq.h"
6262
#include "pycom_general_util.h"
63+
#include "modwlan.h"
6364

6465
/******************************************************************************
6566
DEFINE CONSTANTS
@@ -243,6 +244,9 @@ STATIC void mod_esp_espnow_exceptions(esp_err_t e) {
243244
case ESP_ERR_ESPNOW_EXIST:
244245
mp_raise_msg(&mp_type_OSError, "ESP-Now Peer Exists");
245246
break;
247+
case ESP_ERR_ESPNOW_IF:
248+
mp_raise_msg(&mp_type_OSError, "ESP-Now Wifi Interface error");
249+
break;
246250
default:
247251
nlr_raise(mp_obj_new_exception_msg_varg(
248252
&mp_type_RuntimeError, "ESP-Now Unknown Error 0x%04x", e
@@ -444,6 +448,15 @@ STATIC mp_obj_t mod_espnow_add_peer(size_t n_args, const mp_obj_t *args) {
444448
else {
445449
peer.encrypt = false;
446450
}
451+
452+
// Use the WIFI Station interface if configured otherwise use AP interface
453+
if(wlan_obj.esp_netif_STA) {
454+
peer.ifidx = ESP_IF_WIFI_STA;
455+
}
456+
else if(wlan_obj.esp_netif_AP) {
457+
peer.ifidx = ESP_IF_WIFI_AP;
458+
}
459+
447460
mod_esp_espnow_exceptions(esp_now_add_peer(&peer));
448461

449462
mod_espnow_peer_obj_t *peer_obj = m_new_obj(mod_espnow_peer_obj_t);

0 commit comments

Comments
 (0)