NFC Data Exchange Format (NDEF)¶
MiraOS supports NFC on supported platforms, see the NFC core API here.
NDEF is a standardised data format specification by the NFC Forum, used to describe a set of actions to be encoded onto a NFC tag, or to be exchanged between two active NFC devices.
The majority of NFC enabled devices (phones, readers, etc) support reading and/or writing NDEF messages from/to NFC tags.
At a basic level, an NDEF record contains two components:
- A record type used to contextualise the payload data
- Payload data
Together these two components represent the action to be taken by the devices when the NFC tag is touched. NDEF supports a fairly limited set of actions. More complex actions can be implemented with customised software running on the phone, tabled, or other touching devices.
Multiple records can be written to an NFC tag; however many software applications only act on the 1st record.
Enums¶
mira_nfc_ndef_tnf_t¶
Name | Description |
---|---|
MIRA_NFC_NDEF_TNF_EMPTY |
|
MIRA_NFC_NDEF_TNF_WELL_KNOWN_TYPE |
|
MIRA_NFC_NDEF_TNF_MIME_TYPE |
|
MIRA_NFC_NDEF_TNF_ABSOLUTE_URI |
|
MIRA_NFC_NDEF_TNF_EXTERNAL_TYPE |
|
MIRA_NFC_NDEF_TNF_UNKNOWN |
|
MIRA_NFC_NDEF_TNF_UNCHANGED |
|
MIRA_NFC_NDEF_TNF_RESERVED |
Structs¶
mira_nfc_ndef_record_t¶
Name | Type | Description |
---|---|---|
index |
uint16_t |
|
chunk |
mira_bool_t |
|
type_name_format |
mira_nfc_ndef_tnf_t |
|
type_length |
mira_size_t |
|
type |
uint8_t * |
|
id_length |
mira_size_t |
|
id |
uint8_t * |
|
payload_length |
mira_size_t |
|
payload |
uint8_t * |
mira_nfc_ndef_iter_t¶
Name | Type | Description |
---|---|---|
cur |
uint8_t * |
|
length |
mira_size_t |
|
index |
uint16_t |
|
last_record |
mira_bool_t |
mira_nfc_ndef_writer_t¶
Name | Type | Description |
---|---|---|
start |
uint8_t * |
|
ptr |
uint8_t * |
|
last |
uint8_t * |
|
left |
mira_size_t |
Functions¶
mira_nfc_ndef_iter_start¶
void mira_nfc_ndef_iter_start(mira_nfc_ndef_iter_t *iter, mira_nfc_ndef_record_t *record, uint8_t *msg_data, mira_size_t msg_length);
mira_nfc_ndef_iter_next¶
void mira_nfc_ndef_iter_next(mira_nfc_ndef_iter_t *iter, mira_nfc_ndef_record_t *record);
mira_nfc_ndef_iter_valid¶
mira_bool_t mira_nfc_ndef_iter_valid(mira_nfc_ndef_iter_t *iter);
mira_nfc_ndef_get_by_index¶
mira_bool_t mira_nfc_ndef_get_by_index(mira_nfc_ndef_record_t *record, mira_size_t index, uint8_t *msg_data, mira_size_t msg_length);
mira_nfc_ndef_get_by_id¶
mira_bool_t mira_nfc_ndef_get_by_id(mira_nfc_ndef_record_t *record, const uint8_t *id, mira_size_t id_length, uint8_t *msg_data, mira_size_t msg_length);
mira_nfc_ndef_get_by_id_str¶
mira_bool_t mira_nfc_ndef_get_by_id_str(mira_nfc_ndef_record_t *record, const char *id, uint8_t *msg_data, mira_size_t msg_length);
mira_nfc_ndef_write_start¶
mira_status_t mira_nfc_ndef_write_start(mira_nfc_ndef_writer_t *writer, uint8_t *data, mira_size_t length);
mira_nfc_ndef_write_end¶
mira_status_t mira_nfc_ndef_write_end(mira_nfc_ndef_writer_t *writer, mira_size_t *length);
mira_nfc_ndef_write_inplace¶
mira_status_t mira_nfc_ndef_write_inplace(mira_nfc_ndef_writer_t *writer, mira_nfc_ndef_tnf_t type_name_format, uint8_t **type, mira_size_t type_length, uint8_t **id, mira_size_t id_length, uint8_t **payload, mira_size_t payload_length);
mira_nfc_ndef_write_copy¶
mira_status_t mira_nfc_ndef_write_copy(mira_nfc_ndef_writer_t *writer, mira_nfc_ndef_tnf_t type_name_format, const uint8_t *type, mira_size_t type_length, const uint8_t *id, mira_size_t id_length, const uint8_t *payload, mira_size_t payload_length);