Skip to content

NFC

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.

Defines

Name Value Description
MIRA_NFC_NDEF_FILE_ID 0xe104 File id of the NDEF file.This file must contain an NDEF message

Types

Name Type Description
mira_nfc_file_id_t uint16_t Type of file identifierUse 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.

Structs

mira_nfc_config_t

Type Name Description
void(*)(void *storage) callback_field_on Called when entering an NFC field
void(*)(void *storage) callback_field_off Called when leaving an NFC field
uint8_t *(*)(mira_nfc_file_id_t file_id, mira_size_t *size, void *storage) callback_file_open Called when a file is selected/opened
mira_bool_t)(mira_nfc_file_id_t file_id, mira_size_t size, void *storage) callback_file_save Called when a write is successful
void * storage Local storage for user data
uint16_t max_file_size Maximum 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 filesNumber of proprietary files beside the ndef file. Each proprietary file will enumerated starting from MIRA_NFC_PRORIETARY_FILE_ID_BASE.

Functions

mira_nfc_init

mira_status_t mira_nfc_init(
    const mira_nfc_config_t*  config);

Initialize the NRF module. The custom config passed as parameter (NULL for platform default). Note that this might start a higher resolution clock in the CPU, which can significantly increase the power consumption until CPU is restarted.

Parameters

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.

Return

See the enum definition.

mira_nfc_uninit

mira_status_t mira_nfc_uninit(
    void);

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