NfcTagClass Class
NfcTagClass Class
Description
A class for managing NFC functionality of Ameba.
Syntax
class NfcTagClass
Members
Public Constructors | |
The public constructor should not be used as this class is intended to be a singleton class. Access member functions using the object instance named NFC tag. |
Public Methods | |
NfcTagClass::begin | Start NFC firmware. |
NfcTagClass::end | Stop NFC firmware. |
NfcTagClass::appendRtdText | Create and append an NFC Data Exchange Format (NDEF) text record. |
NfcTagClass::appendRtdUri | Create and append the NDEF URI record. |
NfcTagClass::appendVcard | Create and append V-Card record. |
NfcTagClass::appendAndroidPlayApp | Create and append AAR record. |
NfcTagClass::clearNdefMessage | Clear cached NDEF records. |
NfcTagClass::isUidValid | Check if UID field is valid. |
NfcTagClass::convertNdefToRaw | Convert the cached NDEF messages into raw NFC format data. |
NfcTagClass::convertRawToNdef | Convert the raw NFC format data into NDEF messages. |
NfcTagClass::convertRawToCache | Update the NFC tag content into NFC firmware. |
NfcTagClass::getLastUpdateTimestamp | Get the timestamp when the NFC cache was last updated. |
NfcTagClass::setWriteProtect | Set protection to enable/disable modification of NFC tag content. |
NfcTagClass::getNdefSize | Get current stored NDEF message size. |
NfcTagClass::getNdefData | Get current stored NDEF messages. |
NfcTagClass::begin
Description
Start NFC firmware.
Syntax
void begin(void);
Parameters
NA
Returns
NA
Example Code
Example: GetTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/GetTagContent/GetTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::end
Description
Stop NFC firmware.
Syntax
void end(void);
Parameters
NA
Returns
NA
Example Code
NA
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::appendRtdText
Description
Create and append an NFC Data Exchange Format (NDEF) text record.
Syntax
void appendRtdText(const char *text, unsigned char encodeType, const char *IANALanguageCode);
void appendRtdText(const char *text);
Parameters
text: the text message to add.
encodeType: The encoding type in UTF8 or UTF16.
IANALanguageCode: The code for language selected.
Returns
NA
Example Code
Example: StoreTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/StoreTagContent/StoreTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::appendRtdUri
Description
Create and append the NDEF URI record.
Syntax
void appendRtdUri(const char *text, unsigned char uriIdentifierCode);
void appendRtdUri(const char *text);
Parameters
text: The URI string
uriIdentifierCode: The URI code corresponding to the desired URI header
Returns
NA
Example Code
Example: UriWebPage
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/UriWebPage/UriWebPage.ino)
Notes and Warnings
uriIdentifierCode defaults to RTD_URI_HTTP_WWW if not specified, which is the “http://www.” header. “NfcTag.h” must be included to use the class function.
NfcTagClass::appendVcard
Description
Create and append the V-Card record.
Syntax
void appendVcard(const char *vcard, int vcard_len);
Parameters
vcard: The V-Card string content.
vcard_len: The length of the V-Card content.
Returns
NA
Example Code
Example: VCardContact
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/VCardContact/VCardContact.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::appendAndroidPlayApp
Description
Create and append Android Application Record (AAR) record.
Syntax
void appendAndroidPlayApp(const char *appName);
Parameters
appName: The application name in Android Google Play.
Returns
NA
Example Code
Example: GooglePlayApp
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/GooglePlayApp/GooglePlayApp.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::clearNdefMessage
Description
Clear cached NDEF records in NfcTag object.
Syntax
void clearNdefMessage(void);
Parameters
NA
Returns
NA
Example Code
Example: UpdateTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/UpdateTagContent/UpdateTagContent.ino)
Notes and Warnings
Only clears cached NDEF records in NfcTag object, does not affect records in NFC firmware. “NfcTag.h” must be included to use the class function.
NfcTagClass::isUidValid
Description
Check the contents of nfc_tag_content and verify the UID field.
Syntax
bool isUidValid(void);
Parameters
NA
Returns
This function returns true if the UID is valid, else return false.
Example Code
NA
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::convertNdefToRaw
Description
Convert the cached NDEF messages into raw NFC Tag Type2 format data.
Syntax
void convertNdefToRaw(void);
Parameters
NA
Returns
NA
Example Code
Example: UpdateTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/UpdateTagContent/UpdateTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::convertRawToNdef
Description
Convert the raw NFC Tag Type2 format data into NDEF messages.
Syntax
void convertRawToNdef(void);
Parameters
NA
Returns
NA
Example Code
NA
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::updateRawToCache
Description
Update raw NFC data into NFC firmware.
Syntax
void updateRawToCache(void);
Parameters
NA
Returns
NA
Example Code
Example: UpdateTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/UpdateTagContent/UpdateTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::getLastUpdateTimestamp
Description
Get the timestamp when the NFC cache was last updated.
Syntax
uint32_t getLastUpdateTimestamp(void);
Parameters
NA
Returns
This function returns the last update timestamp as 32-bit unsigned integer representing in milliseconds.
Example Code
Example: GetTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/UpdateTagContent/UpdateTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::setWriteProtect
Description
Set protection to enable/disable modifying of NFC tag content on Ameba by an NFC reader.
Syntax
void setWriteProtect(bool enable);
Parameters
enable: set to true to enable write protection, set to false to disable write protection.
Returns
NA
Example Code
NA
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::getNdefSize
Description
Get the currently stored NDEF message size.
Syntax
unsigned char getNdefSize(void);
Parameters
NA
Returns
This function returns the current size of the stored NDEF messages.
Example Code
Example: GetTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/GetTagContent/GetTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.
NfcTagClass::getNdefData
Description
Get the current stored NDEF messages.
Syntax
const struct NDEF *getNdefData(void);
Parameters
NA
Returns
This function returns the NDEF message in the struct array.
Example Code
Example: GetTagContent
(https://github.com/ambiot/amb1_arduino/blob/dev/Arduino_package/hardware/libraries/NFC/examples/GetTagContent/GetTagContent.ino)
Notes and Warnings
“NfcTag.h” must be included to use the class function.