No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
audio_tools::ESPNowStream Class Reference

ESPNow as Arduino Stream. More...

#include <Communication.h>

Inheritance diagram for audio_tools::ESPNowStream:
audio_tools::AudioStreamX audio_tools::AudioStream audio_tools::Stream audio_tools::AudioBaseInfoDependent audio_tools::AudioBaseInfoSource audio_tools::Print

Public Member Functions

bool addPeer (const char *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.
int available () override
int availableForWrite () override
bool begin ()
 Initialization of ESPNow. More...
bool begin (ESPNowStreamConfig cfg)
 Initialization of ESPNow incl WIFI.
ESPNowStreamConfig defaultConfig ()
void end ()
 DeInitialization. More...
const char * macAddress ()
 Returns the mac address of the current ESP32.
size_t readBytes (uint8_t *data, size_t len) override
 Reeds the data from the peers. More...
void setReceiveCallback (esp_now_recv_cb_t cb)
void setSendCallback (esp_now_send_cb_t cb)
 Defines an alternative send callback.
size_t write (const uint8_t *data, size_t len) override
 Writes the data - sends it to all the peers. More...
- Public Member Functions inherited from audio_tools::AudioStreamX
 AudioStreamX (AudioStreamX const &)=delete
virtual int available () override
AudioStreamXoperator= (AudioStreamX const &)=delete
virtual int peek () override
virtual int read () override
virtual size_t readBytes (uint8_t *buffer, size_t length) override
virtual size_t write (const uint8_t *buffer, size_t size) override
virtual size_t write (uint8_t) override
- Public Member Functions inherited from audio_tools::AudioStream
 AudioStream (AudioStream const &)=delete
virtual AudioBaseInfo audioInfo () override
virtual int availableForWrite () override
virtual bool begin ()
virtual void end ()
virtual void flush () override
 operator bool ()
AudioStreamoperator= (AudioStream const &)=delete
virtual size_t readBytes (char *buffer, size_t length)
virtual size_t readBytes (uint8_t *buffer, size_t length) STREAM_WRITE_OVERRIDE=0
virtual void setAudioInfo (AudioBaseInfo info) override
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi) override
virtual StreamtoStreamPointer ()
virtual size_t write (const uint8_t *buffer, size_t size) override=0
- Public Member Functions inherited from audio_tools::Stream
virtual int available ()
virtual int peek ()
virtual int read ()
virtual size_t readBytes (uint8_t *buffer, size_t len)
virtual void setTimeout (size_t t)
- Public Member Functions inherited from audio_tools::Print
virtual int availableForWrite ()
virtual void flush ()
virtual int print (char c, PrintCharFmt spec)
virtual int print (const char *msg)
virtual int print (int number)
virtual int println (const char *msg="")
virtual size_t write (const char *buffer, size_t size)
virtual size_t write (const char *str)
virtual size_t write (const uint8_t *buffer, size_t size)
virtual size_t write (uint8_t ch)
- Public Member Functions inherited from audio_tools::AudioBaseInfoDependent
virtual AudioBaseInfo audioInfo ()=0
virtual void setAudioInfo (AudioBaseInfo info)=0
virtual bool validate (AudioBaseInfo &info)
virtual void setNotifyAudioChange (AudioBaseInfoDependent &bi)=0

Protected Member Functions

wifi_interface_t getInterface ()
bool isEncrypted ()
const char * mac2str (const uint8_t *array)
void resetAvailableToWrite ()
bool setup ()
void setupReceiveBuffer ()
bool str2mac (const char *mac, uint8_t *values)
- Protected Member Functions inherited from audio_tools::AudioStream
virtual int not_supported (int out)

Static Protected Member Functions

static int bufferAvailableForWrite ()
static void default_recv_cb (const uint8_t *mac_addr, const uint8_t *data, int data_len)
static void default_send_cb (const uint8_t *mac_addr, esp_now_send_status_t status)

Protected Attributes

volatile size_t available_to_write
ESPNowStreamConfig cfg
bool is_init = false
bool is_write_ok = false
BaseBuffer< uint8_t > * p_buffer = nullptr
esp_now_recv_cb_t receive = default_recv_cb
esp_now_send_cb_t send = default_send_cb
_lock_t write_lock
- Protected Attributes inherited from audio_tools::AudioStream
AudioBaseInfo info
AudioBaseInfoDependentp_notify =nullptr

Detailed Description

ESPNow as Arduino Stream.

Phil Schatzmann

Member Function Documentation

◆ available()

int audio_tools::ESPNowStream::available ( )

Reimplemented from audio_tools::AudioStreamX.

◆ availableForWrite()

int audio_tools::ESPNowStream::availableForWrite ( )

Reimplemented from audio_tools::AudioStream.

◆ begin()

bool audio_tools::ESPNowStream::begin ( )

Initialization of ESPNow.

Reimplemented from audio_tools::AudioStream.

◆ end()

void audio_tools::ESPNowStream::end ( )


Reimplemented from audio_tools::AudioStream.

◆ readBytes()

size_t audio_tools::ESPNowStream::readBytes ( uint8_t *  data,
size_t  len 

Reeds the data from the peers.

Reimplemented from audio_tools::AudioStreamX.

◆ setReceiveCallback()

void audio_tools::ESPNowStream::setReceiveCallback ( esp_now_recv_cb_t  cb)

Defines the Receive Callback - Deactivates the readBytes and available() methods!

◆ write()

size_t audio_tools::ESPNowStream::write ( const uint8_t *  data,
size_t  len 

Writes the data - sends it to all the peers.

Reimplemented from audio_tools::AudioStreamX.

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