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

Go to the source code of this file.

Data Structures

struct  rt_adv_init_t
 Initial configuration for advertisement. PHY will be transferred to GATT.
More...
 

Macros

#define SCAN_RSP_NAME_MAX_LEN   (11U)
 Longer name gets truncated when advertised with UUID. More...
 
#define RT_ADV_SCAN_WINDOW_MS   (7000U)
 Window of one scan per channel. Scan takes this * num_channels time. More...
 
#define RT_ADV_SCAN_INTERVAL_MS   (7000U)
 

Functions

rd_status_t rt_adv_init (rt_adv_init_t *const adv_init_settings)
 Initializes data advertising. More...
 
rd_status_t rt_adv_uninit (void)
 Uninitializes data advertising. More...
 
rd_status_t rt_adv_stop (void)
 Stops advertising. This is relevant only if the message was on repeat. More...
 
rd_status_t rt_adv_send_data (ri_comm_message_t *const msg)
 Send given message as a BLE advertisement. More...
 
rd_status_t rt_adv_connectability_set (const bool enable, const char *const device_name)
 Start advertising BLE GATT connection. More...
 
bool rt_adv_is_init (void)
 check if advertisement is initialized More...
 
rd_status_t rt_adv_scan_start (const ri_comm_evt_handler_fp_t on_evt)
 Start scanning BLE advertisements. More...
 
rd_status_t rt_adv_scan_stop (void)
 Abort scanning. More...
 

Detailed Description

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2020-06-01

Advertise data and GATT connection if available.

Typical usage:

channels.channel_37 = 1;
channels.channel_38 = 1;
channels.channel_39 = 1;
rt_adv_init_t adv_settings;
adv_settings.adv_interval_ms = APP_ADV_INTERVAL_MS;
adv_settings.adv_pwr_dbm = RB_TX_POWER_MAX;
adv_settings.channels = channels;
adv_settings.manufacturer_id = RB_BLE_MANUFACTURER_ID;
err_code |= rt_adv_init(&adv_settings);
err_code |= rt_adv_send_data (&my_message);
uint32_t rd_status_t
bitfield for representing errors
#define RD_SUCCESS
Internal Error.
rd_status_t ri_radio_init(const ri_radio_modulation_t modulation)
Enable radio stack for an user. This function also starts radio activity callbacks internally.
@ RI_RADIO_BLE_2MBPS
"Fast BLE". Advertising uses 1MBPS primary advertisement followed by 2 MBit/s extended advertisement.
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_init(rt_adv_init_t *const adv_init_settings)
Initializes data advertising.
@ NONCONNECTABLE_NONSCANNABLE
Nonconnectable, nonscannable.
rd_status_t ri_adv_type_set(ri_adv_type_t type)
Configure the type of advertisement.
Bitfield to describe related sensor data.
uint8_t channel_37
BLE channel 37, 2402 MHz.
uint8_t channel_39
BLE channel 39, 2480 MHz.
uint8_t channel_38
BLE channel 38, 2426 MHz.
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.
ri_radio_channels_t channels
Radio channels, typically 37, 38, and/or 39.
int8_t adv_pwr_dbm
Power to antenna, dBm.

Definition in file ruuvi_task_advertisement.h.