ruuvi.drivers.c
${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
|
Files | |
file | ruuvi_interface_communication_radio_test.h |
Data Structures | |
struct | ri_radio_channels_t |
Bitfield to describe related sensor data. More... | |
Typedefs | |
typedef void(* | ri_radio_activity_interrupt_fp_t) (const ri_radio_activity_evt_t evt) |
Type of radio activity interrupt. This is common to all radio modules, i,e, the callback gets called for every radio action. More... | |
Enumerations | |
enum | ri_radio_activity_evt_t { RI_RADIO_BEFORE , RI_RADIO_AFTER } |
radio activity event type. More... | |
enum | ri_radio_modulation_t { RI_RADIO_BLE_125KBPS , RI_RADIO_BLE_1MBPS , RI_RADIO_BLE_2MBPS } |
type of radio modulation to be used. More... | |
Functions | |
bool | ri_communication_radio_run_integration_test (const rd_test_print_fp printfp) |
void | print_modulation (const rd_test_print_fp printfp, const ri_radio_modulation_t modulation) |
Print used modulation to printfp. More... | |
uint8_t | ri_radio_num_channels_get (const ri_radio_channels_t channels) |
Check how many radio channels are enabled. More... | |
bool | ri_radio_supports (ri_radio_modulation_t modulation) |
Check if radio supports given modulation. More... | |
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. More... | |
rd_status_t | ri_radio_uninit () |
Release radio stack. More... | |
rd_status_t | ri_radio_address_get (uint64_t *const address) |
rd_status_t | ri_radio_address_set (uint64_t const address) |
void | ri_radio_activity_callback_set (const ri_radio_activity_interrupt_fp_t handler) |
Setup radio activity interrupt. More... | |
bool | ri_radio_is_init () |
Check if radio is initialized. More... | |
rd_status_t | ri_radio_get_modulation (ri_radio_modulation_t *const p_modulation) |
Get the modulation used by application. More... | |
typedef void(* ri_radio_activity_interrupt_fp_t) (const ri_radio_activity_evt_t evt) |
Type of radio activity interrupt. This is common to all radio modules, i,e, the callback gets called for every radio action.
[in] | evt | Type of radio event |
Definition at line 63 of file ruuvi_interface_communication_radio.h.
radio activity event type.
Enumerator | |
---|---|
RI_RADIO_BEFORE | Event is before radio goes active, i.e. radio turns on soon. |
RI_RADIO_AFTER | Event is after radio activity, i.e. radio was turned off. |
Definition at line 30 of file ruuvi_interface_communication_radio.h.
type of radio modulation to be used.
Definition at line 39 of file ruuvi_interface_communication_radio.h.
void print_modulation | ( | const rd_test_print_fp | printfp, |
const ri_radio_modulation_t | modulation | ||
) |
Print used modulation to printfp.
Example:
[in] | printfp | Function which accepts a char* message string to print. |
[in] | modulation | Modulation to print. |
bool ri_communication_radio_run_integration_test | ( | const rd_test_print_fp | printfp | ) |
void ri_radio_activity_callback_set | ( | const ri_radio_activity_interrupt_fp_t | handler | ) |
Setup radio activity interrupt.
This function allows driver to notify application on all radio activity.
[in] | handler | Function to call on radio event. Set to NULL to disable radio-level callback. |
rd_status_t ri_radio_address_get | ( | uint64_t *const | address | ) |
Writes maximum 64-bit unique address of the device to the pointer. This address may be changed during runtime. The address is identifier of the device on radio network, such as BLE MAC address.
[out] | address | Value of radio address, i.e. MAC address. |
RD_SUCCESS | on success |
RD_ERROR_NOT_SUPPORTED | if address cannot be returned on given platform |
rd_status_t ri_radio_address_set | ( | uint64_t const | address | ) |
Configures maximum 64-bit unique address of the device to the radio. The address is identifier of the device on radio network, such as BLE MAC address.
[in] | address | Address to configure, MSB first. |
RD_SUCCESS | on success. |
RD_ERROR_NOT_SUPPORTED | if address cannot be configured on given platform. |
RD_ERROR_INVALID_ADDR | if the address does not match protocol rules and cannot or is not converted automatically. |
RD_ERRO_BUSY | if radio stack is doing some other operation, try later. |
RD_ERROR_INVALID_STATE | if radio is in state where address is required, such as advertising, connected or scanning. |
rd_status_t ri_radio_get_modulation | ( | ri_radio_modulation_t *const | p_modulation | ) |
Get the modulation used by application.
Modulation is decided at initialization and used by all radio modules. However, other modules are allowed to switch to other modulation as a part of their operation, for example GATT can use 1 MBit/s when setting up connection and negotiate 2 MBit/s for the remainder of connection.
[out] | p_modulation | Modulation used by default. |
RD_SUCCESS | if modulation was written to pointer |
RD_ERROR_NULL | if p_modulation is NULL |
RD_ERROR_INVALID_STATE | if radio is not initialized. |
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.
[in] | modulation | Modulation for radio operations. If 2 MBPS is defined, primary advertising PHY is 1 MBPS and secondary PHY is 2 MBPS. Note: if other end of communication requests different speed, the implementation should support it if applicable to board. |
RD_SUCCESS | on success |
RD_ERROR_INVALID_STATE | if radio is already initialized. |
RD_ERROR_INVALID_PARAM | if trying to initialize radio with unsupported modulation. |
bool ri_radio_is_init | ( | ) |
Check if radio is initialized.
uint8_t ri_radio_num_channels_get | ( | const ri_radio_channels_t | channels | ) |
Check how many radio channels are enabled.
[in] | channels | Structure with enabled channels. |
bool ri_radio_supports | ( | ri_radio_modulation_t | modulation | ) |
Check if radio supports given modulation.
[in] | modulation | Modulation to check. |
true | If given modulation is supported by radio. |
false | If given modulation is not supported by radio. |
rd_status_t ri_radio_uninit | ( | ) |
Release radio stack.
This function also stops the internal radio activity callbacks
RD_SUCCESS | on success |
RD_ERROR_FORBIDDEN | if radio is in use by other user |