Skip to content


Near-field communication (NFC) is a set of communication protocols that enable two electronic devices, one of which is usually a portable device such as a smartphone, to establish communication by bringing them within close proximity of each other.

MiraOS support NFC-tag emulation.

Note: When using NFC on the nrf52840 platform TIMER4 is unavailable.


Name Value Description
MIRA_NFC_NDEF_FILE_ID 0xe104 File id of the NDEF file.

This file must contain an NDEF message.


Name Type Description
mira_nfc_file_id_t uint16_t Type of file identifier.

Used to identify files. The word length might change depending on backend implementation requirements. Only comparisons with other values of same type, or constants in this file.



Type Name Description
void(*)(void *storage) callback_field_on
void(*)(void *storage) callback_field_off
uint8_t *(*)(mira_nfc_file_id_t file_id, mira_size_t *size, void *storage) callback_file_open
mira_bool_t)(mira_nfc_file_id_t file_id, mira_size_t size, void *storage) callback_file_save
void * storage
uint16_t max_file_size The buffer returned by callback_file_open must be of at least this size to enable writing.
uint16_t proprietary_file_count Number of proprietary files beside the ndef file. Each proprietary file will enumerated starting from MIRA_NFC_PRORIETARY_FILE_ID_BASE.

Configuration of NFC tag interface.

All callbacks are synchronized to the threading, and will not interrupt a running thread, except during normal process switching.



mira_status_t mira_nfc_init(
    const mira_nfc_config_t*  config);

Initialize the NRF module.

The custom config is passed as a parameter (NULL for platform default).


Parameter Description
config Configuration of the nfc reader. This must be valid until mira_nfc_uninit() is called, and must not change during that time.


See the enum definition.

Value Description
MIRA_SUCCESS NFC successfully initialized.
MIRA_ERROR_UNKNOWN An unknown error occurred.


mira_status_t mira_nfc_uninit(

Close the nfc interface.

Free all references to the NFC interface, and close the hardware, until next call of mira_nfc_init.


See the enum definition.

Value Description
MIRA_SUCCESS NFC successfully uninitialized.
MIRA_ERROR_UNKNOWN An unknown error occurred.