1.目的
如何知道周围有其它蓝牙设备来扫描从机
2.分析
实际应用当中,时常需要需从机主动断开蓝牙,防止不明主机连接的情况
3.平台:
协议栈版本:SDK10.0.0
编译软件:keil 5.14
硬件平台:nrf51822最小系统
例子:SDK 10.0.0\examples\ble_peripheral\ble_app_uart\pca10028\s110\arm4
4.步骤
ble_opt_t ble_opt;
ble_opt.gap_opt.scan_req_report.enable = 1 ;
err_code = sd_ble_opt_set(BLE_GAP_OPT_SCAN_REQ_REPORT,&ble_opt);
APP_ERROR_CHECK(err_code);
void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code = NRF_SUCCESS;
uint8_t disconnected_reason = p_ble_evt->evt.gap_evt.params.disconnected.reason;
switch (p_ble_evt->header.evt_id)
{ //添加的代码
case BLE_GAP_EVT_SCAN_REQ_REPORT :
{
printf("scan request report \r\n");
}
break;