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

NDEF Record. More...

#include <ndef_record.hpp>

Public Member Functions

 Record (const TNF tnf) noexcept
 
uint32_t required () const
 Size required for encoding.
 
uint32_t encode (uint8_t *buf, const uint32_t blen) const
 Encode.
 
uint32_t decode (const uint8_t *buf, const uint32_t blen)
 Decode.
 
void clear ()
 Clear.
 
void dump () const
 Dump record for debug.
 
Attribute
Attributeattribute ()
 Gets mutable attribute.
 
const Attributeattribute () const
 Gets attribute.
 
TNF tnf () const
 Gets Type Name Format.
 
Type
Note
Well-known NDEF Record Types
NDEF Record Type Description Specification Reference
Di Device Information Device Information Record Type Definition
Gc Generic Control Generic Control Record Type Definition
Hc Handover Carrier Connection Handover
Hi Handover Initiate Connection Handover
Hm Handover Mediation Connection Handover
Hr Handover Request Connection Handover
Hs Handover Select Connection Handover
Mr Money Transfer Response NFC Money Transfer
Mt Money Transfer Request NFC Money Transfer
PHD Personal Health Device Personal Health Device Communication
Sig Signature Signature Record Type Definition
Sp Smart Poster Smart Poster Record Type Definition
T Text Text Record Type Definition
Te TNEP Status Tag NDEF Exchange Protocol
Tp Service Parameter Tag NDEF Exchange Protocol
Ts Service Select Tag NDEF Exchange Protocol
U URI URI Record Type Definition
V Verb Verb Record Type Definition
WLCCAP WLC Capability Wireless Charging
WLCCTL WLC Listen Control Wireless Charging
WLCFOD WLC JiFOD Wireless Charging
WLCINF WLC Poll Information Wireless Charging

If TNF is TNF::Media, type is MIME type string e.g. "text/plain" , "image/png"...

const char * type () const
 Gets the type string.
 
void setType (const char *s)
 Set the type string.
 
Identifier
uint32_t identifierSize () const
 Gets the identifier size.
 
const uint8_t * identifier () const
 Gets the identifier pointer.
 
void setIdentifier (const uint8_t *id, const uint32_t len)
 Set the identifier.
 
void clearIdentifier ()
 Clear the identifier.
 
Payload
std::string payloadAsString () const
 Obtain the payload as a string.
 
uint32_t payloadSize () const
 Gets the payload size.
 
const uint8_t * payload () const
 Gets the payload pointer.
 
void setPayload (const uint8_t *data, const uint32_t len)
 Set the payload data.
 
Payload helper for TNF::Wellknown
bool setTextPayload (const char *str, const char *lang)
 Set text to the payload.
 
bool setURIPayload (const char *uri, URIProtocol protocol)
 Set URI to the payload.
 

Protected Member Functions

bool apply_nested_message ()
 
void set_text_payload (const char *str, const char *lang)
 
void set_uri_payload (const char *uri, URIProtocol protocol)
 

Friends

bool operator== (const Record &a, const Record &b)
 Equal?
 

Detailed Description

NDEF Record.

Warning
CF is not supported

Member Function Documentation

◆ attribute() [1/2]

Attribute & m5::nfc::ndef::Record::attribute ( )
inline

Gets mutable attribute.

Returns
Mutable record attribute

◆ attribute() [2/2]

const Attribute & m5::nfc::ndef::Record::attribute ( ) const
inline

Gets attribute.

Returns
Record attribute

◆ decode()

uint32_t m5::nfc::ndef::Record::decode ( const uint8_t * buf,
const uint32_t blen )

Decode.

Parameters
bufPointer of the NDEF Record
blenBuffer length
Return values
>0 Decoded length
==0 Error

◆ encode()

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

Encode.

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

◆ identifier()

const uint8_t * m5::nfc::ndef::Record::identifier ( ) const
inline

Gets the identifier pointer.

Returns
Pointer to identifier bytes, or nullptr if empty

◆ identifierSize()

uint32_t m5::nfc::ndef::Record::identifierSize ( ) const
inline

Gets the identifier size.

Returns
Identifier size in bytes

◆ payload()

const uint8_t * m5::nfc::ndef::Record::payload ( ) const
inline

Gets the payload pointer.

Returns
Pointer to payload bytes, or nullptr if empty

◆ payloadAsString()

std::string m5::nfc::ndef::Record::payloadAsString ( ) const

Obtain the payload as a string.

Returns
Payload interpreted as a string

◆ payloadSize()

uint32_t m5::nfc::ndef::Record::payloadSize ( ) const
inline

Gets the payload size.

Returns
Payload size in bytes

◆ required()

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

Size required for encoding.

Returns
Required encoded size in bytes

◆ setIdentifier()

void m5::nfc::ndef::Record::setIdentifier ( const uint8_t * id,
const uint32_t len )
inline

Set the identifier.

Parameters
idPointer of the identifier
lenidentifier length

◆ setPayload()

void m5::nfc::ndef::Record::setPayload ( const uint8_t * data,
const uint32_t len )
inline

Set the payload data.

Parameters
dataPointer of the data
lendata length

◆ setTextPayload()

bool m5::nfc::ndef::Record::setTextPayload ( const char * str,
const char * lang )

Set text to the payload.

Parameters
strString as UTF-8
langISO/IANA language code. e.g. "en"
Returns
True if successful
Warning
type is changed to "T"
UTF-8 only

◆ setType()

void m5::nfc::ndef::Record::setType ( const char * s)
inline

Set the type string.

Parameters
sNull-terminated type string

◆ setURIPayload()

bool m5::nfc::ndef::Record::setURIPayload ( const char * uri,
URIProtocol protocol )

Set URI to the payload.

Parameters
uriURI full text e.g. https://www.example.com
protocolURIProtocol
Returns
True if successful
Note
If there is a part that can be omitted by the protocol, it is omitted and stored
Warning
type is changed to "U"

◆ tnf()

TNF m5::nfc::ndef::Record::tnf ( ) const
inline

Gets Type Name Format.

Returns
TNF value

◆ type()

const char * m5::nfc::ndef::Record::type ( ) const
inline

Gets the type string.

Returns
Null-terminated type string