ESP-IDF Robot ESP NOW

This commit is contained in:
2024-12-24 11:15:55 -05:00
parent efdea51dac
commit f225d05d1b
3 changed files with 51 additions and 1 deletions

View File

View File

@@ -1 +1 @@
8806219c7d8c73b0532c7afd27e9c0bd1efb9047
efdea51dac034fe75f225e806685983fe9b61160

View File

@@ -1,4 +1,54 @@
#ifndef ESPNOW_CONFIG_H
#define ESPNOW_CONFIG_H
/* ESPNOW can work in both station and softap mode. It is configured in menuconfig. */
#if CONFIG_ESPNOW_WIFI_MODE_STATION
#define ESPNOW_WIFI_MODE WIFI_MODE_STA
#define ESPNOW_WIFI_IF ESP_IF_WIFI_STA
#else
#define ESPNOW_WIFI_MODE WIFI_MODE_AP
#define ESPNOW_WIFI_IF ESP_IF_WIFI_AP
#endif
#define ESPNOW_QUEUE_SIZE 6
#define IS_BROADCAST_ADDR(addr) (memcmp(addr, s_example_broadcast_mac, ESP_NOW_ETH_ALEN) == 0)
typedef enum {
EXAMPLE_ESPNOW_SEND_CB,
EXAMPLE_ESPNOW_RECV_CB,
} espnow_event_id_t;
typedef struct {
uint8_t mac_addr[ESP_NOW_ETH_ALEN];
esp_now_send_status_t status;
} espnow_event_send_cb_t;
typedef struct {
uint8_t mac_addr[ESP_NOW_ETH_ALEN];
uint8_t *data;
int data_len;
} espnow_event_recv_cb_t;
typedef union {
espnow_event_send_cb_t send_cb;
espnow_event_recv_cb_t recv_cb;
} espnow_event_info_t;
typedef union {
espnow_event_send_cb_t send_cb;
espnow_event_recv_cb_t recv_cb;
} espnow_event_info_t;
/* When ESPNOW sending or receiving callback function is called, post event to ESPNOW task. */
typedef struct {
espnow_event_id_t id;
espnow_event_info_t info;
} espnow_event_t;
enum {
EXAMPLE_ESPNOW_DATA_BROADCAST,
EXAMPLE_ESPNOW_DATA_UNICAST,
EXAMPLE_ESPNOW_DATA_MAX,
};
#endif