Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Data Structures | |
struct | espNowPacket_t |
A packet received over ESP-NOW. More... | |
Macros | |
#define | ESPNOW_CHANNEL 11 |
The WiFi channel to operate on. | |
#define | WIFI_PHY WIFI_PHY_MODE_HT20 |
#define | WIFI_RATE WIFI_PHY_RATE_MCS6_SGI |
The WiFi rate to run at, MCS6 with short GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz. | |
#define | FRAMING_START_1 251 |
The first random byte used as a 'start' byte for packets transmitted over UART. | |
#define | FRAMING_START_2 63 |
The second random byte used as a 'start' byte for packets transmitted over UART. | |
#define | FRAMING_START_3 114 |
The third random byte used as a 'start' byte for packets transmitted over UART. | |
#define | ESP_NOW_SERIAL_RX_BUF_SIZE 256 |
The size of the UART receive buffer in bytes. | |
#define | ESP_NOW_SERIAL_RINGBUF_SIZE 512 |
The size of the ringbuffer used to decode packets in bytes. | |
Enumerations | |
enum | decodeState_t { EU_PARSING_FR_START_1 , EU_PARSING_FR_START_2 , EU_PARSING_FR_START_3 , EU_PARSING_MAC , EU_PARSING_LEN , EU_PARSING_PAYLOAD } |
Functions | |
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) |
esp_err_t | espNowUseWireless (void) |
void | espNowUseSerial (bool crossoverPins) |
void | checkEspNowRxQueue (void) |
void | espNowSend (const char *data, uint8_t len) |
void | deinitEspNow (void) |
struct espNowPacket_t |
#define ESPNOW_CHANNEL 11 |
The WiFi channel to operate on.
#define WIFI_PHY WIFI_PHY_MODE_HT20 |
#define WIFI_RATE WIFI_PHY_RATE_MCS6_SGI |
The WiFi rate to run at, MCS6 with short GI, 65 Mbps for 20MHz, 135 Mbps for 40MHz.
#define FRAMING_START_1 251 |
The first random byte used as a 'start' byte for packets transmitted over UART.
#define FRAMING_START_2 63 |
The second random byte used as a 'start' byte for packets transmitted over UART.
#define FRAMING_START_3 114 |
The third random byte used as a 'start' byte for packets transmitted over UART.
#define ESP_NOW_SERIAL_RX_BUF_SIZE 256 |
The size of the UART receive buffer in bytes.
#define ESP_NOW_SERIAL_RINGBUF_SIZE 512 |
The size of the ringbuffer used to decode packets in bytes.
enum decodeState_t |
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 ) |
Initialize ESP-NOW and attach callback functions. This uses wifi by default, but espNowUseSerial() may be called later to communicate over the given UART instead
recvCb | A callback to call when data is sent |
sendCb | A callback to call when data is received |
rx | The receive pin when using serial communication instead of wifi. Use GPIO_NUM_NC for no GPIO |
tx | The transmit pin when using serial communication instead of wifi. Use GPIO_NUM_NC for no GPIO |
uart | The UART to use for serial communication. Use UART_NUM_MAX for no UART |
wifiMode | The WiFi mode. If ESP_NOW_IMMEDIATE, then recvCb is called directly from the interrupt. If ESP_NOW, then recvCb is called from checkEspNowRxQueue() |
esp_err_t espNowUseWireless | ( | void | ) |
Start wifi and use it for communication
void espNowUseSerial | ( | bool | crossoverPins | ) |
Start the UART and use it for communication
crossoverPins | true to crossover the rx and tx pins, false to use them as normal. |
void checkEspNowRxQueue | ( | void | ) |
Check the ESP NOW receive queue. If there are any received packets, send them to hostEspNowRecvCb()
void espNowSend | ( | const char * | data, |
uint8_t | len ) |
This is a wrapper for esp_now_send(). It also sets the wifi power with wifi_set_user_fixed_rate()
data | The data to broadcast using ESP NOW |
len | The length of the data to broadcast |
void deinitEspNow | ( | void | ) |
This function is called to de-initialize ESP-NOW