Definition for ESP-NOW hardware abstraction layer.
More...
#include <espnow_hal.h>
|
static void | runHandle (void *param) |
| Static function that calls handle inside task. More...
|
|
|
static void ICACHE_FLASH_ATTR | rx_cb (uint8_t *mac_addr, uint8_t *data, uint8_t len) |
| Function that processes incoming messages and passes them to upper layer. More...
|
|
static void ICACHE_FLASH_ATTR | tx_cb (uint8_t *mac_addr, uint8_t status) |
| Function that gets sending status. More...
|
|
Definition for ESP-NOW hardware abstraction layer.
Definition at line 31 of file espnow_hal.h.
◆ Espnow_halClass()
Espnow_halClass::Espnow_halClass |
( |
| ) |
|
|
inline |
◆ addPeer()
bool Espnow_halClass::addPeer |
( |
const uint8_t * |
da | ) |
|
|
protected |
Adds a peer to esp-now peer list.
- Parameters
-
da | Peer address to be added to peer list |
Definition at line 93 of file espnow_hal.cpp.
◆ begin()
void Espnow_halClass::begin |
( |
uint8_t * |
gateway, |
|
|
uint8_t |
channel = 0 , |
|
|
peerType_t |
peerType = COMM_NODE |
|
) |
| |
|
overridevirtual |
Setup communication environment and establish the connection from node to gateway.
- Parameters
-
gateway | Address of gateway. It may be NULL in case this is used in the own gateway |
channel | Establishes a channel for the communication. Its use depends on actual communications subsystem |
peerType | Role that peer plays into the system, sensor node or gateway. |
Implements Comms_halClass.
Definition at line 78 of file espnow_hal.cpp.
◆ enableTransmit()
void Espnow_halClass::enableTransmit |
( |
bool |
enable | ) |
|
|
inlineoverridevirtual |
Enables or disables transmission of queued messages. Used to disable communication during wifi scan.
- Parameters
-
enable | true to enable transmission, false to disable it |
Implements Comms_halClass.
Definition at line 139 of file espnow_hal.h.
◆ getAddressLength()
uint8_t Espnow_halClass::getAddressLength |
( |
| ) |
|
|
inlineoverridevirtual |
Get address length used on ESP-NOW subsystem.
- Returns
- Always returns the sice of 802.11 MAC address, equals to 6
Implements Comms_halClass.
Definition at line 123 of file espnow_hal.h.
◆ getCommsQueue()
◆ getMaxMessageLength()
size_t Espnow_halClass::getMaxMessageLength |
( |
| ) |
|
|
inline |
Get maximum message length on ESP-NOW subsystem.
- Returns
- Always returns a value equal to 250
Definition at line 131 of file espnow_hal.h.
◆ handle()
void Espnow_halClass::handle |
( |
| ) |
|
|
overridevirtual |
◆ initComms()
void Espnow_halClass::initComms |
( |
peerType_t |
peerType | ) |
|
|
overrideprotectedvirtual |
Communication subsistem initialization.
- Parameters
-
peerType | Role that peer plays into the system, sensor node or gateway. |
Implements Comms_halClass.
Definition at line 24 of file espnow_hal.cpp.
◆ onDataRcvd()
Attach a callback function to be run on every received message.
- Parameters
-
dataRcvd | Pointer to the callback function |
Implements Comms_halClass.
Definition at line 204 of file espnow_hal.cpp.
◆ onDataSent()
Attach a callback function to be run after sending a message to receive its status.
- Parameters
-
dataRcvd | Pointer to the callback function |
Implements Comms_halClass.
Definition at line 208 of file espnow_hal.cpp.
◆ popCommsQueue()
void Espnow_halClass::popCommsQueue |
( |
| ) |
|
|
protected |
◆ runHandle()
void Espnow_halClass::runHandle |
( |
void * |
param | ) |
|
|
static |
Static function that calls handle inside task.
Definition at line 230 of file espnow_hal.cpp.
◆ rx_cb()
void ICACHE_FLASH_ATTR Espnow_halClass::rx_cb |
( |
uint8_t * |
mac_addr, |
|
|
uint8_t * |
data, |
|
|
uint8_t |
len |
|
) |
| |
|
staticprotected |
Function that processes incoming messages and passes them to upper layer.
- Parameters
-
mac_addr | Destination address to send the message to |
data | Data buffer that contain the message to be sent |
len | Data length in number of bytes |
Definition at line 64 of file espnow_hal.cpp.
◆ send()
int32_t Espnow_halClass::send |
( |
uint8_t * |
da, |
|
|
uint8_t * |
data, |
|
|
int |
len |
|
) |
| |
|
overridevirtual |
Sends data to the other peer.
- Parameters
-
da | Destination address to send the message to |
data | Data buffer that contain the message to be sent |
len | Data length in number of bytes |
- Returns
- Returns sending status. 0 for success, 1 to indicate an error.
Implements Comms_halClass.
Definition at line 122 of file espnow_hal.cpp.
◆ sendEspNowMessage()
◆ stop()
void Espnow_halClass::stop |
( |
| ) |
|
|
overridevirtual |
◆ tx_cb()
void ICACHE_FLASH_ATTR Espnow_halClass::tx_cb |
( |
uint8_t * |
mac_addr, |
|
|
uint8_t |
status |
|
) |
| |
|
staticprotected |
Function that gets sending status.
- Parameters
-
mac_addr | Destination address to send the message to |
status | Sending status |
Definition at line 70 of file espnow_hal.cpp.
◆ COMMS_HAL_ADDR_LEN
const uint8_t Espnow_halClass::COMMS_HAL_ADDR_LEN = 6 |
|
static |
Address length for ESP-NOW. Correspond to mac address.
Definition at line 34 of file espnow_hal.h.
◆ COMMS_HAL_MAX_MESSAGE_LENGTH
const size_t Espnow_halClass::COMMS_HAL_MAX_MESSAGE_LENGTH = 250 |
|
static |
Maximum message length for ESP-NOW.
Definition at line 33 of file espnow_hal.h.
◆ espnowLoopTask
ETSTimer Espnow_halClass::espnowLoopTask |
|
protected |
◆ out_queue
◆ readyToSend
bool Espnow_halClass::readyToSend = true |
|
protected |
The documentation for this class was generated from the following files: