CoAP Option

nRF5 SDK v15.0.0

Nordic's CoAP Option APIs. More...

Enumerations

enum coap_opt_format_t {
COAP_OPT_FORMAT_EMPTY = 0,
COAP_OPT_FORMAT_STRING = 1,
COAP_OPT_FORMAT_OPAQUE = 2,
COAP_OPT_FORMAT_UINT = 3
}

Functions

uint32_t coap_opt_string_encode (uint8_t *p_encoded, uint16_t *p_length, uint8_t *p_string, uint16_t str_len)
Encode zero-terminated string into utf-8 encoded string. More...
uint32_t coap_opt_string_decode (uint8_t *p_string, uint16_t *p_length, uint8_t *p_encoded)
Decode a utf-8 string into a zero-terminated string. More...
uint32_t coap_opt_uint_encode (uint8_t *p_encoded, uint16_t *p_length, uint32_t data)
Encode a uint value into a uint8_t buffer in network byte order. More...
uint32_t coap_opt_uint_decode (uint32_t *p_data, uint16_t length, uint8_t *p_encoded)
Decode a uint encoded value in network byte order to a uint32_t value. More...

Detailed Description

Nordic's CoAP Option APIs.

Function Documentation

uint32_t coap_opt_string_decode ( uint8_t * p_string ,
uint16_t * p_length ,
uint8_t * p_encoded
)

Decode a utf-8 string into a zero-terminated string.

Parameters
[out] p_string Pointer to the string buffer where the decoded string will be placed.
[in,out] p_length p_length of the encoded string. Returns the size of the buffer used in bytes.
[in] p_encoded Buffer to decode.
Return values
NRF_SUCCESS Indicates that decoding was successful.
NRF_ERROR_DATA_SIZE Indicates that the buffer provided was not sufficient to successfully dencode the data.
uint32_t coap_opt_string_encode ( uint8_t * p_encoded ,
uint16_t * p_length ,
uint8_t * p_string ,
uint16_t str_len
)

Encode zero-terminated string into utf-8 encoded string.

Parameters
[out] p_encoded Pointer to buffer that will be used to fill the encoded string into.
[in,out] p_length Length of the buffer provided. Will also be used to return the size of the used buffer.
[in] p_string String to encode.
[in] str_len Length of the string to encode.
Return values
NRF_SUCCESS Indicates that encoding was successful.
NRF_ERROR_DATA_SIZE Indicates that the buffer provided was not sufficient to successfully encode the data.
uint32_t coap_opt_uint_decode ( uint32_t * p_data ,
uint16_t length ,
uint8_t * p_encoded
)

Decode a uint encoded value in network byte order to a uint32_t value.

Parameters
[out] p_data Pointer to the uint32_t value where the decoded uint will be placed.
[in,out] length Size of the encoded value.
[in] p_encoded uint value to be decoded into a uint32_t value.
Return values
NRF_SUCCESS Indicates that decoding was successful.
NRF_ERROR_NULL If p_data or p_encoded pointer is NULL.
NRF_ERROR_INVALID_LENGTH If buffer was greater than uint32_t.
uint32_t coap_opt_uint_encode ( uint8_t * p_encoded ,
uint16_t * p_length ,
uint32_t data
)

Encode a uint value into a uint8_t buffer in network byte order.

Parameters
[out] p_encoded Pointer to buffer that will be used to fill the encoded uint into.
[in,out] p_length Length of the buffer provided. Will also be used to return the size of the used buffer.
[in] data uint value which could be anything from 1 to 4 bytes.
Return values
NRF_SUCCESS Indicates that encoding was successful.
NRF_ERROR_DATA_SIZE Indicates that the buffer provided was not sufficient to successfully encode the data.