Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-esp-now.h
Go to the documentation of this file.
1
76#ifndef USER_ESP_NOW_UTILS_H_
77#define USER_ESP_NOW_UTILS_H_
78
79//==============================================================================
80// Includes
81//==============================================================================
82
83#include <stdint.h>
84#include <stdbool.h>
85
86#include <esp_now.h>
87#include <esp_err.h>
88#include <soc/gpio_num.h>
89#include <driver/uart.h>
90
91//==============================================================================
92// Types
93//==============================================================================
94
98typedef enum __attribute__((packed))
99{
103} wifiMode_t;
104
105//==============================================================================
106// Prototypes
107//==============================================================================
108
116typedef void (*hostEspNowRecvCb_t)(const esp_now_recv_info_t* esp_now_info, const uint8_t* data, uint8_t len,
117 int8_t rssi);
123typedef void (*hostEspNowSendCb_t)(const uint8_t* mac_addr, esp_now_send_status_t status);
124
125esp_err_t initEspNow(hostEspNowRecvCb_t recvCb, hostEspNowSendCb_t sendCb, gpio_num_t rx, gpio_num_t tx,
126 uart_port_t uart, wifiMode_t wifiMode);
127void deinitEspNow(void);
128
129esp_err_t espNowUseWireless(void);
130void espNowUseSerial(bool crossoverPins);
131
132void espNowSend(const char* data, uint8_t len);
133void checkEspNowRxQueue(void);
134
135#endif /* USER_ESP_NOW_UTILS_H_ */
void deinitEspNow(void)
Definition hdw-esp-now.c:633
void(* hostEspNowRecvCb_t)(const esp_now_recv_info_t *esp_now_info, const uint8_t *data, uint8_t len, int8_t rssi)
A function typedef for a callback called when an ESP-NOW packet is received.
Definition hdw-esp-now.h:116
void(* hostEspNowSendCb_t)(const uint8_t *mac_addr, esp_now_send_status_t status)
A function typedef for a callback called when an ESP-NOW packet transmission finishes.
Definition hdw-esp-now.h:123
void checkEspNowRxQueue(void)
Definition hdw-esp-now.c:417
wifiMode_t
The different WiFi modes.
Definition hdw-esp-now.h:99
@ ESP_NOW_IMMEDIATE
ESP-NOW packets are delivered to Swadge modes from the interrupt.
Definition hdw-esp-now.h:102
@ ESP_NOW
ESP-NOW packets are delivered to Swadge modes from the main loop.
Definition hdw-esp-now.h:101
@ NO_WIFI
WiFi is not used at all. This saves power.
Definition hdw-esp-now.h:100
void espNowUseSerial(bool crossoverPins)
Definition hdw-esp-now.c:339
esp_err_t espNowUseWireless(void)
Definition hdw-esp-now.c:258
esp_err_t initEspNow(hostEspNowRecvCb_t recvCb, hostEspNowSendCb_t sendCb, gpio_num_t rx, gpio_num_t tx, uart_port_t uart, wifiMode_t wifiMode)
Definition hdw-esp-now.c:119
void espNowSend(const char *data, uint8_t len)
Definition hdw-esp-now.c:559