ESPNow as Arduino Stream. When use_send_ack is true we prevent any buffer overflows by blocking writes until the previous packet has been confirmed. When no acknowledgments are used, you might need to throttle the send speed to prevent any buffer overflow on the receiver side.
More...
#include <ESPNowStream.h>
|
| | ESPNowStream () |
| |
| | ~ESPNowStream () |
| |
| bool | addBroadcastPeer () |
| |
| bool | addPeer (const char *address) |
| | Adds a peer to which we can send info or from which we can receive info.
|
| |
| bool | addPeer (const uint8_t *address) |
| | Adds a peer to which we can send info or from which we can receive info.
|
| |
| bool | addPeer (esp_now_peer_info_t &peer) |
| | Adds a peer to which we can send info or from which we can receive info.
|
| |
| template<size_t size> |
| bool | addPeers (const char *(&array)[size]) |
| | Adds an array of peers.
|
| |
| template<size_t N> |
| bool | addPeers (const uint8_t(&array)[N][6]) |
| | Adds an array of peers.
|
| |
| int | available () override |
| |
| int | availableForWrite () override |
| |
| bool | begin () |
| | Initialization of ESPNow.
|
| |
| virtual bool | begin (ESPNowStreamConfig cfg) |
| | Initialization of ESPNow incl WIFI.
|
| |
| bool | clearPeers () |
| | Deletes all registered peers.
|
| |
| ESPNowStreamConfig | defaultConfig () |
| |
| virtual void | end () |
| | DeInitialization.
|
| |
| virtual void | flush () override |
| |
| BufferRTOS< uint8_t > & | getBuffer () |
| | provides access to the receive buffer
|
| |
| float | getBufferPercent () |
| | provides how much the receive buffer is filled (in percent)
|
| |
| uint8_t | getChannel () |
| | Provides the WiFi Channel.
|
| |
| uint32_t | getLastIoSuccessTime () const |
| | time when we were able to send or receive the last packet successfully
|
| |
| const char * | macAddress () |
| | Returns the mac address of the current ESP32.
|
| |
| | operator bool () |
| |
| size_t | readBytes (uint8_t *data, size_t len) override |
| | Reeds the data from the peers.
|
| |
| void | setChannel (uint8_t ch) |
| | Defines the WiFi Channel.
|
| |
| void | setReceiveCallback (esp_now_recv_cb_t cb) |
| |
| void | setSendCallback (esp_now_send_cb_t cb) |
| | Defines an alternative send callback.
|
| |
| void | setWriteBufferSize (int size) |
| |
| size_t | write (const char *peer, const uint8_t *data, size_t len) |
| | Writes the data - sends it to all the indicated peer mac address string.
|
| |
| size_t | write (const uint8_t *data, size_t len) override |
| | Writes the data - sends it to all registered peers.
|
| |
| size_t | write (const uint8_t *peer, const uint8_t *data, size_t len) |
| | Writes the data - sends it to all the peers.
|
| |
| virtual size_t | write (uint8_t ch) override |
| |
|
| wifi_interface_t | getInterface () |
| |
| virtual void | handle_recv_cb (const uint8_t *mac_addr, const uint8_t *data, int data_len, bool broadcast, uint8_t rssi) |
| |
| virtual void | handle_send_cb (const uint8_t *mac_addr, esp_now_send_status_t status) |
| |
| bool | handleQueueError (esp_err_t rc, int &retry_count) |
| | Handles errors when queuing packets.
|
| |
| bool | handleTransmissionResult (int &retry_count) |
| | Handles the result of packet transmission (after queuing)
|
| |
| bool | initWiFi (wifi_mode_t mode) |
| |
| bool | isEncrypted () |
| |
| const char * | mac2str (const uint8_t *array) |
| |
| void | refillReadBuffer () |
| | Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
|
| |
| void | resetAvailableToWrite () |
| |
| virtual bool | sendPacket (const uint8_t *data, size_t len, int &retry_count, const uint8_t *destination=nullptr) |
| | Sends a single packet with retry logic.
|
| |
| bool | setup () |
| | Initialization.
|
| |
| bool | setupMAC () |
| |
| void | setupReceiveBuffer () |
| |
| void | setupSemaphore () |
| |
| bool | setupWiFi () |
| |
| bool | str2mac (const char *mac, uint8_t *values) |
| |
ESPNow as Arduino Stream. When use_send_ack is true we prevent any buffer overflows by blocking writes until the previous packet has been confirmed. When no acknowledgments are used, you might need to throttle the send speed to prevent any buffer overflow on the receiver side.
- Note
- If multiple receivers are in range, only the first one which sends an acknowledgment will be used as coordinator.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ ESPNowStream()
◆ ~ESPNowStream()
◆ addBroadcastPeer()
| bool addBroadcastPeer |
( |
| ) |
|
|
inline |
Adds the broadcast peer (FF:FF:FF:FF:FF:FF) to send to all devices in range. Note: Broadcast does not support acknowledgments
◆ addPeer() [1/3]
| bool addPeer |
( |
const char * |
address | ) |
|
|
inline |
Adds a peer to which we can send info or from which we can receive info.
◆ addPeer() [2/3]
| bool addPeer |
( |
const uint8_t * |
address | ) |
|
|
inline |
Adds a peer to which we can send info or from which we can receive info.
◆ addPeer() [3/3]
| bool addPeer |
( |
esp_now_peer_info_t & |
peer | ) |
|
|
inline |
Adds a peer to which we can send info or from which we can receive info.
◆ addPeers() [1/2]
template<size_t size>
| bool addPeers |
( |
const char *(&) |
array[size] | ) |
|
|
inline |
◆ addPeers() [2/2]
template<size_t N>
| bool addPeers |
( |
const uint8_t(&) |
array[N][6] | ) |
|
|
inline |
◆ available()
◆ availableForWrite()
| int availableForWrite |
( |
| ) |
|
|
inlineoverridevirtual |
◆ begin() [1/2]
Initialization of ESPNow.
Reimplemented from BaseStream.
◆ begin() [2/2]
Initialization of ESPNow incl WIFI.
◆ bufferAvailableForWrite()
| static int bufferAvailableForWrite |
( |
| ) |
|
|
inlinestaticprotected |
◆ clearPeers()
Deletes all registered peers.
◆ default_recv_cb()
| static void default_recv_cb |
( |
const esp_now_recv_info * |
info, |
|
|
const uint8_t * |
data, |
|
|
int |
data_len |
|
) |
| |
|
inlinestaticprotected |
◆ default_send_cb()
| static void default_send_cb |
( |
const wifi_tx_info_t * |
tx_info, |
|
|
esp_now_send_status_t |
status |
|
) |
| |
|
inlinestaticprotected |
◆ defaultConfig()
◆ end()
◆ flush()
|
|
inlineoverridevirtualinherited |
Reimplemented from Print.
Reimplemented in PureDataStream, URLStreamBufferedT< T >, URLStreamBufferedT< ICYStream >, ReformatBaseStream, AudioStreamWrapper, ResampleStream, EncodedAudioStream, URLStream, BufferedTaskStream, I2SStream, MemoryStream, RingBufferStream, GeneratedSoundStream< T >, GeneratedSoundStream< int16_t >, and BufferedStream.
◆ getBuffer()
provides access to the receive buffer
◆ getBufferPercent()
| float getBufferPercent |
( |
| ) |
|
|
inline |
provides how much the receive buffer is filled (in percent)
◆ getChannel()
Provides the WiFi Channel.
◆ getInterface()
| wifi_interface_t getInterface |
( |
| ) |
|
|
inlineprotected |
◆ getLastIoSuccessTime()
| uint32_t getLastIoSuccessTime |
( |
| ) |
const |
|
inline |
time when we were able to send or receive the last packet successfully
◆ handle_recv_cb()
| virtual void handle_recv_cb |
( |
const uint8_t * |
mac_addr, |
|
|
const uint8_t * |
data, |
|
|
int |
data_len, |
|
|
bool |
broadcast, |
|
|
uint8_t |
rssi |
|
) |
| |
|
inlineprotectedvirtual |
◆ handle_send_cb()
| virtual void handle_send_cb |
( |
const uint8_t * |
mac_addr, |
|
|
esp_now_send_status_t |
status |
|
) |
| |
|
inlineprotectedvirtual |
◆ handleQueueError()
| bool handleQueueError |
( |
esp_err_t |
rc, |
|
|
int & |
retry_count |
|
) |
| |
|
inlineprotected |
Handles errors when queuing packets.
◆ handleTransmissionResult()
| bool handleTransmissionResult |
( |
int & |
retry_count | ) |
|
|
inlineprotected |
Handles the result of packet transmission (after queuing)
◆ initWiFi()
| bool initWiFi |
( |
wifi_mode_t |
mode | ) |
|
|
inlineprotected |
◆ isEncrypted()
◆ mac2str()
| const char * mac2str |
( |
const uint8_t * |
array | ) |
|
|
inlineprotected |
◆ macAddress()
| const char * macAddress |
( |
| ) |
|
|
inline |
Returns the mac address of the current ESP32.
◆ operator bool()
◆ readBytes()
| size_t readBytes |
( |
uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineoverridevirtual |
Reeds the data from the peers.
Implements BaseStream.
◆ refillReadBuffer()
| void refillReadBuffer |
( |
| ) |
|
|
inlineprotectedinherited |
Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
◆ resetAvailableToWrite()
| void resetAvailableToWrite |
( |
| ) |
|
|
inlineprotected |
◆ sendPacket()
| virtual bool sendPacket |
( |
const uint8_t * |
data, |
|
|
size_t |
len, |
|
|
int & |
retry_count, |
|
|
const uint8_t * |
destination = nullptr |
|
) |
| |
|
inlineprotectedvirtual |
Sends a single packet with retry logic.
◆ setChannel()
| void setChannel |
( |
uint8_t |
ch | ) |
|
|
inline |
Defines the WiFi Channel.
◆ setReceiveCallback()
| void setReceiveCallback |
( |
esp_now_recv_cb_t |
cb | ) |
|
|
inline |
Defines the Receive Callback - Deactivates the readBytes and available() methods!
◆ setSendCallback()
| void setSendCallback |
( |
esp_now_send_cb_t |
cb | ) |
|
|
inline |
Defines an alternative send callback.
◆ setup()
◆ setupMAC()
◆ setupReceiveBuffer()
| void setupReceiveBuffer |
( |
| ) |
|
|
inlineprotected |
◆ setupSemaphore()
◆ setupWiFi()
◆ setWriteBufferSize()
| void setWriteBufferSize |
( |
int |
size | ) |
|
|
inlineinherited |
◆ str2mac()
| bool str2mac |
( |
const char * |
mac, |
|
|
uint8_t * |
values |
|
) |
| |
|
inlineprotected |
◆ write() [1/4]
| size_t write |
( |
const char * |
peer, |
|
|
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inline |
Writes the data - sends it to all the indicated peer mac address string.
◆ write() [2/4]
| size_t write |
( |
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineoverridevirtual |
Writes the data - sends it to all registered peers.
Implements BaseStream.
◆ write() [3/4]
| size_t write |
( |
const uint8_t * |
peer, |
|
|
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inline |
Writes the data - sends it to all the peers.
◆ write() [4/4]
| virtual size_t write |
( |
uint8_t |
ch | ) |
|
|
inlineoverridevirtualinherited |
◆ _timeout
◆ available_to_write
| volatile size_t available_to_write = 0 |
|
protected |
◆ buffer
◆ cfg
◆ has_peers
◆ is_broadcast
| bool is_broadcast = false |
|
protected |
◆ is_init
◆ last_io_success_time
| uint32_t last_io_success_time = 0 |
|
protected |
◆ last_send_success
| volatile bool last_send_success = true |
|
protected |
◆ read_ready
◆ receive
◆ send
◆ tmp_in
◆ tmp_out
◆ write_buffer_size
◆ xSemaphore
| SemaphoreHandle_t xSemaphore = nullptr |
|
protected |
The documentation for this class was generated from the following file: