UWB-Tracking
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
espnow_obj Class Reference

An Object which enables a single peer-to-peer connection. More...

#include <espnow.h>

Public Member Functions

void init (uint8_t *destination_address)
 Initialize ESP-NOW communication. More...
 
uint8_t * get_own_mac_address ()
 Get the MAC address of the local device. More...
 
int64_t generate_own_address ()
 Generate a unique ID based on the MAC address. More...
 
uint8_t * get_dst_address ()
 Get the destination MAC address. More...
 
void set_dst_address (uint8_t *destination_address)
 Set the destination MAC address. More...
 
uint8_t send_string (char *send_msg, uint8_t num_of_char)
 Send a string message over ESP-NOW. More...
 

Static Public Member Functions

static void OnDataRecv (const uint8_t *mac, const uint8_t *incomingData, int len)
 Callback function when data is received over ESP-NOW. More...
 
static void OnDataSent (const uint8_t *mac_addr, esp_now_send_status_t status)
 Callback function when data is sent over ESP-NOW. More...
 

Public Attributes

esp_now_peer_info_t peerInfo
 

Static Public Attributes

static uint8_t dst_address [6] = {0}
 Destination MAC address for ESP-NOW communication. More...
 
static char received_token [4] = {0}
 Received token data from ESP-NOW communication. More...
 
static uint8_t received = 0
 Flag indicating whether data has been received. More...
 

Detailed Description

An Object which enables a single peer-to-peer connection.

Member Function Documentation

◆ generate_own_address()

int64_t generate_own_address ( )

Generate a unique ID based on the MAC address.

Returns
The generated unique ID.

◆ get_dst_address()

uint8_t * get_dst_address ( )

Get the destination MAC address.

Returns
The destination MAC address as an array of bytes.

◆ get_own_mac_address()

uint uint8_t * get_own_mac_address ( )

Get the MAC address of the local device.

Returns
The MAC address as an array of bytes.

◆ init()

void init ( uint8_t *  destination_address)

Initialize ESP-NOW communication.

This function initializes ESP-NOW communication and registers callbacks for sending and receiving data.

Parameters
destination_addressThe MAC address of the destination device.

◆ OnDataRecv()

void OnDataRecv ( const uint8_t *  mac,
const uint8_t *  incomingData,
int  len 
)
static

Callback function when data is received over ESP-NOW.

Parameters
macThe MAC address of the sender.
incomingDataThe received data.
lenThe length of the received data.

◆ OnDataSent()

void OnDataSent ( const uint8_t *  mac_addr,
esp_now_send_status_t  status 
)
static

Callback function when data is sent over ESP-NOW.

Parameters
mac_addrThe MAC address of the recipient.
statusThe send status.

◆ send_string()

uint8_t send_string ( char *  send_msg,
uint8_t  num_of_char 
)

Send a string message over ESP-NOW.

Parameters
send_msgThe message to send.
num_of_charThe number of characters in the message.
Returns
1 if the message was sent successfully, 0 otherwise.

◆ set_dst_address()

void set_dst_address ( uint8_t *  destination_address)

Set the destination MAC address.

Parameters
destination_addressThe new destination MAC address.

Member Data Documentation

◆ dst_address

uint8_t dst_address = {0}
static

Destination MAC address for ESP-NOW communication.

◆ peerInfo

esp_now_peer_info_t peerInfo

◆ received

uint8_t received = 0
static

Flag indicating whether data has been received.

◆ received_token

char received_token = {0}
static

Received token data from ESP-NOW communication.


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