M5Unit-NFC 0.0.3 git rev:59f5362
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 ()
 
const Attributeattribute () const
 
TNF tnf () const
 
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
 
void setType (const char *s)
 
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

◆ 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

◆ 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"
Warning
type is changed to "T"
UTF-8 only

◆ 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
Note
If there is a part that can be omitted by the protocol, it is omitted and stored
Warning
type is changed to "U"