The WICED Feather supports the standard Arduino Client interface that is used by many networking boards in the Arduino ecosystem.
Adapting Client Examples
Most existing Client based examples can easily be adapted to work with the WICED Feather board family if the following changes are made to the sketches:
1. Update Header Includes
You will need to change the default WiFi (etc.) headers to the Adafruit versions, as shown below.
Remove Existing Headers
Existing headers like 'WiFi.h', 'WiFiUDP.h', etc., should be removed from the top of your sketch.
For example ...
#include <WiFi.h> #include <WiFiUdp.h> #include <WiFiTcp.h>
Add Adafruit WICED Feather Header
... should be replaced with the single 'adafruit_feather.h' header file:
#include <adafruit_feather.h>
2. Change 'WiFi.*' References to 'Feather.*'
References to functions like WiFi.begin(ssid, pass) or WiFi.available() should be replaced with Feather.begin(ssid, pass) or Feather.available():
Previous Client Code
// Attempt to connect to Wifi network: while (status != WL_CONNECTED) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: status = WiFi.begin(ssid, pass); // wait 10 seconds for connection: delay(10000); }
WICED Feather Client Code
Note that at present .begin in the WICED Feather library returns a bool, not a status byte (as in the WiFi example above), so the example has been modified slightly to detect connection status via the .connected function that is also part of the Client interface.
// Attempt to connect to Wifi network while (!Feather.connected()) { Serial.print("Attempting to connect to SSID: "); Serial.println(ssid); // Connect to any network. // The Feather stack will try to determine the network // security type automatically bool results = Feather.begin(ssid, pass); // Optional: wait a bit before checking for a connection delay(3000); }
3. Change WiFiUDP and WiFiTCP Class Types
If your example uses classes like WiFiUDP and WiFiTCP, simple replace the class names with AdafruitUDP or AdafruitTCP.
Existing WiFiUDP Class
// A UDP instance to let us send and receive packets over UDP WiFiUDP Udp;
Updated AdafruitUDP Class
// A UDP instance to let us send and receive packets over UDP AdafruitUDP Udp;
The UDP and TCP classes should generally be compatible with each other, so simply changing the class type and using the same field name should solve 90% of your problems.
Text editor powered by tinymce.