ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_task_nfc.h File Reference

NFC control. More...

Go to the source code of this file.

Functions

rd_status_t rt_nfc_init (ri_comm_dis_init_t *const init_data)
 Initializes NFC and configures FW, ADDR and ID records according to application_config.h constants. More...
 
rd_status_t rt_nfc_uninit (void)
 Uninitializes NFC. More...
 
bool rt_nfc_is_init (void)
 check that NFC is initialized. More...
 
rd_status_t rt_nfc_send (ri_comm_message_t *message)
 Sets given message to NFC RAM buffer. Clears previous message. More...
 
rd_status_t rt_nfc_on_nfc (ri_comm_evt_t evt, void *p_data, size_t data_len)
 Handle Ruuvi communication events from NFC driver. More...
 
void rt_nfc_set_on_connected_isr (const ri_comm_cb_t cb)
 Setup connection event handler. More...
 
void rt_nfc_set_on_disconn_isr (const ri_comm_cb_t cb)
 Setup disconnection event handler. More...
 
void rt_nfc_set_on_received_isr (const ri_comm_cb_t cb)
 Setup data received event handler. More...
 
void rt_nfc_set_on_sent_isr (const ri_comm_cb_t cb)
 Setup data sent event handler. More...
 
bool rt_nfc_is_connected ()
 check if NFC is connected, i.e. a reader is in range. NFC data cannot be changed during connection, setup data to be sent while NFC is not connected. More...
 

Detailed Description

NFC control.

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2020-02-21

Typical usage:

ri_communication_dis_init_t dis = {
.fw_version = "FW version",
.deviceid = "00:11:22:33:44:55:66:77",
.deviceaddr = "FF:EE:DD:CC:BB:AA"
};
err_code = rt_nfc_init(&dis);
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_CHECK(error, mask)
Shorthand macro for calling the rd_error_check with current file & line.
#define RD_SUCCESS
Internal Error.
rd_status_t rt_nfc_init(ri_comm_dis_init_t *const init_data)
Initializes NFC and configures FW, ADDR and ID records according to application_config....

Definition in file ruuvi_task_nfc.h.

Function Documentation

◆ rt_nfc_init()

rd_status_t rt_nfc_init ( ri_comm_dis_init_t *const  init_data)

Initializes NFC and configures FW, ADDR and ID records according to application_config.h constants.

Return values
RD_SUCCESSon success.
RD_ERROR_NULLif init_data is NULL
RD_ERROR_INVALID_STATEif NFC is already initialized.
Returns
error code from stack on error.

Definition at line 288 of file ruuvi_task_nfc.c.

◆ rt_nfc_is_connected()

bool rt_nfc_is_connected ( )

check if NFC is connected, i.e. a reader is in range. NFC data cannot be changed during connection, setup data to be sent while NFC is not connected.

Returns
true if NFC is connected, false otherwise.

Definition at line 319 of file ruuvi_task_nfc.c.

◆ rt_nfc_is_init()

bool rt_nfc_is_init ( void  )

check that NFC is initialized.

Returns
True if NFC is initialized, false otherwise.

◆ rt_nfc_on_nfc()

rd_status_t rt_nfc_on_nfc ( ri_comm_evt_t  evt,
void *  p_data,
size_t  data_len 
)

Handle Ruuvi communication events from NFC driver.

Parameters
[in]evtType of event.
[in]p_datapointer to data received. NULL if data was not received.
[in]data_lenlength of data received. 0 if data was NULL.
Returns
RD_SUCCESS if no error occurred
error code from stack on error.

◆ rt_nfc_send()

rd_status_t rt_nfc_send ( ri_comm_message_t message)

Sets given message to NFC RAM buffer. Clears previous message.

NFC data cannot be sent while NFC is connected, setup data before reader enters range.

Returns
RD_SUCCESS on success
error code from stack on error

Definition at line 293 of file ruuvi_task_nfc.c.

◆ rt_nfc_set_on_connected_isr()

void rt_nfc_set_on_connected_isr ( const ri_comm_cb_t  cb)

Setup connection event handler.

The event handler has signature of

void(*rt_comm_cb_t)(void* p_event_data, uint16_t event_size)

where event data is NULL and event_size is 0. The event handler is called in interrupt context.

Parameters
[in]cbCallback which gets called on connection in interrupt context.

Definition at line 298 of file ruuvi_task_nfc.c.

◆ rt_nfc_set_on_disconn_isr()

void rt_nfc_set_on_disconn_isr ( const ri_comm_cb_t  cb)

Setup disconnection event handler.

The event handler has signature of

void(*rt_comm_cb_t)(void* p_event_data, uint16_t event_size)

where event data is NULL and event_size is 0. The event handler is called in interrupt context.

Parameters
[in]cbCallback which gets called on disconnection in interrupt context.

Definition at line 304 of file ruuvi_task_nfc.c.

◆ rt_nfc_set_on_received_isr()

void rt_nfc_set_on_received_isr ( const ri_comm_cb_t  cb)

Setup data received event handler.

The event handler has signature of

void(*rt_comm_cb_t)(void* p_event_data, uint16_t event_size)

where event data is NULL and event_size is 0. The event handler is called in interrupt context.

Parameters
[in]cbCallback which gets called on data received in interrupt context.

Definition at line 309 of file ruuvi_task_nfc.c.

◆ rt_nfc_set_on_sent_isr()

void rt_nfc_set_on_sent_isr ( const ri_comm_cb_t  cb)

Setup data sent event handler.

The event handler has signature of

void(*rt_comm_cb_t)(void* p_event_data, uint16_t event_size)

where event data is NULL and event_size is 0. The event handler is called in interrupt context.

Parameters
[in]cbCallback which gets called on data sent in interrupt context.

Definition at line 314 of file ruuvi_task_nfc.c.

◆ rt_nfc_uninit()

rd_status_t rt_nfc_uninit ( void  )

Uninitializes NFC.

After uninitialization device is no longer readable with NFC reader.

Returns
RD_SUCCESS on success.
error code from stack on error.