User Manual
Parameters: None
Returns: Nothing.
void setConnectCallback (tcpserver_callback_t fp)
Sets the TCP server callback event handler function for any incoming connection requests.
Parameters:
fp: The function that will be used to handling incoming connection requests.
Returns: Nothing.
The connect callback function handler has the following syntax:
Example
The following example will listen for connection requests on port 80 and echo back any data that is received. The
connection logic happens inside the connection request callback handler.
/**************************************************************************/
/*!
@brief This callback is fired when there is a connection request from
a TCP client. Use accept() to establish the connection and
retrieve the client 'AdafruitTCP' instance.
*/
/**************************************************************************/
void connect_request_callback(void)
{
uint8_t buffer[256];
uint16_t len;
AdafruitTCP client = tcpserver.available();
if ( client )
{
// read data
len = client.read(buffer, 256);
// Echo data back to the TCP client
client.write(buffer, len);
// call stop() to free memory in the client class
client.stop();
}
}
#include <adafruit_feather.h>
#define WLAN_SSID "yourSSID"
#define WLAN_PASS "yourPass"
#define PORT 80 // The TCP port to use
AdafruitTCPServer tcpserver(PORT);
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 84 of 202










