25 static size_t safe_strlen (
const char * s,
size_t maxlen)
29 for (i = 0; i < maxlen; ++i)
37 static bool m_is_init;
110 err_code |= m_channel.
send (msg);
128 else if (NULL == device_name)
147 return ( (NULL != m_channel.
send) && (
true == m_is_init));
160 m_channel.
on_evt = on_evt;
#define RD_ERROR_NULL
Null Pointer.
uint32_t rd_status_t
bitfield for representing errors
#define RD_ERROR_INVALID_LENGTH
Invalid Length.
#define RD_SUCCESS
Internal Error.
#define RD_ERROR_DATA_SIZE
Invalid Data size.
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RT_ADV_SCAN_INTERVAL_MS
rd_status_t rt_adv_scan_stop(void)
Abort scanning.
rd_status_t rt_adv_send_data(ri_comm_message_t *const msg)
Send given message as a BLE advertisement.
rd_status_t rt_adv_connectability_set(const bool enable, const char *const device_name)
Start advertising BLE GATT connection.
rd_status_t rt_adv_scan_start(const ri_comm_evt_handler_fp_t on_evt)
Start scanning BLE advertisements.
bool rt_adv_is_init(void)
check if advertisement is initialized
rd_status_t rt_adv_uninit(void)
Uninitializes data advertising.
rd_status_t rt_adv_init(rt_adv_init_t *const adv_init_settings)
Initializes data advertising.
#define RT_ADV_SCAN_WINDOW_MS
Window of one scan per channel. Scan takes this * num_channels time.
rd_status_t rt_adv_stop(void)
Stops advertising. This is relevant only if the message was on repeat.
#define SCAN_RSP_NAME_MAX_LEN
Longer name gets truncated when advertised with UUID.
Header to enable and disable module compilation.
Ruuvi error codes and error check 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_adv_channels_set(const ri_radio_channels_t channels)
Set channels to use on radio. This has effect only on BLE advertising.
rd_status_t ri_adv_scan_start(const uint32_t window_interval_ms, const uint32_t window_size_ms)
setup scan window interval and window size.
@ NONCONNECTABLE_NONSCANNABLE
Nonconnectable, nonscannable.
@ CONNECTABLE_SCANNABLE
Connectable, scannable.
void ri_adv_rx_set_max_advertisement_data_length(const uint8_t max_adv_length)
Set maximum advertisement data length. This is used to limit the size of extended advertisement data.
rd_status_t ri_adv_manufacturer_id_set(const uint16_t id)
Set manufacturer ID of manufacturer specific advertisement.
rd_status_t ri_adv_init(ri_comm_channel_t *const channel)
Initialize Advertising module and scanning module.
rd_status_t ri_adv_scan_response_setup(const char *const name, const bool advertise_nus)
Configure advertising data with a scan response.
rd_status_t ri_adv_stop(void)
Stop ongoing advertisements.
rd_status_t ri_adv_uninit(ri_comm_channel_t *const channel)
rd_status_t ri_adv_type_set(ri_adv_type_t type)
Configure the type of advertisement.
rd_status_t ri_adv_tx_interval_set(const uint32_t ms)
rd_status_t ri_adv_tx_power_set(int8_t *dbm)
Set radio TX power.
rd_status_t ri_adv_scan_stop(void)
Stop ongoing scanning.
void ri_adv_rx_ble_phy_enabled_set(const bool is_le_1m_phy_enabled, const bool is_le_2m_phy_enabled, const bool is_le_coded_phy_enabled)
Set BLE PHYs enabled or disabled for scanning.
bool rt_gatt_is_nus_enabled(void)
Check if Nordic UART Service is enabled.
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.
Application message structure used for communication.
uint8_t data_length
Length of data.
Initial configuration for advertisement. PHY will be transferred to GATT.
uint16_t adv_interval_ms
ms / advertisement, not counting random delay
uint16_t manufacturer_id
BLE SIG id of board manufacturer.
bool is_rx_le_2m_phy_enabled
True if 2 MBit/s PHY is enabled in receiver.
ri_radio_channels_t channels
Radio channels, typically 37, 38, and/or 39.
uint8_t max_adv_length
Maximum length of advertisement data.
int8_t adv_pwr_dbm
Power to antenna, dBm.
bool is_rx_le_1m_phy_enabled
True if 1 MBit/s PHY is enabled in receiver.
bool is_rx_le_coded_phy_enabled
True if 125 kBit/s PHY is enabled in receiver.