Wirepas SDK
wms_beacon_rx.h File Reference

Detailed Description

Application library for Bluetooth LE beacon RX

Library services are accessed via lib_beacon_rx handle.

Definition in file wms_beacon_rx.h.

Go to the source code of this file.

Typedefs

typedef void(* app_lib_beacon_rx_data_received_cb_f) (const app_lib_beacon_rx_received_t *packet)
 Function type for BLE Advertisement packet received callback. More...
 
typedef void(* app_lib_beacon_rx_set_data_received_cb_f) (app_lib_beacon_rx_data_received_cb_f cb)
 Set a callback to be called when data packet received. More...
 
typedef app_res_e(* app_lib_beacon_rx_start) (app_lib_beacon_rx_channels_mask_e channel)
 Start BLE advertisement scanner. More...
 
typedef app_res_e(* app_lib_beacon_rx_stop) (void)
 Stop BLE advertisement scanner. More...
 
typedef bool(* app_lib_beacon_rx_started) (void)
 Check if BLE advertisement scanner is running. More...
 

Data Structures

struct  app_lib_beacon_rx_received_t
 BLE structure received from network. Used in callback function set with lib_beacon_rx->setBeaconReceivedCb() service. More...
 
struct  app_lib_beacon_rx_t
 List of library functions. More...
 

Enumerations

enum  app_lib_beacon_rx_channels_mask_e { APP_LIB_BEACON_RX_CHANNEL_37 = 0x1, APP_LIB_BEACON_RX_CHANNEL_38 = 0x2, APP_LIB_BEACON_RX_CHANNEL_39 = 0x4, APP_LIB_BEACON_RX_CHANNEL_ALL = 0x7 }
 BLE Advertising channels to listen, used with lib_beacon_rx->startScanner() service. More...
 

Macros

#define APP_LIB_BEACON_RX_NAME   0x0cb93068
 Library symbolic name
More...
 
#define APP_LIB_BEACON_RX_VERSION   0x200
 Maximum supported library version. More...
 

Typedef Documentation

◆ app_lib_beacon_rx_data_received_cb_f

typedef void(* app_lib_beacon_rx_data_received_cb_f) (const app_lib_beacon_rx_received_t *packet)

Function type for BLE Advertisement packet received callback.

Parameters
packetReceived packet

Used with lib_beacon_rx->setBeaconReceivedCb() service.

Definition at line 72 of file wms_beacon_rx.h.

◆ app_lib_beacon_rx_set_data_received_cb_f

typedef void(* app_lib_beacon_rx_set_data_received_cb_f) (app_lib_beacon_rx_data_received_cb_f cb)

Set a callback to be called when data packet received.

Example on use:

static void BLEdataReceivedCb(const app_lib_beacon_rx_received_t * packet)
{
...
}
void App_init(const app_global_functions_t * functions)
{
// Set callback for received BT Beacon.
// This callback will be call in Interrupt Context !
lib_beacon_rx->setBeaconReceivedCb(BLEdataReceivedCb);
...
// Start the stack
lib_state->startStack();
}
Parameters
cbThe function to be executed, or NULL to unset
Note
This callback is called from IRQ context so keep the processing time at minimum!

Definition at line 105 of file wms_beacon_rx.h.

◆ app_lib_beacon_rx_start

typedef app_res_e(* app_lib_beacon_rx_start) (app_lib_beacon_rx_channels_mask_e channel)

Start BLE advertisement scanner.

For example on how to use this function, check lib_beacon_rx->isScannerStarted().

Parameters
channelmask BlueTooth advertisement channel mask to use
Returns
Result code, APP_RES_OK if successful, APP_RES_INVALID_STACK_STATE if BLE Scanner is already running, APP_RES_INVALID_NULL_POINTER if no callback set
Note
BLE advertisement scanner scanning in Low Energy Mode (see lib_settings->setNodeRole()) is an experimental feature in WM FW v5.1.0 and shall not be used by Wirepas licensees. No support is provided on this feature.

Definition at line 126 of file wms_beacon_rx.h.

◆ app_lib_beacon_rx_started

typedef bool(* app_lib_beacon_rx_started) (void)

Check if BLE advertisement scanner is running.

Example on use. When device receives a packet to destination endpoint 10, it checks whether BLE scanner is active. If not, it will start it.

#define SET_NUM_BTLE_EP 10
static app_lib_data_receive_res_e dataReceivedCb(
{
bool btle_started = lib_beacon_rx->isScannerStarted();
if (data->dest_endpoint != SET_NUM_BTLE_EP)
{
// Data was not for this application
}
if (!btle_started)
{
// Start BT Sanner now
lib_beacon_rx->startScanner(APP_LIB_BEACON_RX_CHANNEL_ALL);
}
// Data handled successfully
}
void App_init(const app_global_functions_t * functions)
{
// Set callback for received unicast messages
lib_data->setDataReceivedCb(dataReceivedCb);
// Start the stack
lib_state->startStack();
}
Returns
Result code, true if running, false if BLE advertisement scanner is not running

Definition at line 183 of file wms_beacon_rx.h.

◆ app_lib_beacon_rx_stop

typedef app_res_e(* app_lib_beacon_rx_stop) (void)

Stop BLE advertisement scanner.

Returns
Result code, APP_RES_OK if successful, APP_RES_INVALID_STACK_STATE if BLE Scanner is not running

Definition at line 134 of file wms_beacon_rx.h.


Data Structure Documentation

◆ app_lib_beacon_rx_received_t

struct app_lib_beacon_rx_received_t

BLE structure received from network. Used in callback function set with lib_beacon_rx->setBeaconReceivedCb() service.

Examples
ble_scanner/app.c.

Definition at line 51 of file wms_beacon_rx.h.

Data Fields
uint8_t length

Number of bytes of data payload

uint8_t * payload

Data payload

int8_t rssi

RSSI from packet received

uint8_t type

PDU type (BlueTooth Core_v5.0.pdf, p2567)

◆ app_lib_beacon_rx_t

struct app_lib_beacon_rx_t

List of library functions.

Definition at line 189 of file wms_beacon_rx.h.

Data Fields
app_lib_beacon_rx_started isScannerStarted
app_lib_beacon_rx_set_data_received_cb_f setBeaconReceivedCb
app_lib_beacon_rx_start startScanner
app_lib_beacon_rx_stop stopScanner

Enumeration Type Documentation

◆ app_lib_beacon_rx_channels_mask_e

BLE Advertising channels to listen, used with lib_beacon_rx->startScanner() service.

Enumerator
APP_LIB_BEACON_RX_CHANNEL_37 

Use advertising channel 37

APP_LIB_BEACON_RX_CHANNEL_38 

Use advertising channel 38

APP_LIB_BEACON_RX_CHANNEL_39 

Use advertising channel 39

APP_LIB_BEACON_RX_CHANNEL_ALL 

Use all advertising channels

Definition at line 34 of file wms_beacon_rx.h.

Macro Definition Documentation

◆ APP_LIB_BEACON_RX_NAME

#define APP_LIB_BEACON_RX_NAME   0x0cb93068

Library symbolic name

Definition at line 25 of file wms_beacon_rx.h.

◆ APP_LIB_BEACON_RX_VERSION

#define APP_LIB_BEACON_RX_VERSION   0x200

Maximum supported library version.

Definition at line 28 of file wms_beacon_rx.h.

APP_LIB_BEACON_RX_CHANNEL_39
@ APP_LIB_BEACON_RX_CHANNEL_39
Definition: wms_beacon_rx.h:41
APP_LIB_BEACON_RX_CHANNEL_37
@ APP_LIB_BEACON_RX_CHANNEL_37
Definition: wms_beacon_rx.h:37
APP_LIB_DATA_RECEIVE_RES_HANDLED
@ APP_LIB_DATA_RECEIVE_RES_HANDLED
Definition: wms_data.h:192
app_lib_beacon_rx_received_t
BLE structure received from network. Used in callback function set with lib_beacon_rx->setBeaconRecei...
Definition: wms_beacon_rx.h:51
app_lib_data_receive_res_e
app_lib_data_receive_res_e
Return value of data reception callback.
Definition: wms_data.h:188
app_lib_data_received_t::dest_endpoint
uint8_t dest_endpoint
Definition: wms_data.h:300
APP_LIB_BEACON_RX_CHANNEL_ALL
@ APP_LIB_BEACON_RX_CHANNEL_ALL
Definition: wms_beacon_rx.h:43
app_global_functions_t
List of global functions, passed to App_entrypoint()
Definition: wms_app.h:157
app_lib_data_received_t
Struct passed to data reception callback functions.
Definition: wms_data.h:283
APP_LIB_DATA_RECEIVE_RES_NOT_FOR_APP
@ APP_LIB_DATA_RECEIVE_RES_NOT_FOR_APP
Definition: wms_data.h:195
APP_LIB_BEACON_RX_CHANNEL_38
@ APP_LIB_BEACON_RX_CHANNEL_38
Definition: wms_beacon_rx.h:39
app_lib_beacon_rx_channels_mask_e
app_lib_beacon_rx_channels_mask_e
BLE Advertising channels to listen, used with lib_beacon_rx->startScanner() service.
Definition: wms_beacon_rx.h:34