EnigmaIOT  0.9.3
Secure sensor and gateway platform based on ESP8266 and ESP32
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Espnow_halClass Class Reference

Definition for ESP-NOW hardware abstraction layer. More...

#include <espnow_hal.h>

Inheritance diagram for Espnow_halClass:
Comms_halClass

Public Member Functions

void begin (uint8_t *gateway, uint8_t channel=0, peerType_t peerType=COMM_NODE)
 Setup communication environment and establish the connection from node to gateway. More...
 
void stop ()
 Terminates communication and closes all connectrions. More...
 
int32_t send (uint8_t *da, uint8_t *data, int len)
 Sends data to the other peer. More...
 
void onDataRcvd (comms_hal_rcvd_data dataRcvd)
 Attach a callback function to be run on every received message. More...
 
void onDataSent (comms_hal_sent_data dataRcvd)
 Attach a callback function to be run after sending a message to receive its status. More...
 
uint8_t getAddressLength ()
 Get address length used on ESP-NOW subsystem. More...
 
size_t getMaxMessageLength ()
 Get maximum message length on ESP-NOW subsystem. More...
 

Static Public Attributes

static const size_t COMMS_HAL_MAX_MESSAGE_LENGTH = 250
 Maximum message length for ESP-NOW. More...
 
static const uint8_t COMMS_HAL_ADDR_LEN = 6
 Address length for ESP-NOW. Correspond to mac address. More...
 
- Static Public Attributes inherited from Comms_halClass
static const size_t COMMS_HAL_MAX_MESSAGE_LENGTH = 0
 Maximum message length. More...
 
static const uint8_t COMMS_HAL_ADDR_LEN = 1
 Address length. More...
 

Protected Member Functions

void initComms (peerType_t peerType)
 Communication subsistem initialization. More...
 

Static Protected Member Functions

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...
 

Protected Attributes

uint8_t gateway [COMMS_HAL_ADDR_LEN]
 Gateway address. More...
 
uint8_t channel
 WiFi channel to be used. More...
 
comms_hal_rcvd_data dataRcvd
 Pointer to a function to be called on every received message. More...
 
comms_hal_sent_data sentResult
 Pointer to a function to be called to notify last sending status. More...
 
- Protected Attributes inherited from Comms_halClass
uint8_t gateway [COMMS_HAL_ADDR_LEN]
 Gateway address. More...
 
uint8_t channel
 WiFi channel to be used. More...
 
comms_hal_rcvd_data dataRcvd = 0
 Pointer to a function to be called on every received message. More...
 
comms_hal_sent_data sentResult = 0
 Pointer to a function to be called to notify last sending status. More...
 
peerType_t _ownPeerType
 Stores peer type, node or gateway. More...
 

Detailed Description

Definition for ESP-NOW hardware abstraction layer.

Definition at line 31 of file espnow_hal.h.

Member Function Documentation

◆ begin()

void Espnow_halClass::begin ( uint8_t *  gateway,
uint8_t  channel = 0,
peerType_t  peerType = COMM_NODE 
)
virtual

Setup communication environment and establish the connection from node to gateway.

Parameters
gatewayAddress of gateway. It may be NULL in case this is used in the own gateway
channelEstablishes a channel for the communication. Its use depends on actual communications subsystem
peerTypeRole that peer plays into the system, sensor node or gateway.

Implements Comms_halClass.

Definition at line 67 of file espnow_hal.cpp.

◆ getAddressLength()

uint8_t Espnow_halClass::getAddressLength ( )
inlinevirtual

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 103 of file espnow_hal.h.

◆ 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 111 of file espnow_hal.h.

◆ initComms()

void Espnow_halClass::initComms ( peerType_t  peerType)
protectedvirtual

Communication subsistem initialization.

Parameters
peerTypeRole that peer plays into the system, sensor node or gateway.

Implements Comms_halClass.

Definition at line 24 of file espnow_hal.cpp.

◆ onDataRcvd()

void Espnow_halClass::onDataRcvd ( comms_hal_rcvd_data  dataRcvd)
virtual

Attach a callback function to be run on every received message.

Parameters
dataRcvdPointer to the callback function

Implements Comms_halClass.

Definition at line 122 of file espnow_hal.cpp.

◆ onDataSent()

void Espnow_halClass::onDataSent ( comms_hal_sent_data  dataRcvd)
virtual

Attach a callback function to be run after sending a message to receive its status.

Parameters
dataRcvdPointer to the callback function

Implements Comms_halClass.

Definition at line 126 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_addrDestination address to send the message to
dataData buffer that contain the message to be sent
lenData length in number of bytes

Definition at line 55 of file espnow_hal.cpp.

◆ send()

int32_t Espnow_halClass::send ( uint8_t *  da,
uint8_t *  data,
int  len 
)
virtual

Sends data to the other peer.

Parameters
daDestination address to send the message to
dataData buffer that contain the message to be sent
lenData length in number of bytes
Returns
Returns sending status. 0 for success, 1 to indicate an error.

Implements Comms_halClass.

Definition at line 86 of file espnow_hal.cpp.

◆ stop()

void Espnow_halClass::stop ( )
virtual

Terminates communication and closes all connectrions.

Implements Comms_halClass.

Definition at line 79 of file espnow_hal.cpp.

◆ 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_addrDestination address to send the message to
statusSending status

Definition at line 61 of file espnow_hal.cpp.

Member Data Documentation

◆ channel

uint8_t Espnow_halClass::channel
protected

WiFi channel to be used.

Definition at line 39 of file espnow_hal.h.

◆ 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.

◆ dataRcvd

comms_hal_rcvd_data Espnow_halClass::dataRcvd
protected

Pointer to a function to be called on every received message.

Definition at line 41 of file espnow_hal.h.

◆ gateway

uint8_t Espnow_halClass::gateway[COMMS_HAL_ADDR_LEN]
protected

Gateway address.

Definition at line 38 of file espnow_hal.h.

◆ sentResult

comms_hal_sent_data Espnow_halClass::sentResult
protected

Pointer to a function to be called to notify last sending status.

Definition at line 42 of file espnow_hal.h.


The documentation for this class was generated from the following files: