M5Unit-NFC 0.1.0 git rev:93745b5
Loading...
Searching...
No Matches
m5::nfc::ndef::TLV Class Reference

NDEF TLV container. More...

#include <ndef_tlv.hpp>

Public Types

using container_type = std::vector<Record>
 

Public Member Functions

 TLV ()
 Default ctor (Tag::Null)
 
 TLV (const Tag t)
 Construct with the given Tag.
 
 ~TLV ()
 Destructor.
 
Tag tag () const
 Tag.
 
bool isTerminatorTLV () const
 Is terminator.
 
bool isMessageTLV () const
 Is Message?
 
bool isNullTLV () const
 Is Null TLV?
 
const container_type & records () const
 Get the records.
 
const std::vector< uint8_t > & payload () const
 Get the payload.
 
std::vector< uint8_t > & payload ()
 Get the payload.
 
uint32_t required () const
 Size required for encoding.
 
bool push_back (const Record &r)
 Push back the record.
 
void pop_back ()
 Removes the last record.
 
uint32_t encode (uint8_t *buf, const uint32_t blen) const
 Encode.
 
uint32_t decode (const uint8_t *buf, const uint32_t len)
 Decode.
 
void clear ()
 Clear internal buffers.
 
void dump ()
 Dump internal state for debugging.
 

Static Public Attributes

static const TLV Terminator
 Terminator instance.
 

Detailed Description

NDEF TLV container.

Constructor & Destructor Documentation

◆ TLV()

m5::nfc::ndef::TLV::TLV ( const Tag t)
inlineexplicit

Construct with the given Tag.

Parameters
tTag

Member Function Documentation

◆ clear()

void m5::nfc::ndef::TLV::clear ( )

Clear internal buffers.

Warning
Keep the tag

◆ decode()

uint32_t m5::nfc::ndef::TLV::decode ( const uint8_t * buf,
const uint32_t len )

Decode.

Parameters
bufPointer of the TLV
lenBuffer length
Return values
>0 Decoded length
==0 Error

◆ encode()

uint32_t m5::nfc::ndef::TLV::encode ( uint8_t * buf,
const uint32_t blen ) const

Encode.

Parameters
[out]bufBuffer
blenBuffer size
Return values
>0 Encoded length
==0 Error

◆ isMessageTLV()

bool m5::nfc::ndef::TLV::isMessageTLV ( ) const
inline

Is Message?

Returns
True if this TLV is a Message TLV

◆ isNullTLV()

bool m5::nfc::ndef::TLV::isNullTLV ( ) const
inline

Is Null TLV?

Returns
True if this TLV is a Null TLV

◆ isTerminatorTLV()

bool m5::nfc::ndef::TLV::isTerminatorTLV ( ) const
inline

Is terminator.

Returns
True if this TLV is a Terminator TLV

◆ payload() [1/2]

std::vector< uint8_t > & m5::nfc::ndef::TLV::payload ( )
inline

Get the payload.

Returns
Mutable TLV payload bytes
Precondition
Tag must NOT be Message

◆ payload() [2/2]

const std::vector< uint8_t > & m5::nfc::ndef::TLV::payload ( ) const
inline

Get the payload.

Returns
TLV payload bytes
Precondition
Tag must NOT be Message

◆ pop_back()

void m5::nfc::ndef::TLV::pop_back ( )

Removes the last record.

Note
Does nothing if there is no record

◆ push_back()

bool m5::nfc::ndef::TLV::push_back ( const Record & r)

Push back the record.

Parameters
rRecord
Returns
True if successful
Note
A copy of the Record is inserted at the end

◆ records()

const container_type & m5::nfc::ndef::TLV::records ( ) const
inline

Get the records.

Returns
NDEF records
Precondition
Tag must be Message

◆ required()

uint32_t m5::nfc::ndef::TLV::required ( ) const

Size required for encoding.

Returns
Required encoded size in bytes

◆ tag()

Tag m5::nfc::ndef::TLV::tag ( ) const
inline

Tag.

Returns
TLV tag