User Manual
Returns: The number of bytes written.
Callback Handlers
AdafruitUDP supports a 'read' callback that will fire every time incoming UDP data is recieved over the open socket
connection.
The callback function has the following signature (although you are free to choose a different name if you wish to):
Before you can use the callback function, you need to register your callback handler (using the function signature in the
paragraph above).
You register the callback with the following function:
void setReceivedCallback (udpcallback_t fp)
Registers the function used to process 'data received' callbacks.
Parameters:
fp: The name of the function where callback events should be redirected to
Returns: Nothing
Examples
The examples below illustration some basic UDP concepts to help you understand the class described above.
UDP Echo Server
The following example will listen on port 8888 for any incoming UDP requests, and then echo them back to the
requesting device via the 'received' callback handler:
void received_callback(void);
See the example section at the bottom of this page for details on using the data received callback in the real
world.
#include <adafruit_feather.h>
#define WLAN_SSID "yourSSID"
#define WLAN_PASS "yourPass"
#define LOCAL_PORT 8888
AdafruitUDP udp;
char packetBuffer[255];
bool connectAP(void)
{
// Attempt to connect to an AP
Serial.print("Attempting to connect to: ");
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 91 of 202










