Wirepas SDK
poslib_tlv.h File Reference

Library to encode/decode buffers in PosLibTLV compact format. More...

Detailed Description

Library to encode/decode buffers in PosLibTLV compact format.

Definition in file poslib_tlv.h.

Go to the source code of this file.

Functions

void PosLibTlv_init (poslib_tlv_record *rcd, uint8_t *buffer, uint8_t length)
 Initialize a TLV record. More...
 
poslib_tlv_res_e PosLibTlv_Decode_getNextItem (poslib_tlv_record *rcd, poslib_tlv_item_t *item)
 Decode the next tlv_item in the tlv_record passed in parameter. More...
 
poslib_tlv_res_e PosLibTlv_Encode_addItem (poslib_tlv_record *rcd, poslib_tlv_item_t *item)
 Encode tlv_item in the tlv_record passed as parameter. More...
 

Data Structures

struct  poslib_tlv_item_t
 Structure describing a Type Length Value item. More...
 
struct  poslib_tlv_record
 This structure holds the buffer containing TLV items and data to manage it, max. buffer size and current index. More...
 

Enumerations

enum  poslib_tlv_res_e { POSLIB_TLV_RES_OK, POSLIB_TLV_RES_ERROR, POSLIB_TLV_RES_END }
 List of return codes. More...
 

Function Documentation

◆ PosLibTlv_Decode_getNextItem()

poslib_tlv_res_e PosLibTlv_Decode_getNextItem ( poslib_tlv_record rcd,
poslib_tlv_item_t item 
)

Decode the next tlv_item in the tlv_record passed in parameter.

Parameters
[in]rcdPointer to a tlv_record structure to decode items from.
[in]itemPointer to a tlv_item. Updated by the call if return code is POSLIB_TLV_RES_OK
Returns
POSLIB_TLV_RES_OK if OK, see poslib_tlv_res_e otherwise.

◆ PosLibTlv_Encode_addItem()

poslib_tlv_res_e PosLibTlv_Encode_addItem ( poslib_tlv_record rcd,
poslib_tlv_item_t item 
)

Encode tlv_item in the tlv_record passed as parameter.

Parameters
[in]rcdPointer to a tlv_record structure to encode items into.
[in]itemPointer to a tlv_item to add.
Returns
POSLIB_TLV_RES_OK if encoding possible, see poslib_tlv_res_e otherwise.

◆ PosLibTlv_init()

void PosLibTlv_init ( poslib_tlv_record rcd,
uint8_t *  buffer,
uint8_t  length 
)

Initialize a TLV record.

Parameters
[in]rcdPointer to the tlv_record structure to initialize.
[in]bufferBuffer used by the tlv_record.
[in]lengthSize in bytes of the buffer.
Note
This funtion must be used before using the Tlv_Decode_getNextItem or Tlv_Encode_addItem functions.

Data Structure Documentation

◆ poslib_tlv_item_t

struct poslib_tlv_item_t

Structure describing a Type Length Value item.

Definition at line 26 of file poslib_tlv.h.

Data Fields
uint8_t length

Length of the value buffer.

uint16_t type

Type of the TLV item.

uint8_t * value

Pointer to the buffer containing the value

◆ poslib_tlv_record

struct poslib_tlv_record

This structure holds the buffer containing TLV items and data to manage it, max. buffer size and current index.

Definition at line 37 of file poslib_tlv.h.

Data Fields
uint8_t * buffer

Pointer to a buffer containing TLV Items.

uint8_t index

Current encode/decode index in the buffer.

uint8_t length

Length of the buffer.

Enumeration Type Documentation

◆ poslib_tlv_res_e

List of return codes.

Enumerator
POSLIB_TLV_RES_OK 

Successfully decoded one TLV item from the buffer.

POSLIB_TLV_RES_ERROR 

Decode error, item is too long or lenth field is 0.

POSLIB_TLV_RES_END 

End of buffer, nothing to decode.

Definition at line 15 of file poslib_tlv.h.

poslib_tlv_res_e
poslib_tlv_res_e
List of return codes.
Definition: poslib_tlv.h:15
POSLIB_TLV_RES_ERROR
@ POSLIB_TLV_RES_ERROR
Definition: poslib_tlv.h:18
POSLIB_TLV_RES_END
@ POSLIB_TLV_RES_END
Definition: poslib_tlv.h:19
POSLIB_TLV_RES_OK
@ POSLIB_TLV_RES_OK
Definition: poslib_tlv.h:17