espnowSimple 1
Loading...
Searching...
No Matches
espnowsimple.cpp File Reference
#include <espnowsimple.h>
Include dependency graph for espnowsimple.cpp:

Go to the source code of this file.

Functions

void espSimpleNowCallbackBinRcvd (const uint8_t *data, int len)
void espSimpleNowCallbackDataSent (const bool success)
void internalDataSentCallback (const uint8_t *mac_addr, esp_now_send_status_t status)
void internalDataReceivedCallback (const unsigned char *mac, const unsigned char *incomingData, int len)
void setMacAddr (uint8_t lastByte, uint8_t mac[6])
uint8_t initESPNowMac (uint8_t *mac)
uint8_t espSimpleNowInit (uint8_t macAddrLastByte)
uint8_t espSimpleNowBroadcastData (char *data, uint16_t len)
void espSimpleNowSetMacAddr (uint8_t mac[6])
void espSimpleNowGetMacAddr (uint8_t mac[6])

Variables

uint8_t broadcastMAC [6] = { 0x02, 0x2a, 0x56, 0x72, 0x2b, 0x00 }
esp_now_peer_info_t peerInfo
esp_err_t espNowSimpleErr
uint8_t espSimpleNowRunning = false

Function Documentation

◆ espSimpleNowBroadcastData()

uint8_t espSimpleNowBroadcastData ( char * data,
uint16_t len )

Simple binary data tx NB max size 250Byte pls use max 249 just to be sure

Returns
1: well.

Definition at line 130 of file espnowsimple.cpp.

References broadcastMAC, and espSimpleNowRunning.

Referenced by txTest().

Here is the caller graph for this function:

◆ espSimpleNowCallbackBinRcvd()

void espSimpleNowCallbackBinRcvd ( const uint8_t * data,
int len )

The callback you shall implement as to get data

void espSimpleNowCallbackBinRcvd(const uint8_t *data, int len) { your code }

Definition at line 33 of file espnowsimple.cpp.

Referenced by internalDataReceivedCallback().

Here is the caller graph for this function:

◆ espSimpleNowCallbackDataSent()

void espSimpleNowCallbackDataSent ( const bool success)

The callback you shall implement as to check if data has been send NB esp now do not guarantee if data is received in same order as you did tx - ifff you are heavily loading the system

void espSimpleNowCallbackDataSent(const bool success) { }

to check if data has been send to get data

Definition at line 34 of file espnowsimple.cpp.

Referenced by internalDataSentCallback().

Here is the caller graph for this function:

◆ espSimpleNowGetMacAddr()

void espSimpleNowGetMacAddr ( uint8_t mac[6])

you can get current mac addr

Returns
1: hej

Definition at line 148 of file espnowsimple.cpp.

References broadcastMAC.

Referenced by testMacAddr().

Here is the caller graph for this function:

◆ espSimpleNowInit()

uint8_t espSimpleNowInit ( uint8_t macAddrLastByte)

change last byte in MAC to To used for broadcast See esp now library NB parm must not n“edn on 1,3,5,7 (decimal) or just lsb bit must not be 1 return: -1 if macaddressbyte i odd - must be even (lsb bit0 ==0) rest of err codes comes from call to initESPNowMac 1: esp_wifi_sec_mac failed 2: esp_now_init failed 3: esp_wifi_set_protocol failed 4: esp_now_register_send_cb failed 5: esp_now_register_recv_cb failed 6: esp_now_add_peer failed

espNowSimpleErr (of type esp_err_t) holds the actual errorcode

Definition at line 114 of file espnowsimple.cpp.

References broadcastMAC, initESPNowMac(), and setMacAddr().

Referenced by setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ espSimpleNowSetMacAddr()

void espSimpleNowSetMacAddr ( uint8_t mac[6])

You can change broadcast mac address

Set new

Definition at line 142 of file espnowsimple.cpp.

References broadcastMAC.

Referenced by testMacAddr().

Here is the caller graph for this function:

◆ initESPNowMac()

uint8_t initESPNowMac ( uint8_t * mac)

Definition at line 66 of file espnowsimple.cpp.

References broadcastMAC, espNowSimpleErr, espSimpleNowRunning, internalDataReceivedCallback(), internalDataSentCallback(), and peerInfo.

Referenced by espSimpleNowInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internalDataReceivedCallback()

void internalDataReceivedCallback ( const unsigned char * mac,
const unsigned char * incomingData,
int len )

Definition at line 44 of file espnowsimple.cpp.

References espSimpleNowCallbackBinRcvd().

Referenced by initESPNowMac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ internalDataSentCallback()

void internalDataSentCallback ( const uint8_t * mac_addr,
esp_now_send_status_t status )

Definition at line 38 of file espnowsimple.cpp.

References espSimpleNowCallbackDataSent().

Referenced by initESPNowMac().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMacAddr()

void setMacAddr ( uint8_t lastByte,
uint8_t mac[6] )

Definition at line 57 of file espnowsimple.cpp.

Referenced by espSimpleNowInit().

Here is the caller graph for this function:

Variable Documentation

◆ broadcastMAC

uint8_t broadcastMAC[6] = { 0x02, 0x2a, 0x56, 0x72, 0x2b, 0x00 }

◆ espNowSimpleErr

esp_err_t espNowSimpleErr

Definition at line 19 of file espnowsimple.cpp.

Referenced by initESPNowMac().

◆ espSimpleNowRunning

uint8_t espSimpleNowRunning = false

Definition at line 23 of file espnowsimple.cpp.

Referenced by espSimpleNowBroadcastData(), and initESPNowMac().

◆ peerInfo

esp_now_peer_info_t peerInfo

Definition at line 18 of file espnowsimple.cpp.

Referenced by initESPNowMac().