arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
UDPStream Class Reference

A UDP class which makes sure that we can use UDP as AudioSource and AudioSink. By default the WiFiUDP object is used and we login to wifi if the ssid and password is provided and we are not already connected. More...

#include <UDPStream.h>

Inheritance diagram for UDPStream:
BaseStream Stream Print

Public Member Functions

 UDPStream ()=default
 Default Constructor.
 
 UDPStream (const char *ssid, const char *password)
 Convinience constructor which defines the optional ssid and password.
 
 UDPStream (UDP &udp)
 Constructor which defines an alternative UDP object. By default we use WiFiUDP.
 
int available () override
 
int availableForWrite ()
 
virtual bool begin ()
 
bool begin (IPAddress a, uint16_t port)
 Starts to send data to the indicated address / port.
 
bool begin (uint16_t port, uint16_t port_ext=0)
 Starts to receive data from/with the indicated port.
 
bool beginMulticast (IPAddress address, uint16_t port)
 Starts to receive data in multicast from/with the indicated address / port.
 
virtual void end ()
 
virtual void flush () override
 
 operator bool ()
 
size_t readBytes (uint8_t *data, size_t len) override
 Reads bytes using WiFi::readBytes.
 
IPAddress remoteIP ()
 We use the same remote ip as defined in begin for write.
 
uint16_t remotePort ()
 We use the same remote port as defined in begin for write.
 
void setPassword (const char *pwd)
 
void setSSID (const char *ssid)
 
void setUDP (UDP &udp)
 Defines an alternative UDP object. By default we use WiFiUDP.
 
void setWriteBufferSize (int size)
 
size_t write (const uint8_t *data, size_t len) override
 Replys will be sent to the initial remote caller.
 
virtual size_t write (uint8_t ch) override
 

Protected Member Functions

void connect ()
 connect to WIFI if necessary
 
void printIP ()
 
void refillReadBuffer ()
 Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()
 

Protected Attributes

int _timeout = 10
 
WiFiUDP default_udp
 
UDPp_udp = &default_udp
 
const charpassword = nullptr
 
IPAddress remote_address_ext
 
uint16_t remote_port_ext = 0
 
const charssid = nullptr
 
RingBuffer< uint8_ttmp_in {0}
 
RingBuffer< uint8_ttmp_out {0}
 
int write_buffer_size = MAX_SINGLE_CHARS
 

Detailed Description

A UDP class which makes sure that we can use UDP as AudioSource and AudioSink. By default the WiFiUDP object is used and we login to wifi if the ssid and password is provided and we are not already connected.

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ UDPStream() [1/3]

UDPStream ( )
default

Default Constructor.

◆ UDPStream() [2/3]

UDPStream ( const char ssid,
const char password 
)
inline

Convinience constructor which defines the optional ssid and password.

Parameters
ssid
password

◆ UDPStream() [3/3]

UDPStream ( UDP udp)
inline

Constructor which defines an alternative UDP object. By default we use WiFiUDP.

Parameters
udp

Member Function Documentation

◆ available()

int available ( )
inlineoverridevirtual

Provides the available size of the current package and if this is used up of the next package

Reimplemented from BaseStream.

◆ availableForWrite()

int availableForWrite ( )
inlinevirtual

Always return 1492 (MTU 1500 - 8 byte header) as UDP packet available to write

Reimplemented from BaseStream.

◆ begin() [1/3]

virtual bool begin ( )
inlinevirtualinherited

◆ begin() [2/3]

bool begin ( IPAddress  a,
uint16_t  port 
)
inline

Starts to send data to the indicated address / port.

◆ begin() [3/3]

bool begin ( uint16_t  port,
uint16_t  port_ext = 0 
)
inline

Starts to receive data from/with the indicated port.

◆ beginMulticast()

bool beginMulticast ( IPAddress  address,
uint16_t  port 
)
inline

Starts to receive data in multicast from/with the indicated address / port.

◆ connect()

void connect ( )
inlineprotected

connect to WIFI if necessary

◆ end()

virtual void end ( )
inlinevirtualinherited

◆ flush()

virtual void flush ( )
inlineoverridevirtualinherited

◆ operator bool()

operator bool ( )
inlineinherited

◆ printIP()

void printIP ( )
inlineprotected

◆ readBytes()

size_t readBytes ( uint8_t data,
size_t  len 
)
inlineoverridevirtual

Reads bytes using WiFi::readBytes.

Implements BaseStream.

◆ refillReadBuffer()

void refillReadBuffer ( )
inlineprotectedinherited

Refill small read buffer (e.g. 8 bytes) to avoid single byte reads when calling read()

◆ remoteIP()

IPAddress remoteIP ( )
inline

We use the same remote ip as defined in begin for write.

◆ remotePort()

uint16_t remotePort ( )
inline

We use the same remote port as defined in begin for write.

◆ setPassword()

void setPassword ( const char pwd)
inline

◆ setSSID()

void setSSID ( const char ssid)
inline

◆ setUDP()

void setUDP ( UDP udp)
inline

Defines an alternative UDP object. By default we use WiFiUDP.

Parameters
udp

◆ setWriteBufferSize()

void setWriteBufferSize ( int  size)
inlineinherited

◆ write() [1/2]

size_t write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtual

Replys will be sent to the initial remote caller.

Implements BaseStream.

◆ write() [2/2]

virtual size_t write ( uint8_t  ch)
inlineoverridevirtualinherited

Member Data Documentation

◆ _timeout

int _timeout = 10
protectedinherited

◆ default_udp

WiFiUDP default_udp
protected

◆ p_udp

UDP* p_udp = &default_udp
protected

◆ password

const char* password = nullptr
protected

◆ remote_address_ext

IPAddress remote_address_ext
protected

◆ remote_port_ext

uint16_t remote_port_ext = 0
protected

◆ ssid

const char* ssid = nullptr
protected

◆ tmp_in

RingBuffer<uint8_t> tmp_in {0}
protectedinherited

◆ tmp_out

RingBuffer<uint8_t> tmp_out {0}
protectedinherited

◆ write_buffer_size

int write_buffer_size = MAX_SINGLE_CHARS
protectedinherited

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