arduino-audio-tools
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:
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. More...
 
 UDPStream (UDP &udp)
 Constructor which defines an alternative UDP object. By default we use WiFiUDP. More...
 
int available () override
 
int availableForWrite ()
 
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 flush ()
 
 operator bool ()
 
virtual int peek ()
 
virtual int read ()
 
size_t readBytes (uint8_t *buffer, size_t length) 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. More...
 
size_t write (const uint8_t *buffer, size_t size) override
 Replys will be sent to the initial remote caller.
 
virtual size_t write (uint8_t)
 

Protected Member Functions

void connect ()
 connect to WIFI if necessary
 

Protected Attributes

int _timeout = 10
 
WiFiUDP default_udp
 
UDP * p_udp = &default_udp
 
const char * password = nullptr
 
IPAddress remote_address_ext
 
uint16_t remote_port_ext
 
const char * ssid = nullptr
 

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/2]

UDPStream ( const char *  ssid,
const char *  password 
)
inline

Convinience constructor which defines the optional ssid and password.

Parameters
ssid
password

◆ UDPStream() [2/2]

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 Stream.

◆ availableForWrite()

int availableForWrite ( )
inlinevirtual

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

Reimplemented from Print.

◆ setUDP()

void setUDP ( UDP &  udp)
inline

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

Parameters
udp

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