36 static bool m_nfc_is_connected;
37 static bool m_nfc_is_initialized;
66 m_nfc_is_connected =
true;
67 (NULL != m_on_connected) ? m_on_connected (p_data, data_len) :
false;
71 m_nfc_is_connected =
false;
72 (NULL != m_on_disconnected) ? m_on_disconnected (p_data, data_len) :
false;
76 (NULL != m_on_sent) ? m_on_sent (p_data, data_len) :
false;
80 (NULL != m_on_received) ? m_on_received (p_data, data_len) :
false;
105 written = snprintf ( (
char *) fw_string,
118 strlen ( (
char *) fw_string));
140 written = snprintf ( (
char *) name,
174 written = snprintf ( (
char *) id_string,
187 strlen ( (
char *) id_string));
198 if (NULL == init_data)
210 err_code |= id_set (init_data->
deviceid);
213 memcpy (&msg.
data,
"Data:", sizeof (
"Data:"));
215 m_channel.
on_evt = rt_nfc_isr;
216 err_code |= m_channel.
send (&msg);
219 m_nfc_is_initialized = (
RD_SUCCESS == err_code);
225 return m_nfc_is_initialized;
238 m_nfc_is_initialized =
false;
252 err_code |= m_channel.
send (message);
266 m_on_disconnected = cb;
281 return m_nfc_is_connected;
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_INVALID_LENGTH
Invalid Length.
#define RD_ERROR_NOT_ENABLED
Driver is not enabled.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
void(* ri_comm_cb_t)(void *p_data, size_t data_len)
#define RI_COMM_DIS_STRLEN
Maximum length for device information strings.
ri_comm_evt_t
Communication event type.
@ RI_COMM_CONNECTED
Connection established, OK to send, may receive data.
@ RI_COMM_RECEIVED
New data received, available to read with read function.
@ RI_COMM_SENT
One queued message was sent with all repetitions.
@ RI_COMM_DISCONNECTED
Connection lost, cannot send, may not receive data.
rd_status_t ri_nfc_address_set(const uint8_t *const address, const uint8_t length)
rd_status_t ri_nfc_init(ri_comm_channel_t *const channel)
rd_status_t ri_nfc_fw_version_set(const uint8_t *const version, const uint8_t length)
rd_status_t ri_nfc_uninit(ri_comm_channel_t *const channel)
rd_status_t ri_nfc_id_set(const uint8_t *const id, const uint8_t length)
Interface functions to scheduler.
void rt_nfc_set_on_disconn_isr(const ri_comm_cb_t cb)
Setup disconnection event handler.
bool rt_nfc_is_connected(void)
check if NFC is connected, i.e. a reader is in range. NFC data cannot be changed during connection,...
void rt_nfc_set_on_sent_isr(const ri_comm_cb_t cb)
Setup data sent event handler.
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....
void rt_nfc_set_on_connected_isr(const ri_comm_cb_t cb)
Setup connection event handler.
void rt_nfc_set_on_received_isr(const ri_comm_cb_t cb)
Setup data received event handler.
rd_status_t rt_nfc_send(ri_comm_message_t *message)
Sets given message to NFC RAM buffer. Clears previous message.
rd_status_t rt_nfc_uninit(void)
Uninitializes NFC.
bool rt_nfc_is_init(void)
check that NFC is initialized.
control API for communication via outside world
ri_comm_evt_handler_fp_t on_evt
Callback to application-level event handler, must be set in application.
ri_comm_xfer_fp_t send
Asynchronous send function.
char deviceaddr[RI_COMM_DIS_STRLEN]
Human readable device address, e.g. MAC.
char fw_version[RI_COMM_DIS_STRLEN]
Human readable firmware version.
char deviceid[RI_COMM_DIS_STRLEN]
Human readable device ID.
Application message structure used for communication.
uint8_t data[RI_COMM_MESSAGE_MAX_LENGTH]
Data payload.
uint8_t data_length
Length of data.