The WICED Feather library uses a handful of public constants, enums, typdefs and defines.  In some situations, you will have to use these constants, enums, typedefs or defines in your own sketches, and the most common values are documented below:

wl_enc_type_t

This typedef (which resolves to an int32_t value) is used to indicate the security encoding mechanism used by your AP when establishing a connection. You can indicate the following values in the encoding type parameter of Feather.connect:

  • ENC_TYPE_AUTO
    Attempts to automatically detect the security encoding type. This is the default option if no encoding type is specified in Feather.connect, but is also the slowest since it has to scan for all APs in range and determine the security type if the requested AP is found.
  • ENC_TYPE_OPEN
    Open AP (no security or password required)
  • ENC_TYPE_WEP
    WEP security with open authentication
  • ENC_TYPE_WEP_SHARED
    WEP security with shared authentication
  • ENC_TYPE_WPA_TKIP
  • WPA security with TKIP
  • ENC_TYPE_WPA_AES
    WPA security with AES
  • ENC_TYPE_WPA_MIXED
    WPA security with AES and TKIP
  • ENC_TYPE_WPA2_TKIP
    WPA2 security with TKIP
  • ENC_TYPE_WPA2_AES
    WPA2 security with AES
  • ENC_TYPE_WPA2_MIXED
    WPA2 security with TKIP and AES
  • ENC_TYPE_WPA_TKIP_ENT
    WPA enterprise security with TKIP
  • ENC_TYPE_WPA_AES_ENT
    WPA enterprise security with AES
  • ENC_TYPE_WPA_MIXED_ENT
    WPA enteprise security with TKIP and AES
  • ENC_TYPE_WPA2_TKIP_ENT
    WPA2 enterprise security with TKIP
  • ENC_TYPE_WPA2_AES_ENT
    WPA2 enterprise security with AES
  • ENC_TYPE_WPA2_MIXED_ENT
    WPA2 enterprise security with TKIP and AES
  • ENC_TYPE_WPS_OPEN
    WPS with open security
  • ENC_TYPE_WPS_SECURE
    WPS with AES security
  • ENC_TYPE_IBSS_OPEN
    BSS with open security

err_t

The most frequently encountered error codes are defined below:

  • ERROR_NONE (0)
    This means that no error occurred and that execution completed as expected
  • ERROR_OUT_OF_HEAP_SPACE (3)
    This error indicates that you have run out of heap memory in Feather Lib
  • ERROR_NOT_CONNECTED (20)
    You will get this error if you try to perform an operation that requires a connection to an AP or the Internet when you aren't connected.
  • ERROR_WWD_INVALID_KEY (1004)
    You will get this error if the password you provided for your AP is invalid
  • ERROR_WWD_AUTHENTICATION_FAILED (1006)
    You will get this error if authentication failed trying to connect to the AP
  • ERROR_WWD_NETWORK_NOT_FOUND (1024)
    You will get this error if the requested AP could not be found in an AP scan. A likely cause of this error message is that you are out of range of the AP.
  • ERROR_WWD_UNABLE_TO_JOIN (1025)
    You will get this error if you are unable to join the requested AP. A likely cause of this error message is that you are out of range of the AP.
  • ERROR_WWD_ACCESS_POINT_NOT_FOUND (1066)
    This error message indicates that the requested AP could not be found
  • ERROR_TLS_UNTRUSTED_CERTIFICATE (5035)
    Indicates that the certificate from the remote secure server could not be validated against any of the root certificates available to WICED. You may need to add another root certificate via Feather.addRootCA(...).
  • ERROR_SDEP_INVALIDPARAMETER (30002)
    This error indicates that an invalid parameter was provided to the underlying SDEP command, or a parameter was rejected by the command handler.

There are hundreds of other possible error codes, and they can't all be documented here, but using the .errno() and .errstr() functions in AdafruitFeather you can get either the 16-bit error code or a string that provides a basic description for that error code.  

The following code shows how you might use a combination of .errno() and .errstr() to handle common error codes:

// Attempt to connect to the AP
if ( Feather.connect("SSID", "PASSWORD", ENC_TYPE_AUTO ) )
{
  int8_t rssi = Feather.RSSI();
  uint32_t ipAddress = Feather.localIP();
  // Do something now that you are connected to the AP!
}
else
{
  // Display the error message
  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(Feather.errno());
      Serial.print(":");
      Serial.println(Feather.errstr());
      break;
  }    
}

wl_ap_info_t

Access points are described with the following typedef/struct, which you may need to access on certain specific occasions:

typedef struct ATTR_PACKED
{
  char     ssid[WIFI_MAX_SSID_LEN+1];
  uint8_t  bssid[6];
  int16_t  rssi;
  uint32_t max_data_rate;
  uint8_t  network_type;
  int32_t  security;
  uint8_t  channel;
  uint8_t  band_2_4ghz;
} wl_ap_info_t;
WIFI_MAX_SSID_LEN is equal to 32 and is set in adafruit_feather.h
Each AP described using this typedef will require 52 bytes of memory

This guide was first published on Mar 23, 2016. It was last updated on Sep 14, 2016.

This page (Constants) was last updated on Feb 11, 2016.

Text editor powered by tinymce.