广播就是为了让别人能发现你。
记得初始化完毕还要在协议栈初始化通过ble_evt_dispatch分发事件,on_adv_evt()处理。
ble_advertising.h涉及的函数
协议栈广播派发事件 : void ble_advertising_on_ble_evt(const ble_evt_t * const p_ble_evt);
系统事件 : void ble_advertising_on_sys_evt(uint32_t sys_evt);
广播初始化
uint32_t ble_advertising_init(ble_advdata_t const * p_advdata,
ble_advdata_t const * p_srdata,
ble_adv_modes_config_t const * p_config,
ble_advertising_evt_handler_t const evt_handler,
ble_advertising_error_handler_t const error_handler);
开始广播 : uint32_t ble_advertising_start(ble_adv_mode_t advertising_mode);
设置配对地址 : uint32_t ble_advertising_peer_addr_reply(ble_gap_addr_t *p_peer_addr);
设置白名单 : uint32_t ble_advertising_whitelist_reply(ble_gap_whitelist_t *p_whitelist);
禁止白名单广告 : uint32_t ble_advertising_restart_without_whitelist(void);
-----------------------------------------------------------------------------------------------------------------------------------广播模式处理函数:on_adv_evt(ble_adv_evt_t ble_adv_evt)
typedef enum
{
BLE_ADV_EVT_IDLE, /**< Idle; no connectableadvertising is ongoing.*/
BLE_ADV_EVT_DIRECTED, //定向广播,只能被指定的设备连接
BLE_ADV_EVT_DIRECTED_SLOW,
BLE_ADV_EVT_FAST,//快速广播
BLE_ADV_EVT_SLOW,
BLE_ADV