Appiko
Data Structures | Macros | Enumerations | Functions
BLE Advertisements

Driver of the radio to generate BLE advertisements with scan responses. More...

Data Structures

struct  ble_adv_param_t
 The structure format for setting the advertisement parameters. More...
 

Macros

#define ADV_INTERVAL_MS(x)   ((x*16)/10)
 
#define ADRS_LEN   6
 length of MAC address in BLE
 
#define ADV_HEADER_LEN   2
 length of header in BLE
 

Enumerations

enum  adrs_type_t
 The address types in BLE advertisement: Public and random.
 
enum  ble_adv_type_t
 Defines for advertising parameters (BLE Spec 4.2 Vol 2, Part E, 7.8.5 Page No:1277)
 
enum  ble_adv_ch_map_t {
  CH_37_PARAM = 1, CH_38_PARAM, CH_37_38_PARAM, CH_39_PARAM,
  CH_37_39_PARAM, CH_38_39_PARAM, CH_ALL_PARAM
}
 The various advertisement channels combinations that can be used for advertising. More...
 

Functions

void ble_adv_set_tx_power (int8_t pwr)
 Set the advertising transmission power in dBm. More...
 
int8_t ble_adv_get_tx_power (void)
 Get the advertising transmission power in dBm. More...
 
void ble_adv_start (void)
 Start advertising based on the parameters set.
 
void ble_adv_stop (void)
 Stop advertising.
 
void ble_adv_set_adv_data (uint8_t len, uint8_t *data_ptr)
 Set the advertising data. More...
 
void ble_adv_set_adv_param (ble_adv_param_t *adv_param)
 Set the advertising parameters to be used. More...
 
void ble_adv_set_random_adrs (uint8_t *rand_adrs)
 Set the random address to be used. More...
 
void ble_adv_set_scan_rsp_data (uint8_t len, uint8_t *data_ptr)
 Set the scan response data. More...
 

The various advertisement formats in an advertisement payload defined

in Generic Access Profile (GAP)

#define GAP_ADV_FLAGS   0x1
 
#define GAP_ADV_UUID16_INCOMP   0x2
 
#define GAP_ADV_UUID16_ALL   0x3
 
#define GAP_ADV_UUID32_INCOMP   0x4
 
#define GAP_ADV_UUID32_ALL   0x5
 
#define GAP_ADV_UUID128_INCOMP   0x6
 
#define GAP_ADV_UUID128_ALL   0x7
 
#define GAP_ADV_NAME_SHORT   0x8
 
#define GAP_ADV_NAME_FULL   0x9
 
#define GAP_ADV_TRANSMIT_PWR   0xA
 
#define GAP_ADV_CONN_INTERVAL   0x12
 
#define GAP_ADV_SERVICE_DATA   0x16
 
#define GAP_ADV_MANUF_DATA   0xFF
 

Detailed Description

Note
This module utilizes the MS_TIMER2 and US_TIMER3, so ms_timer_init and us_timer_init must be called before using this module. Also the radio only works with the high frequency crystal enabled, so hfclk_xtal_init_blocking or hfclk_xtal_init_nonblocking must be used before to enable the it. The radio peripheral uses the highest priority interrupt.

Macro Definition Documentation

◆ ADV_INTERVAL_MS

#define ADV_INTERVAL_MS (   x)    ((x*16)/10)

Conversion from millisecond to multiples of 0.625 ms

Definition at line 62 of file ble_adv.h.

Enumeration Type Documentation

◆ ble_adv_ch_map_t

Enumerator
CH_37_PARAM 

CH_37_PARAM.

CH_38_PARAM 

CH_38_PARAM.

CH_37_38_PARAM 

CH_37_38_PARAM.

CH_39_PARAM 

CH_39_PARAM.

CH_37_39_PARAM 

CH_37_39_PARAM.

CH_38_39_PARAM 

CH_38_39_PARAM.

CH_ALL_PARAM 

CH_ALL_PARAM.

Definition at line 111 of file ble_adv.h.

Function Documentation

◆ ble_adv_get_tx_power()

int8_t ble_adv_get_tx_power ( void  )
Returns
The tx power used

Definition at line 225 of file ble_adv.c.

◆ ble_adv_set_adv_data()

void ble_adv_set_adv_data ( uint8_t  len,
uint8_t *  data_ptr 
)
Parameters
lenLength of the advertising data
data_ptrPointer to the buffer containing the data_ptr

Definition at line 246 of file ble_adv.c.

References ADRS_LEN.

◆ ble_adv_set_adv_param()

void ble_adv_set_adv_param ( ble_adv_param_t adv_param)
Parameters
adv_paramPointer to the structure containing the parameters

Definition at line 202 of file ble_adv.c.

References ble_adv_param_t::adv_type.

◆ ble_adv_set_random_adrs()

void ble_adv_set_random_adrs ( uint8_t *  rand_adrs)
Parameters
rand_adrsPointer to the buffer containing the random address containing ADRS_LEN number of octets

Definition at line 242 of file ble_adv.c.

References ADRS_LEN.

◆ ble_adv_set_scan_rsp_data()

void ble_adv_set_scan_rsp_data ( uint8_t  len,
uint8_t *  data_ptr 
)
Parameters
lenLength of the scan response data
data_ptrPointer to the buffer containing the data_ptr

Definition at line 251 of file ble_adv.c.

References ADRS_LEN.

◆ ble_adv_set_tx_power()

void ble_adv_set_tx_power ( int8_t  pwr)
Parameters
pwrThe tx power ranging from -40 to 4

Definition at line 229 of file ble_adv.c.