User Manual

/**************************************************************************/
/*!
@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);
// Print data along with peer's info
Serial.print("[RX] from ");
Serial.print(client.remoteIP());
Serial.printf(" port %d : ", client.remotePort());
Serial.write(buffer, len);
Serial.println();
// Echo back
client.write(buffer, len);
// call stop() to free memory by Client
client.stop();
}
}
/**************************************************************************/
/*!
@brief The setup function runs once when the board comes out of reset
*/
/**************************************************************************/
void setup()
{
Serial.begin(115200);
// Wait for the serial port to connect. Needed for native USB port only.
while (!Serial) delay(1);
Serial.println("TCP Server Example (Callbacks)\r\n");
// Print all software versions
Feather.printVersions();
while ( !connectAP() )
{
delay(500); // delay between each attempt
}
// Connected: Print network info
Feather.printNetwork();
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 85 of 202