Trident IoT SDK
 
Loading...
Searching...
No Matches
tr_tlv_parser.h File Reference

A utility to parse TridentIot TLV data. More...

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
+ Include dependency graph for tr_tlv_parser.h:

Go to the source code of this file.

Functions

bool find_tlv_by_tag (const uint8_t *buffer, size_t buffer_len, uint8_t tag, uint8_t *out_value, uint8_t *out_value_len)
 Search for a TLV entry by tag and validate its length.
 
bool update_tlv_tag (uint8_t *buffer, size_t buffer_size, uint8_t tag, const uint8_t *value, uint8_t length)
 Update an existing TLV entry if found, or append a new one. Assumes unused buffer space is filled with 0xFF.
 

Detailed Description

A utility to parse TridentIot TLV data.


SPDX-License-Identifier: LicenseRef-TridentMSLA SPDX-FileCopyrightText: 2025 Trident IoT, LLC https://www.tridentiot.com


Function Documentation

◆ find_tlv_by_tag()

bool find_tlv_by_tag ( const uint8_t * buffer,
size_t buffer_len,
uint8_t tag,
uint8_t * out_value,
uint8_t * out_value_len )

Search for a TLV entry by tag and validate its length.

If a matching tag is found and its value length is not zero, the value is copied into the provided output buffer.

Parameters
bufferPointer to the TLV data buffer.
buffer_lenLength of the TLV data buffer in bytes.
tagTag value to search for.
out_valuePointer to a buffer where the value will be copied.
out_value_lenPointer to variable holding the length of the copied data.
Returns
true if the tag is found, the length matches, and value was copied; false otherwise.

◆ update_tlv_tag()

bool update_tlv_tag ( uint8_t * buffer,
size_t buffer_size,
uint8_t tag,
const uint8_t * value,
uint8_t length )

Update an existing TLV entry if found, or append a new one. Assumes unused buffer space is filled with 0xFF.

Parameters
bufferPointer to the TLV buffer.
buffer_sizeTotal size of the buffer in bytes.
tagTag to search or insert.
valuePointer to the value data to insert/update.
lengthLength of the value in bytes.
Returns
true if the update or append was successful, false otherwise.