1 #ifndef RUUVI_INTERFACE_COMMUNICATION_H
2 #define RUUVI_INTERFACE_COMMUNICATION_H
17 # define RUUVI_NRF5_SDK15_COMMUNICATION_ENABLED RUUVI_NRF5_SDK15_ENABLED
25 #define RI_COMM_DIS_STRLEN 48
30 #define RI_COMM_MSG_REPEAT_FOREVER (0U)
32 #if defined(RI_ADV_EXTENDED_ENABLED) && RI_ADV_EXTENDED_ENABLED
33 # if !defined(RI_COMM_BLE_PAYLOAD_MAX_LENGTH)
34 # error "RI_COMM_BLE_PAYLOAD_MAX_LENGTH must be defined when RI_ADV_EXTENDED_ENABLED=1"
37 #if defined(RI_RE_CA_UART_ENABLED) && RI_RE_CA_UART_ENABLED
40 # define RI_COMM_BLE_PAYLOAD_MAX_LENGTH (31U)
44 # define RI_COMM_BLE_PAYLOAD_MAX_LENGTH (24U)
48 #if defined(RI_RE_CA_UART_ENABLED) && RI_RE_CA_UART_ENABLED
55 #define RI_COMM_MESSAGE_MAX_LENGTH (20 + RI_COMM_BLE_PAYLOAD_MAX_LENGTH)
61 #define RI_COMM_MESSAGE_MAX_LENGTH (RI_COMM_BLE_PAYLOAD_MAX_LENGTH)
82 "Data length must fit in uint8_t");
154 evt,
void * p_data,
size_t data_len);
uint32_t rd_status_t
bitfield for representing errors
Header to enable and disable module compilation.
Ruuvi error codes and error check function.
rd_status_t(* ri_comm_xfer_fp_t)(ri_comm_message_t *const msg)
Asynchronous transfer function. Puts/gets message in driver queue.
#define RI_COMM_MESSAGE_MAX_LENGTH
The maximum length for the application message for sending over BLE, which depends on whether extende...
void(* ri_comm_cb_t)(void *p_data, size_t data_len)
struct ri_comm_message_t ri_comm_message_t
Application message structure used for communication.
rd_status_t(* ri_comm_init_fp_t)(ri_comm_channel_t *const channel)
(Un-)Initialization function.
rd_status_t(* ri_comm_evt_handler_fp_t)(const ri_comm_evt_t evt, void *p_data, size_t data_len)
Application event handler for communication events.
rd_status_t ri_comm_id_get(uint64_t *const id)
#define RI_COMM_DIS_STRLEN
Maximum length for device information strings.
ri_comm_evt_t
Communication event type.
@ RI_COMM_TIMEOUT
Operation timed out.
@ 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_ABORTED
Operation aborted, e.g. advertising on connection.
@ RI_COMM_DISCONNECTED
Connection lost, cannot send, may not receive data.
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.
ri_comm_init_fp_t init
Initialize and populate channel api control.
ri_comm_init_fp_t uninit
Uninitialize and depopulate channel api control.
ri_comm_xfer_fp_t read
Asynchronous read function.
Application message structure used for communication.
_Static_assert(RI_COMM_MESSAGE_MAX_LENGTH<=UINT8_MAX, "Data length must fit in uint8_t")
uint8_t data[RI_COMM_MESSAGE_MAX_LENGTH]
Data payload.
uint8_t repeat_count
Number of times to repeat the message,.
uint8_t data_length
Length of data.