nRF5 SDK v16.0.0
Enumerations | Functions
CoAP Option

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_stringPointer to the string buffer where the decoded string will be placed.
[in,out]p_lengthp_length of the encoded string. Returns the size of the buffer used in bytes.
[in]p_encodedBuffer to decode.
Return values
NRF_SUCCESSIndicates that decoding was successful.
NRF_ERROR_DATA_SIZEIndicates 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_encodedPointer to buffer that will be used to fill the encoded string into.
[in,out]p_lengthLength of the buffer provided. Will also be used to return the size of the used buffer.
[in]p_stringString to encode.
[in]str_lenLength of the string to encode.
Return values
NRF_SUCCESSIndicates that encoding was successful.
NRF_ERROR_DATA_SIZEIndicates 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_dataPointer to the uint32_t value where the decoded uint will be placed.
[in,out]lengthSize of the encoded value.
[in]p_encodeduint value to be decoded into a uint32_t value.
Return values
NRF_SUCCESSIndicates that decoding was successful.
NRF_ERROR_NULLIf p_data or p_encoded pointer is NULL.
NRF_ERROR_INVALID_LENGTHIf 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_encodedPointer to buffer that will be used to fill the encoded uint into.
[in,out]p_lengthLength of the buffer provided. Will also be used to return the size of the used buffer.
[in]datauint value which could be anything from 1 to 4 bytes.
Return values
NRF_SUCCESSIndicates that encoding was successful.
NRF_ERROR_DATA_SIZEIndicates that the buffer provided was not sufficient to successfully encode the data.

Documentation feedback | Developer Zone | Subscribe | Updated