Skip to content

Commit 5ab5714

Browse files
committed
cpu/esp_common/esp-now: migration to ESP-IDF v5.4
1 parent 8eeeb99 commit 5ab5714

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cpu/esp_common/esp-now/esp_now_netdev.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "esp_event_loop.h"
3333
#else
3434
#include "esp_event.h"
35+
#include "esp_event_legacy.h"
36+
#include "esp_mac.h"
3537
#endif
3638
#include "esp_now.h"
3739
#include "esp_system.h"
@@ -201,7 +203,11 @@ static const uint8_t _esp_now_mac[6] = { 0x82, 0x73, 0x79, 0x84, 0x79, 0x83 }; /
201203

202204
static bool _in_recv_cb = false;
203205

206+
#ifdef CPU_ESP8266
204207
static IRAM_ATTR void esp_now_recv_cb(const uint8_t *mac, const uint8_t *data, int len)
208+
#else
209+
static IRAM_ATTR void esp_now_recv_cb(const esp_now_recv_info_t *mac, const uint8_t *data, int len)
210+
#endif
205211
{
206212
#if ESP_NOW_UNICAST
207213
if (!_esp_now_scan_peers_done) {
@@ -241,7 +247,11 @@ static IRAM_ATTR void esp_now_recv_cb(const uint8_t *mac, const uint8_t *data, i
241247
return;
242248
}
243249

250+
#ifdef CPU_ESP8266
244251
_esp_now_dev.rx_mac = (uint8_t*)mac;
252+
#else
253+
_esp_now_dev.rx_mac = mac->src_addr;
254+
#endif
245255
_esp_now_dev.rx_data = (uint8_t*)data;
246256
_esp_now_dev.rx_len = len;
247257

@@ -275,7 +285,7 @@ static void IRAM_ATTR esp_now_send_cb(const uint8_t *mac, esp_now_send_status_t
275285
*/
276286
static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *event)
277287
{
278-
switch(event->event_id) {
288+
switch (event->event_id) {
279289
case SYSTEM_EVENT_STA_START:
280290
DEBUG("%s WiFi started\n", __func__);
281291
break;
@@ -322,14 +332,14 @@ esp_now_netdev_t *netdev_esp_now_setup(void)
322332

323333
esp_err_t result;
324334

325-
#if CONFIG_ESP32_WIFI_NVS_ENABLED
335+
#if CONFIG_ESP_WIFI_NVS_ENABLED
326336
result = nvs_flash_init();
327337
if (result != ESP_OK) {
328338
LOG_TAG_ERROR("esp_now",
329339
"nfs_flash_init failed with return value %d\n", result);
330340
return NULL;
331341
}
332-
#endif /* CONFIG_ESP32_WIFI_NVS_ENABLED */
342+
#endif /* CONFIG_ESP_WIFI_NVS_ENABLED */
333343

334344
/* initialize the WiFi driver with default configuration */
335345
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();

0 commit comments

Comments
 (0)