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

A UDP class which makes sure that we can use UDP as simple Stream w/o additional complexity. When we did not specify a target IP address we send the data to the address we received the data. Single character writes will be buffered up to the defined write buffer size (default 256 bytes) More...

#include <UDPStream.h>

Inheritance diagram for arduino::UDPStream:
arduino::Stream arduino::Print

Public Member Functions

 UDPStream ()=default
 Default Constructor.
 
 UDPStream (IPAddress a, uint16_t port)
 
int available () override
 
int availableForWrite () override
 
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.
 
void flush () override
 
int peek () override
 
int read () override
 
size_t readBytes (uint8_t *data, size_t len)
 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.
 
bool setTarget (IPAddress a, uint16_t port)
 Alternative to begin(IPAddress a, uint16_t port)
 
void setUDP (UDP &udp)
 Defines an alternative UDP object. By default we use WiFiUDP.
 
void setWriteBufferSize (size_t size)
 
void stop ()
 
size_t write (const uint8_t *data, size_t len) override
 Replys will be sent to the initial remote caller.
 
size_t write (uint8_t data) override
 
- Public Member Functions inherited from arduino::Stream
bool find (char target)
 
bool find (const char *target)
 
bool find (const char *target, size_t length)
 
bool find (const uint8_t *target)
 
bool find (const uint8_t *target, size_t length)
 
bool findUntil (const char *target, const char *terminator)
 
bool findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen)
 
bool findUntil (const uint8_t *target, const char *terminator)
 
bool findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen)
 
unsigned long getTimeout (void)
 
float parseFloat (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
long parseInt (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR)
 
size_t readBytes (char *buffer, size_t length)
 
size_t readBytes (uint8_t *buffer, size_t length)
 
size_t readBytesUntil (char terminator, char *buffer, size_t length)
 
size_t readBytesUntil (char terminator, uint8_t *buffer, size_t length)
 
String readString ()
 
String readStringUntil (char terminator)
 
void setTimeout (unsigned long timeout)
 
- Public Member Functions inherited from arduino::Print
void clearWriteError ()
 
int getWriteError ()
 
size_t print (char)
 
size_t print (const __FlashStringHelper *)
 
size_t print (const char[])
 
size_t print (const Printable &)
 
size_t print (const String &)
 
size_t print (double, int=2)
 
size_t print (int, int=DEC)
 
size_t print (long long, int=DEC)
 
size_t print (long, int=DEC)
 
size_t print (unsigned char, int=DEC)
 
size_t print (unsigned int, int=DEC)
 
size_t print (unsigned long long, int=DEC)
 
size_t print (unsigned long, int=DEC)
 
size_t println (char)
 
size_t println (const __FlashStringHelper *)
 
size_t println (const char[])
 
size_t println (const Printable &)
 
size_t println (const String &s)
 
size_t println (double, int=2)
 
size_t println (int, int=DEC)
 
size_t println (long long, int=DEC)
 
size_t println (long, int=DEC)
 
size_t println (unsigned char, int=DEC)
 
size_t println (unsigned int, int=DEC)
 
size_t println (unsigned long long, int=DEC)
 
size_t println (unsigned long, int=DEC)
 
size_t println (void)
 
size_t write (const char *buffer, size_t size)
 
size_t write (const char *str)
 

Protected Attributes

WiFiUDP default_udp
 
UDPp_udp = &default_udp
 
IPAddress remote_address_ext
 
uint16_t remote_port_ext = 0
 
std::vector< uint8_twrite_buffer
 
int write_buffer_size = 256
 
- Protected Attributes inherited from arduino::Stream
unsigned long _startMillis
 
unsigned long _timeout
 

Additional Inherited Members

- Protected Member Functions inherited from arduino::Stream
int findMulti (struct MultiTarget *targets, int tCount)
 
float parseFloat (char ignore)
 
long parseInt (char ignore)
 
int peekNextDigit (LookaheadMode lookahead, bool detectDecimal)
 
int timedPeek ()
 
int timedRead ()
 
- Protected Member Functions inherited from arduino::Print
void setWriteError (int err=1)
 

Detailed Description

A UDP class which makes sure that we can use UDP as simple Stream w/o additional complexity. When we did not specify a target IP address we send the data to the address we received the data. Single character writes will be buffered up to the defined write buffer size (default 256 bytes)

Author
Phil Schatzmann

Constructor & Destructor Documentation

◆ UDPStream()

arduino::UDPStream::UDPStream ( IPAddress  a,
uint16_t  port 
)
inline

Short hand constructor to start sending data to the indicated address / port

Member Function Documentation

◆ available()

int arduino::UDPStream::available ( void  )
inlineoverridevirtual

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

Implements arduino::Stream.

◆ availableForWrite()

int arduino::UDPStream::availableForWrite ( )
inlineoverridevirtual

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

Reimplemented from arduino::Print.

◆ flush()

void arduino::UDPStream::flush ( void  )
inlineoverridevirtual

Reimplemented from arduino::Print.

◆ peek()

int arduino::UDPStream::peek ( void  )
inlineoverridevirtual

Implements arduino::Stream.

◆ read()

int arduino::UDPStream::read ( void  )
inlineoverridevirtual

Implements arduino::Stream.

◆ setUDP()

void arduino::UDPStream::setUDP ( UDP udp)
inline

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

Parameters
udp

◆ write() [1/2]

size_t arduino::UDPStream::write ( const uint8_t data,
size_t  len 
)
inlineoverridevirtual

Replys will be sent to the initial remote caller.

Reimplemented from arduino::Print.

◆ write() [2/2]

size_t arduino::UDPStream::write ( uint8_t  data)
inlineoverridevirtual

Implements arduino::Print.


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