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 This file must contain an NDEF message.

Types

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

Structs

mira_nfc_config_t

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.

Functions

mira_nfc_init

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).

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.

Return

See the enum definition.

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