|
32 | 32 | #include "esp_event_loop.h" |
33 | 33 | #else |
34 | 34 | #include "esp_event.h" |
| 35 | +#include "esp_event_legacy.h" |
| 36 | +#include "esp_mac.h" |
35 | 37 | #endif |
36 | 38 | #include "esp_now.h" |
37 | 39 | #include "esp_system.h" |
@@ -201,7 +203,11 @@ static const uint8_t _esp_now_mac[6] = { 0x82, 0x73, 0x79, 0x84, 0x79, 0x83 }; / |
201 | 203 |
|
202 | 204 | static bool _in_recv_cb = false; |
203 | 205 |
|
| 206 | +#ifdef CPU_ESP8266 |
204 | 207 | 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 |
205 | 211 | { |
206 | 212 | #if ESP_NOW_UNICAST |
207 | 213 | 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 |
241 | 247 | return; |
242 | 248 | } |
243 | 249 |
|
| 250 | +#ifdef CPU_ESP8266 |
244 | 251 | _esp_now_dev.rx_mac = (uint8_t*)mac; |
| 252 | +#else |
| 253 | + _esp_now_dev.rx_mac = mac->src_addr; |
| 254 | +#endif |
245 | 255 | _esp_now_dev.rx_data = (uint8_t*)data; |
246 | 256 | _esp_now_dev.rx_len = len; |
247 | 257 |
|
@@ -275,7 +285,7 @@ static void IRAM_ATTR esp_now_send_cb(const uint8_t *mac, esp_now_send_status_t |
275 | 285 | */ |
276 | 286 | static esp_err_t IRAM_ATTR _esp_system_event_handler(void *ctx, system_event_t *event) |
277 | 287 | { |
278 | | - switch(event->event_id) { |
| 288 | + switch (event->event_id) { |
279 | 289 | case SYSTEM_EVENT_STA_START: |
280 | 290 | DEBUG("%s WiFi started\n", __func__); |
281 | 291 | break; |
@@ -322,14 +332,14 @@ esp_now_netdev_t *netdev_esp_now_setup(void) |
322 | 332 |
|
323 | 333 | esp_err_t result; |
324 | 334 |
|
325 | | -#if CONFIG_ESP32_WIFI_NVS_ENABLED |
| 335 | +#if CONFIG_ESP_WIFI_NVS_ENABLED |
326 | 336 | result = nvs_flash_init(); |
327 | 337 | if (result != ESP_OK) { |
328 | 338 | LOG_TAG_ERROR("esp_now", |
329 | 339 | "nfs_flash_init failed with return value %d\n", result); |
330 | 340 | return NULL; |
331 | 341 | } |
332 | | -#endif /* CONFIG_ESP32_WIFI_NVS_ENABLED */ |
| 342 | +#endif /* CONFIG_ESP_WIFI_NVS_ENABLED */ |
333 | 343 |
|
334 | 344 | /* initialize the WiFi driver with default configuration */ |
335 | 345 | wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); |
|
0 commit comments