Rtos API example

Embed: (wiki syntax)

« Back to documentation index

thread_meshcop_lib.h File Reference

thread_meshcop_lib.h File Reference

Public API to handle the Thread management framework message parsing and building. More...

Go to the source code of this file.

Functions

uint8_t * thread_meshcop_tlv_data_write (uint8_t *ptr, const uint8_t type, const uint16_t length, const uint8_t *data)
 Write array TLV.
uint8_t * thread_meshcop_tlv_data_write_header (uint8_t *ptr, uint8_t type, uint16_t length)
 Write header.
uint8_t * thread_meshcop_tlv_data_write_uint8 (uint8_t *ptr, const uint8_t type, const uint8_t data)
 Write 1 byte length TLV.
uint8_t * thread_meshcop_tlv_data_write_uint16 (uint8_t *ptr, const uint8_t type, const uint16_t data)
 Write 2 byte length TLV.
uint8_t * thread_meshcop_tlv_data_write_uint32 (uint8_t *ptr, const uint8_t type, const uint32_t data)
 Write 4 byte length TLV.
uint8_t * thread_meshcop_tlv_data_write_uint64 (uint8_t *ptr, const uint8_t type, const uint64_t data)
 Write 8 byte length TLV.
bool thread_meshcop_tlv_exist (const uint8_t *ptr, const uint16_t length, const uint8_t type)
 Check if TLV exists in the message.
uint16_t thread_meshcop_tlv_find (const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t **result_ptr)
 Find TLV from message.
int16_t thread_meshcop_tlv_length (const uint8_t *ptr, uint16_t length)
 Get length of the TLV.
int16_t thread_meshcop_tlv_length_required (const uint8_t *ptr, uint16_t length)
 Get length of the TLV including the type and length field.
const uint8_t * thread_meshcop_tlv_get_next (const uint8_t *ptr, uint16_t *length)
 Go through TLV list in order.
bool thread_meshcop_tlv_list_present (const uint8_t *ptr, uint16_t length, const uint8_t *required_tlv_ptr, uint8_t required_tlv_len)
 Validate that required TLVs are present in the buffer.
uint16_t thread_meshcop_tlv_list_generate (const uint8_t *ptr, uint16_t length, uint8_t *result_ptr, uint16_t *result_len)
 Get list of TLVS included in the buffer.
uint16_t thread_meshcop_tlv_list_remove (uint8_t *tlv_ptr, uint16_t tlv_len, uint8_t tlv_type)
 Remove TLV from list of TLVs.
bool thread_meshcop_tlv_list_type_available (const uint8_t *list_ptr, uint16_t list_len, uint8_t tlv_type)
 Check if specific type is available in list of TLVs.
uint16_t thread_meshcop_tlv_find_next (uint8_t *tlv_ba, uint16_t tlv_ba_length, uint8_t tlv_id, uint8_t **found_tlv)
 Find next TLV from message.
uint8_t thread_meshcop_tlv_data_get_uint8 (const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t *data_ptr)
 Read 1 byte length TLV.
uint8_t thread_meshcop_tlv_data_get_uint16 (const uint8_t *ptr, const uint16_t length, const uint8_t type, uint16_t *data_ptr)
 Read 2 byte length TLV.
uint8_t thread_meshcop_tlv_data_get_uint32 (const uint8_t *ptr, const uint16_t length, const uint8_t type, uint32_t *data_ptr)
 Read 4 byte length TLV.
uint8_t thread_meshcop_tlv_data_get_uint64 (const uint8_t *ptr, const uint16_t length, const uint8_t type, uint64_t *data_ptr)
 Read 8 byte length TLV.

Detailed Description

Public API to handle the Thread management framework message parsing and building.

Definition in file thread_meshcop_lib.h.


Function Documentation

uint8_t thread_meshcop_tlv_data_get_uint16 ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type,
uint16_t *  data_ptr 
)

Read 2 byte length TLV.

Parameters:
ptrpointer TLV message array.
lengthlength of TLV message array.
typeType of TLV.
data_ptrpointer to variable where the value is read.
Returns:
pointer length of TLV 2 if success. 0 means TLV not found or does not have any data.
Any other value indicates that TLV is not as expected.
uint8_t thread_meshcop_tlv_data_get_uint32 ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type,
uint32_t *  data_ptr 
)

Read 4 byte length TLV.

Parameters:
ptrpointer TLV message array.
lengthlength of TLV message array.
typeType of TLV.
data_ptrpointer to variable where the value is read.
Returns:
pointer length of TLV 4 if success. 0 means TLV not found or does not have any data.
Any other value indicates that TLV is not as expected.
uint8_t thread_meshcop_tlv_data_get_uint64 ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type,
uint64_t *  data_ptr 
)

Read 8 byte length TLV.

Parameters:
ptrpointer TLV message array.
lengthlength of TLV message array.
typeType of TLV.
data_ptrpointer to variable where the value is read.
Returns:
pointer length of TLV 4 if success. 0 means TLV not found or does not have any data.
Any other value indicates that TLV is not as expected.
uint8_t thread_meshcop_tlv_data_get_uint8 ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type,
uint8_t *  data_ptr 
)

Read 1 byte length TLV.

Parameters:
ptrpointer TLV message array.
lengthlength of TLV message array.
typeType of TLV.
data_ptrpointer to variable where the value is read.
Returns:
pointer length of TLV 1 if success. 0 means TLV not found or does not have any data.
Any other value indicates that TLV is not as expected.
uint8_t* thread_meshcop_tlv_data_write ( uint8_t *  ptr,
const uint8_t  type,
const uint16_t  length,
const uint8_t *  data 
)

Write array TLV.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
lengthlength of the data that is written in TLV.
dataarray for TLV value.
Returns:
pointer value for writing the next TLV.
uint8_t* thread_meshcop_tlv_data_write_header ( uint8_t *  ptr,
uint8_t  type,
uint16_t  length 
)

Write header.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
lengthlength of the data that is written in TLV.
Returns:
pointer value for writing the remaining bytes of network data.
uint8_t* thread_meshcop_tlv_data_write_uint16 ( uint8_t *  ptr,
const uint8_t  type,
const uint16_t  data 
)

Write 2 byte length TLV.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
datavalue.
Returns:
pointer value for writing the next TLV.
uint8_t* thread_meshcop_tlv_data_write_uint32 ( uint8_t *  ptr,
const uint8_t  type,
const uint32_t  data 
)

Write 4 byte length TLV.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
datavalue.
Returns:
pointer value for writing the next TLV.
uint8_t* thread_meshcop_tlv_data_write_uint64 ( uint8_t *  ptr,
const uint8_t  type,
const uint64_t  data 
)

Write 8 byte length TLV.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
datavalue.
Returns:
pointer value for writing the next TLV.
uint8_t* thread_meshcop_tlv_data_write_uint8 ( uint8_t *  ptr,
const uint8_t  type,
const uint8_t  data 
)

Write 1 byte length TLV.

Parameters:
ptrpointer for array where to write the TLV.
typeType of TLV.
datavalue.
Returns:
pointer value for writing the next TLV.
bool thread_meshcop_tlv_exist ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type 
)

Check if TLV exists in the message.

Parameters:
ptrMessage buffer.
lengthLength of the message buffer to validate message.
typeType of TLV searched.
Returns:
true if TLV is found.
false if TLV does not exist.
uint16_t thread_meshcop_tlv_find ( const uint8_t *  ptr,
const uint16_t  length,
const uint8_t  type,
uint8_t **  result_ptr 
)

Find TLV from message.

Parameters:
ptrMessage buffer.
lengthLength of the message buffer to validate message.
typeType of TLV searched.
result_ptrPointer value is given as result if length is positive. Can be NULL which only searches for the length.
Returns:
The length of the TLV data found
0 if TLV is empty or no TLV found.
negative value indicates corrupted message.
uint16_t thread_meshcop_tlv_find_next ( uint8_t *  tlv_ba,
uint16_t  tlv_ba_length,
uint8_t  tlv_id,
uint8_t **  found_tlv 
)

Find next TLV from message.

Parameters:
tlv_baTLV message buffer.
tlv_ba_lengthLength of the TLV message buffer.
tlv_idID of the TLV to be searched.
found_tlv[IN] Pointer value is given as result if length is > 0. Can be NULL which only searches for the length. \ [OUT] Pointer to previous TLV found
Returns:
The length of the TLV data found and found_tlv updated to point beginning of value field. 0 if TLV is not found.
const uint8_t* thread_meshcop_tlv_get_next ( const uint8_t *  ptr,
uint16_t *  length 
)

Go through TLV list in order.

Parameters:
ptrMessage buffer.
lengthLength of the message buffer to validate message. Length value modified to remaining value or 0 when no more TLVs present
Returns:
ptr to the next TLV
NULL if no TLV found.
int16_t thread_meshcop_tlv_length ( const uint8_t *  ptr,
uint16_t  length 
)

Get length of the TLV.

Parameters:
ptrMessage buffer.
lengthLength of the message buffer to validate message.
Returns:
The length of the TLV data found
0 if TLV is empty.
negative value indicates corrupted message or no TLV present.
int16_t thread_meshcop_tlv_length_required ( const uint8_t *  ptr,
uint16_t  length 
)

Get length of the TLV including the type and length field.

Parameters:
ptrMessage buffer.
lengthLength of the message buffer to validate message.
Returns:
The length of the TLV data found
0 if TLV is empty.
negative value indicates corrupted message or no TLV present.
uint16_t thread_meshcop_tlv_list_generate ( const uint8_t *  ptr,
uint16_t  length,
uint8_t *  result_ptr,
uint16_t *  result_len 
)

Get list of TLVS included in the buffer.

Parameters:
ptrTLV message buffer.
lengthLength of the TLV message buffer.
result_ptr[OUT] buffer where the IDs of TLVs are written. can be NULL when counting amount of TLVs
result_len[OUT] Amount of TLVs written in buffer
Returns:
amount of TLVs present in the buffer.
bool thread_meshcop_tlv_list_present ( const uint8_t *  ptr,
uint16_t  length,
const uint8_t *  required_tlv_ptr,
uint8_t  required_tlv_len 
)

Validate that required TLVs are present in the buffer.

Parameters:
ptrTLV message buffer.
lengthLength of the TLV message buffer.
required_tlv_ptrbuffer where the IDs of TLVs that are must be present
required_tlv_lenAmount of TLVs
Returns:
amount of TLVs present in the buffer.
uint16_t thread_meshcop_tlv_list_remove ( uint8_t *  tlv_ptr,
uint16_t  tlv_len,
uint8_t  tlv_type 
)

Remove TLV from list of TLVs.

Parameters:
tlv_ptrpointer to TLV List buffer.
tlv_lenLength of the TLV list buffer.
tlv_typeTLV that is removed from the List
Returns:
amount of TLVs present in the buffer.
bool thread_meshcop_tlv_list_type_available ( const uint8_t *  list_ptr,
uint16_t  list_len,
uint8_t  tlv_type 
)

Check if specific type is available in list of TLVs.

Parameters:
list_ptrPointer to TLV list buffer.
list_lenLength of the TLV list buffer.
tlv_typeTLV type to be find from the list
Returns:
true if type exists, false if type does not exist.