User Manual
// Attempt to connect to the AP using the specified SSID/key/encoding
if ( !Feather.connect(WLAN_SSID, WLAN_PASS, WLAN_SECURITY ) )
{
err_t err = Feather.errno();
Serial.println("Connection Error:");
switch (err)
{
case ERROR_WWD_ACCESS_POINT_NOT_FOUND:
// SSID wasn't found when scanning for APs
Serial.println("Invalid SSID");
break;
case ERROR_WWD_INVALID_KEY:
// Invalid SSID passkey
Serial.println("Invalid Password");
break;
default:
// The most likely cause of errors at this point is that
// you are just out of the device/AP operating range
Serial.print(err);
Serial.print(":");
Serial.println(Feather.errstr());
break;
}
// Wait around here forever!
while(1);
}
// Optional: Disable TLS certificate verification (accept any server)
Feather.tlsRequireVerification(false);
// Optional: Set the default TCP timeout to 10s
tcp.setTimeout(10000);
// Set the callback handlers for RX and disconnect
tcp.setReceivedCallback(receive_callback);
tcp.setDisconnectCallback(disconnect_callback);
// Try to connect to the HTTP Server
if ( tcp.connect(TCP_DOMAIN, TCP_PORT) )
{
Serial.println("Connected to server");
// Make a basic HTTP request
tcp.printf("GET %s HTTP/1.1\r\n", TCP_FILENAME);
tcp.printf("host: %s\r\n", TCP_DOMAIN);
tcp.println();
}
else
{
Serial.printf("TCP connection failed: %s (%d)", tcp.errstr(), tcp.errno());
Serial.println();
while(1);
}
}
void loop()
{
// put your main code here, to run repeatedly:
}
void receive_callback(void)
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 81 of 202










