User Manual
This is a blocking command that only returns when the procedure succeeeds or fails. As such, we will ignore any return
data from the command other than a possible SDEP error code. As such, p_results_len and p_result are both set
to NULL here:
A more complex example is shown below where we read the SDEP response, and a pointer to certain parameter
values is also used (noticed the '&' character below some parameter values). The use of pointers is necessary when
passing large or complex parameters to the SDEP command handler.
In this particular example we use SDEP_CMD_TCP_READ but we also want to read the response data.
We pass in three parameters to SDEP_CMD_TCP_READ:
The TCP handle (_tcp_handle)
The number of bytes we want to read (size16)
The timeout before returning an error (_timeout)
The command will then return the data that was read back, populating the buf and size16 fields. The 'size16' field will
contain the numbers of bytes written to 'buf' so that we can compare the numbers of bytes requested with the number
of bytes actually read out.
bool AdafruitFeather::addProfile(char* ssid)
{
sdep_cmd_para_t para_arr[] =
{
{ .len = strlen(ssid), .p_value = ssid },
};
uint8_t para_count = sizeof(para_arr)/sizeof(sdep_cmd_para_t);
return sdep_n(SDEP_CMD_WIFI_PROFILE_ADD, para_count, para_arr,
NULL, NULL);
}
int AdafruitTCP::read(uint8_t* buf, size_t size)
{
if ( _tcp_handle == 0 ) return 0;
uint16_t size16 = (uint16_t) size;
sdep_cmd_para_t para_arr[] =
{
{ .len = 4, .p_value = &_tcp_handle },
{ .len = 2, .p_value = &size16 },
{ .len = 4, .p_value = &_timeout },
};
uint8_t para_count = sizeof(para_arr)/sizeof(sdep_cmd_para_t);
uint16_t readlen = size16;
VERIFY_RETURN( sdep_n(SDEP_CMD_TCP_READ, para_count, para_arr, &readlen, buf), 0);
_bytesRead += readlen;
return readlen;
}
The VERIFY macro in the example above is simply a helper to check the response from sdep_n, and it will
© Adafruit Industries https://learn.adafruit.com/introducing-the-adafruit-wiced-feather-wifi Page 153 of 202










