ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
#include "ruuvi_driver_enabled_modules.h"
#include "ruuvi_driver_error.h"
#include "ruuvi_interface_atomic.h"
#include "ruuvi_interface_communication_ble_advertising.h"
#include "ruuvi_interface_communication_ble_gatt.h"
#include "ruuvi_interface_communication_radio.h"
#include "ruuvi_interface_communication.h"
#include "ruuvi_interface_log.h"
#include "ruuvi_interface_rtc.h"
#include "ruuvi_interface_scheduler.h"
#include "ruuvi_task_advertisement.h"
#include "ruuvi_task_communication.h"
#include "ruuvi_task_gatt.h"
Go to the source code of this file.
Functions | |
rd_status_t | rt_gatt_send_asynchronous (ri_comm_message_t *const p_msg) |
Send given message via NUS. More... | |
rd_status_t | rt_gatt_dfu_init (void) |
Initialize Device Firmware Update service. More... | |
rd_status_t | rt_gatt_dis_init (const ri_comm_dis_init_t *const dis) |
Initialize Device Information Update service. More... | |
rd_status_t | rt_gatt_nus_init () |
Initialize Nordic UART Service. More... | |
rd_status_t | rt_gatt_init (const char *const name) |
Initialize GATT. Must be called as a first function in rt_gatt. More... | |
rd_status_t | rt_gatt_adv_enable () |
Start advertising GATT connection to devices. More... | |
rd_status_t | rt_gatt_adv_disable () |
Stop advertising GATT connection to devices. More... | |
bool | rt_gatt_is_init () |
check if GATT task is initialized More... | |
void | rt_gatt_set_on_connected_isr (const ri_comm_cb_t cb) |
Setup connection event handler. More... | |
void | rt_gatt_set_on_disconn_isr (const ri_comm_cb_t cb) |
Setup disconnection event handler. More... | |
void | rt_gatt_set_on_received_isr (const ri_comm_cb_t cb) |
Setup data received event handler. More... | |
void | rt_gatt_set_on_sent_isr (const ri_comm_cb_t cb) |
Setup data sent event handler. More... | |
bool | rt_gatt_is_nus_enabled (void) |
Check if Nordic UART Service is enabled. More... | |
rd_status_t rt_gatt_adv_disable | ( | ) |
Stop advertising GATT connection to devices.
Calling this function is not enough to stop advertising connection, you must also update advertised data to remove the scan response from data being advertised. This makes sure that advertised data stays valid. This function has not effect if called while already disabled
RD_SUCCESS | on success |
RD_ERROR_INVALID_STATE | if GATT is not initialized. |
Definition at line 406 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_adv_enable | ( | ) |
Start advertising GATT connection to devices.
Calling this function is not enough to let users to connect, you must also update advertised data to add the scan response to data being advertised. This makes sure that advertised data stays valid. This function has no effect if called while already enabled.
RD_SUCCESS | on success |
RD_ERROR_INVALID_STATE | if GATT is not initialized. |
Definition at line 401 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_dfu_init | ( | void | ) |
Initialize Device Firmware Update service.
GATT must be initialized before calling this function, and once initialized the DFU service cannot be uninitialized.
Call will return successfully even if the device doesn't have useable bootloader, however program will reboot if user tries to enter bootloader in that case.
To use the DFU service advertisement module must send connectable (and preferably scannable) advertisements.
RD_SUCCESS | GATT was initialized successfully |
RD_ERROR_INVALID_STATE | DFU was already initialized or GATT is not initialized |
Definition at line 381 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_dis_init | ( | const ri_comm_dis_init_t *const | dis | ) |
Initialize Device Information Update service.
GATT must be initialized before calling this function, and once initialized the DIS service cannot be uninitialized.
DIS service lets user read basic information, such as firmware version and hardware model over GATT in a standard format.
To use the DIS service advertisement module must send connectable (and preferably scannable) advertisements.
[in] | dis | structure containing data to be copied into DIS, can be freed after call finishes. |
RD_SUCCESS | GATT was initialized successfully |
RD_ERROR_NULL | if given NULL as the information. |
RD_ERROR_INVALID_STATE | DIS was already initialized or GATT is not initialized |
Definition at line 386 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_init | ( | const char *const | name | ) |
Initialize GATT. Must be called as a first function in rt_gatt.
After calling this function underlying software stack is ready to setup GATT services.
[in] | name | Full name of device to be advertised in scan responses. Maximum 11 chars + trailing NULL. Must not be NULL, 0-length string is valid. |
RD_SUCCESS | on success. |
RD_ERROR_NULL | if name is NULL (use 0-length string instead) |
RD_ERROR_INVALID_LENGTH | if name is longer than SCAN_RSP_NAME_MAX_LEN |
RD_ERROR_INVALID_STATE | if GATT is already initialized or advertisements are not initialized. |
Definition at line 396 of file ruuvi_task_gatt.c.
bool rt_gatt_is_init | ( | ) |
check if GATT task is initialized
Definition at line 411 of file ruuvi_task_gatt.c.
bool rt_gatt_is_nus_enabled | ( | ) |
Check if Nordic UART Service is enabled.
The event handler has signature of
where event data is NULL and event_size is 0. The event handler is called in interrupt context.
Definition at line 437 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_nus_init | ( | ) |
Initialize Nordic UART Service.
GATT must be initialized before calling this function, and once initialized the NUS service cannot be uninitialized.
NUS service lets user do bidirectional communication with the application.
To use the NUS service advertisement module must send connectable (and preferably scannable) advertisements.
RD_SUCCESS | GATT was initialized successfully |
RD_ERROR_NULL | if given NULL as the information. |
RD_ERROR_INVALID_STATE | DIS was already initialized or GATT is not initialized |
Definition at line 391 of file ruuvi_task_gatt.c.
rd_status_t rt_gatt_send_asynchronous | ( | ri_comm_message_t *const | p_msg | ) |
Send given message via NUS.
Ruuvi Firmware 3.x GATT tasks.
License: BSD-3 Author: Otso Jousimaa otso@ ojou sima. net
Definition at line 375 of file ruuvi_task_gatt.c.
void rt_gatt_set_on_connected_isr | ( | const ri_comm_cb_t | cb | ) |
Setup connection event handler.
The event handler has signature of
where event data is NULL and event_size is 0. The event handler is called in interrupt context.
[in] | cb | Callback which gets called on connection in interrupt context. |
Definition at line 416 of file ruuvi_task_gatt.c.
void rt_gatt_set_on_disconn_isr | ( | const ri_comm_cb_t | cb | ) |
Setup disconnection event handler.
The event handler has signature of
where event data is NULL and event_size is 0. The event handler is called in interrupt context.
[in] | cb | Callback which gets called on disconnection in interrupt context. |
Definition at line 422 of file ruuvi_task_gatt.c.
void rt_gatt_set_on_received_isr | ( | const ri_comm_cb_t | cb | ) |
Setup data received event handler.
The event handler has signature of
where event data is pointer to raw bytes and event_size is length of received data. The event handler is called in interrupt context.
[in] | cb | Callback which gets called on data received in interrupt context. |
Definition at line 427 of file ruuvi_task_gatt.c.
void rt_gatt_set_on_sent_isr | ( | const ri_comm_cb_t | cb | ) |
Setup data sent event handler.
The event handler has signature of
where event data is NULL and event_size is 0. The event handler is called in interrupt context.
[in] | cb | Callback which gets called on data sent in interrupt context. |
Definition at line 432 of file ruuvi_task_gatt.c.