AppNearMe µNFC stack for the NXP PN532 chip License: You can use the stack free of charge to prototype with mbed; if you want to use the stack with your commercial product, get in touch!

Dependents:   IOT_sensor_nfc AppNearMe_MuNFC_PN532_Test p2p_nfc_test NFCMoodLamp ... more

Embed: (wiki syntax)

« Back to documentation index

TLVList Class Reference

TLVList Class Reference

A simple container List of Type/Length/Values items. More...

#include <TLVList.h>

Public Types

enum  TLVType {
  UINT8, UINT32, UINT8_ARRAY, STRING,
  NONE, UNKNOWN
}
 

Type of a TLV item.

More...

Public Member Functions

TLVType getNext ()
 Iterate to next item.
TLVType getType ()
 Get current item's type.
uint8_t getUInt8 ()
 Get uint8_t value.
uint32_t getUInt32 ()
 Get uint32_t value.
size_t getArrayLength ()
 Get array length.
size_t getArray (uint8_t *buf, size_t maxLen)
 Get array.
size_t getStringLength ()
 Get string length.
size_t getString (char *str, size_t maxLen)
 Get string.
bool isSpace ()
 Check whether there is space left in list.
bool putUInt8 (uint8_t value)
 Put uint8_t value.
bool putUInt32 (uint32_t value)
 Put uint32_t value.
size_t putArray (uint8_t *buf, size_t len)
 Put array.
size_t putString (char *str)
 Put string.

Detailed Description

A simple container List of Type/Length/Values items.

Definition at line 28 of file TLVList.h.


Member Enumeration Documentation

enum TLVType

Type of a TLV item.

Enumerator:
UINT8 

Unsigned char (byte)

UINT32 

Unsigned int.

UINT8_ARRAY 

Byte array.

STRING 

String.

NONE 

End of packet.

UNKNOWN 

Unknown type.

Definition at line 41 of file TLVList.h.


Member Function Documentation

size_t getArray ( uint8_t *  buf,
size_t  maxLen 
)

Get array.

Parameters:
bufpointer to buffer's start
maxLenmaximum number of bytes to copy
Returns:
number of copied bytes

Definition at line 129 of file TLVList.cpp.

size_t getArrayLength (  )

Get array length.

Returns:
bytes array length

Definition at line 113 of file TLVList.cpp.

TLVList::TLVType getNext (  )

Iterate to next item.

Returns:
type if next item exists, NONE otherwise

Definition at line 36 of file TLVList.cpp.

size_t getString ( char *  str,
size_t  maxLen 
)

Get string.

Get string Copy string to buffer (including null-terminating char)

Copy string to buffer (including null-terminating char).

Parameters:
strpointer to string's start
maxLenmaximum number of chars to copy (not including null-terminating char)
Returns:
number of copied chars
Parameters:
strpointer to string's start
maxLenmaximum number of chars to copy (not including null-terminating char)
Returns:
number of copied chars

Definition at line 161 of file TLVList.cpp.

size_t getStringLength (  )

Get string length.

Returns:
string length

Definition at line 143 of file TLVList.cpp.

TLVList::TLVType getType (  )

Get current item's type.

Returns:
type if item exists, NONE otherwise

Definition at line 71 of file TLVList.cpp.

uint32_t getUInt32 (  )

Get uint32_t value.

Get uint32_t value If the current item's type is uint8_t, the value will be casted to uint32_t.

If the current item's type is uint8_t, the value will be casted to uint32_t.

Returns:
uint32_t value OR 0 if the type is incompatible
uint32_t value OR 0 if the type is incompatible

Definition at line 97 of file TLVList.cpp.

uint8_t getUInt8 (  )

Get uint8_t value.

Get uint8_t value If the current item's type is uint32_t, the value will be masked with 0xFF.

If the current item's type is uint32_t, the value will be masked with 0xFF.

Returns:
uint8_t value OR 0 if the type is incompatible
uint8_t value OR 0 if the type is incompatible

Definition at line 80 of file TLVList.cpp.

bool isSpace (  )

Check whether there is space left in list.

Returns:
true if there is space left, false otherwise

Definition at line 178 of file TLVList.cpp.

size_t putArray ( uint8_t *  buf,
size_t  len 
)

Put array.

Parameters:
bufpointer to buffer's start
lennumber of bytes to copy
Returns:
number of copied bytes

Definition at line 218 of file TLVList.cpp.

size_t putString ( char *  str )

Put string.

Parameters:
strpointer to null-terminated string's start
Returns:
number of copied bytes

Definition at line 233 of file TLVList.cpp.

bool putUInt32 ( uint32_t  value )

Put uint32_t value.

Parameters:
valueuint32_t value
Returns:
true on success, false if there is not enough space in buffer

Definition at line 202 of file TLVList.cpp.

bool putUInt8 ( uint8_t  value )

Put uint8_t value.

Parameters:
valueuint8_t value
Returns:
true on success, false if there is not enough space in buffer

Definition at line 187 of file TLVList.cpp.