1234567891011121314151617181920212223242526272829303132333435 |
- #ifndef CRV2_ESP_NOW_H
- #define CRV2_ESP_NOW_H
- /* Protocol version will maybe help us in the future if we decide to redo the protocol
- * in a major way.
- */
- #define PROTOCOL_VERSION 1
- #include "configuration.h"
- typedef struct {
- int data_len;
- uint8_t mac_addr[19];
- uint8_t data[ESP_NOW_MAX_DATA_LEN+1];
- } receive_buffer_t;
- /* Send a message in an MBOX header */
- bool send_encapsulated(const uint8_t type, const uint8_t *data, const size_t len);
- /* Decapsulate a message and route it appropriately */
- void process_message(receive_buffer_t& incoming);
- /* Send raw data */
- bool send_broadcast(const uint8_t *data, const size_t len);
- receive_buffer_t *get_message();
- bool manageSlave();
- void initBroadcast();
- bool manageBroadcast();
- // callback when data is received
- void OnDataRecv(const uint8_t *mac_addr, const uint8_t *data, int data_len);
- // callback when data is sent
- void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status);
- #endif
|