User Manual
AdafruitUDP
AdafruitUDP makes it easy to work with raw UDP sockets. It includes a convenient callback for incoming data, and a
number of helper functions to read and write data over a UDP socket.
You're free to 'poll' for incoming data and connection status, but the 'data received' callback fires whenever incoming
data is available, which can then be read via the .read() and related commands. Callbacks aren't mandatory, but help
keep your code easy to understand and more maintainable as your project grows in complexity.
UDP Socket API
The AdafruitUDP class includes the following functions:
UDP API
The following functions are primarilly based on the Arduino EthernetUDP (https://adafru.it/lGA) class and enable you to
work with UDP connections and packets.
uint8_t begin (uint16_t port)
Initialises the AdafruitUDP class for the specified local port.
Parameters:
port: The local port number to listen on (0..65535)
Returns: 1 if successful, 0 if there are no sockets available to be used.
void stop (void)
Disconnects from the UDP server, and releases any resources used during the UDP session.
// UDP API
virtual uint8_t begin (uint16_t port);
virtual void stop (void);
virtual int beginPacket (IPAddress ip, uint16_t port);
virtual int beginPacket (const char *host, uint16_t port);
virtual int endPacket (void);
virtual int parsePacket (void);
virtual IPAddress remoteIP (void);
virtual uint16_t remotePort (void);
// Stream API
virtual int read (void);
virtual int read (unsigned char* buffer, size_t len);
virtual int read (char* buffer, size_t len);
virtual int peek (void);
virtual int available (void);
virtual void flush (void);
virtual size_t write (uint8_t byte);
virtual size_t write (const uint8_t *buffer, size_t size);
// Callback
void setReceivedCallback (udpcallback_t fp);
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 87 of 202










