5.13.0.0R1
Software Development Kit
Helper functions

Functions

uint8_t double_to_string (char *buffer, uint8_t buffer_len, double value, uint8_t resolution)
 
uint8_t float_to_string (char *buffer, uint8_t buffer_len, float value, uint8_t resolution)
 
void format_wep_keys (char *wep_key_output, const char *wep_key_data, uint8_t *wep_key_length, wep_key_format_t wep_key_format)
 
uint32_t generic_string_to_unsigned (const char *str)
 
int is_digit_str (const char *str)
 
uint8_t match_string_with_wildcard_pattern (const char *string, uint32_t length, const char *pattern)
 
uint8_t signed64_to_decimal_string (int64_t value, char *output, uint8_t min_length, uint8_t max_length)
 
uint8_t signed_to_decimal_string (int32_t value, char *output, uint8_t min_length, uint8_t max_length)
 
uint8_t string_to_signed (const char *string, uint16_t str_length, int32_t *value_out, uint8_t is_hex)
 
uint8_t string_to_unsigned (const char *string, uint8_t str_length, uint32_t *value_out, uint8_t is_hex)
 
char * strncasestr (const char *s, uint16_t s_len, const char *substr, uint16_t substr_len)
 
char * strnstrn (const char *s, uint16_t s_len, const char *substr, uint16_t substr_len)
 
uint8_t unsigned64_to_decimal_string (uint64_t value, char *output, uint8_t min_length, uint8_t max_length)
 
uint8_t unsigned_to_decimal_string (uint32_t value, char *output, uint8_t min_length, uint8_t max_length)
 
uint8_t unsigned_to_hex_string (uint32_t value, char *output, uint8_t min_length, uint8_t max_length)
 
char * wiced_ether_ntoa (const uint8_t *ea, char *buf, uint8_t buf_len)
 

Detailed Description

This library implements helper functions for commonly used tasks.

Function Documentation

uint8_t double_to_string ( char *  buffer,
uint8_t  buffer_len,
double  value,
uint8_t  resolution 
)

Converts double precision floating point value to string

Parameters
buffer[in/out]: Pointer to buffer where the output string to be stored.
buffer_len[in]: Length of the buffer used for storing the output.
value[in]: Double floating point value to be converted to a string.
resolution[in]: Floating point resolution for the conversion. Supported max upto FLOAT_TO_STRING_MAX_FRACTION_SUPPORTED.
Returns
Number of char printed in buffer. On error, returns 0.
uint8_t float_to_string ( char *  buffer,
uint8_t  buffer_len,
float  value,
uint8_t  resolution 
)

Converts floating point value to string

Parameters
buffer[in/out]: Pointer to buffer where the output string to be stored.
buffer_len[in]: Length of the buffer used for storing the output.
value[in]: Floating point value to be converted to a string.
resolution[in]: Floating point resolution for the conversion. Supported max upto FLOAT_TO_STRING_MAX_FRACTION_SUPPORTED.
Returns
Number of char printed in buffer. On error, returns 0.
void format_wep_keys ( char *  wep_key_output,
const char *  wep_key_data,
uint8_t *  wep_key_length,
wep_key_format_t  wep_key_format 
)

Convert WEP security key to the format used by WICED

Parameters
[out]wep_key_ouputThe converted key
[in]wep_key_dataThe WEP key to convert
[in,out]wep_key_lengthThe length of the WEP key data. Upon return, the length of the converted WEP key
[in]wep_key_formatThe current format of the WEP key
uint32_t generic_string_to_unsigned ( const char *  str)

Convert a decimal or hexidecimal string to an integer.

Parameters
[in]strThe string containing the value.
Returns
The value represented by the string.
int is_digit_str ( const char *  str)

Verifies the provided string is a collection of digits.

Parameters
str[in]: The string to verify
Returns
1 if string is valid digits, 0 otherwise
uint8_t match_string_with_wildcard_pattern ( const char *  string,
uint32_t  length,
const char *  pattern 
)

Compare a string to a pattern containing wildcard character(s).

Note
: The following wildcard characters are supported:
  • '*' for matching zero or more characters
  • '?' for matching exactly one character
Parameters
[in]stringThe target string to compare with with the pattern
[in]lengthThe length of the target string
[in]patternThe NUL-terminated string pattern which contains wildcard character(s)
Returns
1 if the string matches the pattern; 0 otherwise.
uint8_t signed64_to_decimal_string ( int64_t  value,
char *  output,
uint8_t  min_length,
uint8_t  max_length 
)

Converts a signed 64-bit integer (long long) to a decimal string

Parameters
value[in]: The signed 64-bit integer (long long) to be converted.
output[out]: The buffer which will receive the decimal string. A terminating 'null' is added. Ensure that there is space in the buffer for this.
min_length[in]: The minimum number of characters to output (zero padding will apply if required).
max_length[in]: The maximum number of characters to output. The max number of characters it can have is of the length of (ULLONG_MAX + 1).
Returns
the number of characters returned (excluding terminating null)
uint8_t signed_to_decimal_string ( int32_t  value,
char *  output,
uint8_t  min_length,
uint8_t  max_length 
)

Converts a signed 32-bit long int to a decimal string

Parameters
value[in]: The signed 32-bit long int to be converted
output[out]: The buffer which will receive the decimal string. A terminating 'null' is added. Ensure that there is space in the buffer for this.
min_length[in]: The minimum number of characters to output (zero padding will apply if required)
max_length[in]: The maximum number of characters to output. The max number of characters it can have is of the length of (ULONG_MAX + 1).
Returns
the number of characters returned (excluding terminating null)
uint8_t string_to_signed ( const char *  string,
uint16_t  str_length,
int32_t *  value_out,
uint8_t  is_hex 
)

Converts a decimal/hexidecimal string (with optional sign) to a signed long int Better than strtol or atol or atoi because the return value indicates if an error occurred

Parameters
string[in]: The string buffer to be converted
str_length[in]: The maximum number of characters to process in the string buffer
value_out[out]: The unsigned in that will receive value of the the decimal string
is_hex[in]: 0 = Decimal string, 1 = Hexidecimal string
Returns
the number of characters successfully converted (including sign). i.e. 0 = error
uint8_t string_to_unsigned ( const char *  string,
uint8_t  str_length,
uint32_t *  value_out,
uint8_t  is_hex 
)

Converts a decimal/hexidecimal string to an unsigned long int Better than strtol or atol or atoi because the return value indicates if an error occurred

Parameters
string[in]: The string buffer to be converted
str_length[in]: The maximum number of characters to process in the string buffer
value_out[out]: The unsigned in that will receive value of the the decimal string
is_hex[in]: 0 = Decimal string, 1 = Hexidecimal string
Returns
the number of characters successfully converted. i.e. 0 = error
char* strncasestr ( const char *  s,
uint16_t  s_len,
const char *  substr,
uint16_t  substr_len 
)

Length limited version of strcasestr. Ported from bcmutils.c

Parameters
s[in]: The string to be searched.
s_len[in]: The length of the string to be searched.
substr[in]: The string to be found.
substr_len[in]: The length of the string to be found.
Returns
pointer to the found string if search successful, otherwise NULL
char* strnstrn ( const char *  s,
uint16_t  s_len,
const char *  substr,
uint16_t  substr_len 
)

Length limited version of strstr. Ported from bcmutils.c

Parameters
s[in]: The string to be searched.
s_len[in]: The length of the string to be searched.
substr[in]: The string to be found.
substr_len[in]: The length of the string to be found.
Returns
pointer to the found string if search successful, otherwise NULL
uint8_t unsigned64_to_decimal_string ( uint64_t  value,
char *  output,
uint8_t  min_length,
uint8_t  max_length 
)

Converts a unsigned 64-bit integer (long long) to a decimal string

Parameters
value[in]: The unsigned 64-bit integer (long long) to be converted.
output[out]: The buffer which will receive the decimal string. A terminating 'null' is added. Ensure that there is space in the buffer for this.
min_length[in]: The minimum number of characters to output (zero padding will apply if required).
max_length[in]: The maximum number of characters to output. The max number of characters it can have is of the length of (ULLONG_MAX + 1).
Returns
the number of characters returned (excluding terminating null)
uint8_t unsigned_to_decimal_string ( uint32_t  value,
char *  output,
uint8_t  min_length,
uint8_t  max_length 
)

Converts a unsigned 32-bit long int to a decimal string

Parameters
value[in]: The unsigned long to be converted.
output[out]: The buffer which will receive the decimal string. A terminating 'null' is added. Ensure that there is space in the buffer for this.
min_length[in]: The minimum number of characters to output (zero padding will apply if required).
max_length[in]: The maximum number of characters to output. The max number of characters it can have is of the length of (ULONG_MAX + 1).
Returns
the number of characters returned (excluding terminating null)
uint8_t unsigned_to_hex_string ( uint32_t  value,
char *  output,
uint8_t  min_length,
uint8_t  max_length 
)

Converts a unsigned 32-bit long int to a hexidecimal string

Parameters
value[in]: The unsigned 32-bit long int to be converted
output[out]: The buffer which will receive the hexidecimal string. A terminating 'null' is added. Ensure that there is space in the buffer for this.
min_length[in]: The minimum number of characters to output (zero padding will apply if required)
max_length[in]: The maximum number of characters to output. The max number of characters it can have is of the length of (ULONG_MAX + 1).
Note
: No leading '0x' is added.
Returns
the number of characters returned (excluding terminating null)
char* wiced_ether_ntoa ( const uint8_t *  ea,
char *  buf,
uint8_t  buf_len 
)

Convert ether address to a printable string

Parameters
[in]eaEthernet address to convert
[in]bufBuffer to write the ascii string into
[in]buf_lenLength of the memory buf points to
Returns
Pointer to buf if successful; "" if not successful due to buffer too short