Merge branch 'bugfix/btdm_adv_scan_enable_report' into 'master'

component/bt : add adv/scan start complete event

1. indicate adv/scan start complete success or failed
2. controller do limit of adv/scan concurrence, so add some codes to report adv/scan start failed or not.

See merge request !524
This commit is contained in:
Jiang Jiang Jian 2017-02-24 16:24:22 +08:00
commit 63e0140ae6
11 changed files with 149 additions and 33 deletions

View File

@ -46,6 +46,8 @@ typedef enum {
ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */ ESP_GAP_BLE_SCAN_RESULT_EVT, /*!< When one scan result ready, the event comes each time */
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */ ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */ ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, /*!< When raw advertising data set complete, the event comes */
ESP_GAP_BLE_ADV_START_COMPLETE_EVT, /*!< When start advertising complete, the event comes */
ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, /*!< When start scan complete, the event comes */
} esp_gap_ble_cb_event_t; } esp_gap_ble_cb_event_t;
/// Advertising data maximum length /// Advertising data maximum length
@ -284,6 +286,18 @@ typedef union {
struct ble_scan_rsp_data_raw_cmpl_evt_param { struct ble_scan_rsp_data_raw_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */ esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
} scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */ } scan_rsp_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_ADV_START_COMPLETE_EVT
*/
struct ble_adv_start_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate advertising start operation success status */
} adv_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_START_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SCAN_START_COMPLETE_EVT
*/
struct ble_scan_start_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate scan start operation success status */
} scan_start_cmpl; /*!< Event parameter of ESP_GAP_BLE_SCAN_START_COMPLETE_EVT */
} esp_ble_gap_cb_param_t; } esp_ble_gap_cb_param_t;
/** /**

View File

@ -4534,12 +4534,11 @@ void bta_dm_ble_observe (tBTA_DM_MSG *p_data)
bta_dm_search_cb.p_scan_cback = p_data->ble_observe.p_cback; bta_dm_search_cb.p_scan_cback = p_data->ble_observe.p_cback;
if ((status = BTM_BleObserve(TRUE, p_data->ble_observe.duration, if ((status = BTM_BleObserve(TRUE, p_data->ble_observe.duration,
bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) { bta_dm_observe_results_cb, bta_dm_observe_cmpl_cb)) != BTM_CMD_STARTED) {
tBTA_DM_SEARCH data;
APPL_TRACE_WARNING(" %s BTM_BleObserve failed. status %d\n", __FUNCTION__, status); APPL_TRACE_WARNING(" %s BTM_BleObserve failed. status %d\n", __FUNCTION__, status);
data.inq_cmpl.num_resps = 0; }
if (bta_dm_search_cb.p_scan_cback) { if (p_data->ble_observe.p_start_scan_cback) {
bta_dm_search_cb.p_scan_cback(BTA_DM_INQ_CMPL_EVT, &data); status = (status == BTM_CMD_STARTED ? BTA_SUCCESS : BTA_FAILURE);
} p_data->ble_observe.p_start_scan_cback(status);
} }
} else { } else {
bta_dm_search_cb.p_scan_cback = NULL; bta_dm_search_cb.p_scan_cback = NULL;
@ -4576,13 +4575,21 @@ void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data)
*******************************************************************************/ *******************************************************************************/
void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data) void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data)
{ {
BTM_BleSetAdvParamsStartAdv(p_data->ble_set_adv_params_all.adv_int_min, tBTA_STATUS status = BTA_FAILURE;
if (BTM_BleSetAdvParamsStartAdv(p_data->ble_set_adv_params_all.adv_int_min,
p_data->ble_set_adv_params_all.adv_int_max, p_data->ble_set_adv_params_all.adv_int_max,
p_data->ble_set_adv_params_all.adv_type, p_data->ble_set_adv_params_all.adv_type,
p_data->ble_set_adv_params_all.addr_type_own, p_data->ble_set_adv_params_all.addr_type_own,
p_data->ble_set_adv_params_all.p_dir_bda, p_data->ble_set_adv_params_all.p_dir_bda,
p_data->ble_set_adv_params_all.channel_map, p_data->ble_set_adv_params_all.channel_map,
p_data->ble_set_adv_params_all.adv_filter_policy); p_data->ble_set_adv_params_all.adv_filter_policy) == BTM_SUCCESS) {
status = BTA_SUCCESS;
}
if (p_data->ble_set_adv_params_all.p_start_adv_cback) {
(*p_data->ble_set_adv_params_all.p_start_adv_cback)(status);
}
} }
/******************************************************************************* /*******************************************************************************

View File

@ -1009,7 +1009,7 @@ void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own, UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol, tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
tBLE_BD_ADDR *p_dir_bda) tBLE_BD_ADDR *p_dir_bda, tBTA_START_ADV_CMPL_CBACK p_start_adv_cb)
{ {
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
tBTA_DM_API_BLE_ADV_PARAMS_ALL *p_msg; tBTA_DM_API_BLE_ADV_PARAMS_ALL *p_msg;
@ -1029,6 +1029,7 @@ void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
p_msg->addr_type_own = addr_type_own; p_msg->addr_type_own = addr_type_own;
p_msg->channel_map = chnl_map; p_msg->channel_map = chnl_map;
p_msg->adv_filter_policy = adv_fil_pol; p_msg->adv_filter_policy = adv_fil_pol;
p_msg->p_start_adv_cback = p_start_adv_cb;
if (p_dir_bda != NULL) { if (p_dir_bda != NULL) {
p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1); p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1);
memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR)); memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
@ -2127,7 +2128,8 @@ void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transpor
** **
*******************************************************************************/ *******************************************************************************/
extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration, extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb) tBTA_DM_SEARCH_CBACK *p_results_cb,
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cb)
{ {
tBTA_DM_API_BLE_OBSERVE *p_msg; tBTA_DM_API_BLE_OBSERVE *p_msg;
@ -2140,6 +2142,7 @@ extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
p_msg->start = start; p_msg->start = start;
p_msg->duration = duration; p_msg->duration = duration;
p_msg->p_cback = p_results_cb; p_msg->p_cback = p_results_cb;
p_msg->p_start_scan_cback = p_start_scan_cb;
bta_sys_sendmsg(p_msg); bta_sys_sendmsg(p_msg);
} }

View File

@ -471,7 +471,8 @@ typedef struct {
BT_HDR hdr; BT_HDR hdr;
BOOLEAN start; BOOLEAN start;
UINT16 duration; UINT16 duration;
tBTA_DM_SEARCH_CBACK *p_cback; tBTA_DM_SEARCH_CBACK *p_cback;
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cback;
} tBTA_DM_API_BLE_OBSERVE; } tBTA_DM_API_BLE_OBSERVE;
typedef struct { typedef struct {
@ -506,6 +507,7 @@ typedef struct {
tBTM_BLE_ADV_CHNL_MAP channel_map; tBTM_BLE_ADV_CHNL_MAP channel_map;
tBTM_BLE_AFP adv_filter_policy; tBTM_BLE_AFP adv_filter_policy;
tBLE_BD_ADDR *p_dir_bda; tBLE_BD_ADDR *p_dir_bda;
tBTA_START_ADV_CMPL_CBACK *p_start_adv_cback;
} tBTA_DM_API_BLE_ADV_PARAMS_ALL; } tBTA_DM_API_BLE_ADV_PARAMS_ALL;

View File

@ -400,6 +400,8 @@ typedef struct {
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status); typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
/* advertising channel map */ /* advertising channel map */
#define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37 #define BTA_BLE_ADV_CHNL_37 BTM_BLE_ADV_CHNL_37
#define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38 #define BTA_BLE_ADV_CHNL_38 BTM_BLE_ADV_CHNL_38
@ -1095,6 +1097,8 @@ typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt,
tBTA_DM_BLE_REF_VALUE ref_value, tBTA_DM_BLE_REF_VALUE ref_value,
tBTA_STATUS status); tBTA_STATUS status);
typedef void (tBTA_START_SCAN_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status, typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status,
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
tBTA_DM_BLE_REF_VALUE ref_value); tBTA_DM_BLE_REF_VALUE ref_value);
@ -1891,7 +1895,7 @@ extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own, UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol, tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
tBLE_BD_ADDR *p_dir_bda); tBLE_BD_ADDR *p_dir_bda, tBTA_START_ADV_CMPL_CBACK p_start_adv_cb);
/******************************************************************************* /*******************************************************************************
@ -1997,7 +2001,8 @@ extern void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport,
** **
*******************************************************************************/ *******************************************************************************/
extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration, extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration,
tBTA_DM_SEARCH_CBACK *p_results_cb); tBTA_DM_SEARCH_CBACK *p_results_cb,
tBTA_START_SCAN_CMPL_CBACK *p_start_scan_cb);
extern void BTA_DmBleStopAdvertising(void); extern void BTA_DmBleStopAdvertising(void);

View File

@ -367,7 +367,26 @@ static void btc_ble_set_scan_rsp_data_raw(uint8_t *raw_scan_rsp, uint32_t raw_sc
BTA_DmBleSetScanRspRaw(raw_scan_rsp, raw_scan_rsp_len, p_scan_rsp_data_cback); BTA_DmBleSetScanRspRaw(raw_scan_rsp, raw_scan_rsp_len, p_scan_rsp_data_cback);
} }
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params) static void btc_start_adv_callback(tBTA_STATUS status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_START_COMPLETE_EVT;
param.adv_start_cmpl.status = status;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBTA_START_ADV_CMPL_CBACK start_adv_cback)
{ {
tBLE_BD_ADDR peer_addr; tBLE_BD_ADDR peer_addr;
@ -398,7 +417,8 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params)
ble_adv_params->own_addr_type, ble_adv_params->own_addr_type,
ble_adv_params->channel_map, ble_adv_params->channel_map,
ble_adv_params->adv_filter_policy, ble_adv_params->adv_filter_policy,
&peer_addr); &peer_addr,
start_adv_cback);
} }
@ -487,12 +507,33 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL); btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL);
} }
static void btc_start_scan_callback(tBTA_STATUS status)
static void btc_ble_start_scanning(uint8_t duration, tBTA_DM_SEARCH_CBACK *results_cb)
{ {
if ((duration != 0) && (results_cb != NULL)) { esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SCAN_START_COMPLETE_EVT;
param.scan_start_cmpl.status = status;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_start_scanning(uint8_t duration,
tBTA_DM_SEARCH_CBACK *results_cb,
tBTA_START_SCAN_CMPL_CBACK *start_scan_cb)
{
if ((duration != 0) && (results_cb != NULL) && (start_scan_cb != NULL)) {
///Start scan the device ///Start scan the device
BTA_DmBleObserve(true, duration, results_cb); BTA_DmBleObserve(true, duration, results_cb, start_scan_cb);
} else { } else {
LOG_ERROR("The scan duration or p_results_cb invalid\n"); LOG_ERROR("The scan duration or p_results_cb invalid\n");
} }
@ -501,7 +542,7 @@ static void btc_ble_start_scanning(uint8_t duration, tBTA_DM_SEARCH_CBACK *resul
static void btc_ble_stop_scanning(void) static void btc_ble_stop_scanning(void)
{ {
uint8_t duration = 0; uint8_t duration = 0;
BTA_DmBleObserve(false, duration, NULL); BTA_DmBleObserve(false, duration, NULL, NULL);
} }
@ -576,6 +617,12 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg)
case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT: case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, param); btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT, param);
break; break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_ADV_START_COMPLETE_EVT, param);
break;
case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT:
btc_gap_ble_cb_to_app(ESP_GAP_BLE_SCAN_START_COMPLETE_EVT, param);
break;
default: default:
break; break;
@ -695,13 +742,13 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
btc_ble_set_scan_params(&arg->set_scan_param.scan_params, btc_scan_params_callback); btc_ble_set_scan_params(&arg->set_scan_param.scan_params, btc_scan_params_callback);
break; break;
case BTC_GAP_BLE_ACT_START_SCAN: case BTC_GAP_BLE_ACT_START_SCAN:
btc_ble_start_scanning(arg->start_scan.duration, btc_search_callback); btc_ble_start_scanning(arg->start_scan.duration, btc_search_callback, btc_start_scan_callback);
break; break;
case BTC_GAP_BLE_ACT_STOP_SCAN: case BTC_GAP_BLE_ACT_STOP_SCAN:
btc_ble_stop_scanning(); btc_ble_stop_scanning();
break; break;
case BTC_GAP_BLE_ACT_START_ADV: case BTC_GAP_BLE_ACT_START_ADV:
btc_ble_start_advertising(&arg->start_adv.adv_params); btc_ble_start_advertising(&arg->start_adv.adv_params, btc_start_adv_callback);
break; break;
case BTC_GAP_BLE_ACT_STOP_ADV: case BTC_GAP_BLE_ACT_STOP_ADV:
btc_ble_stop_advertising(); btc_ble_stop_advertising();

View File

@ -2935,14 +2935,18 @@ tBTM_STATUS btm_ble_start_scan(void)
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var; tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS status = BTM_CMD_STARTED; tBTM_STATUS status = BTM_CMD_STARTED;
/* start scan, disable duplicate filtering */ if (p_inq->adv_mode != BTM_BLE_ADV_DISABLE) {
if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
status = BTM_NO_RESOURCES; status = BTM_NO_RESOURCES;
} else { } else {
if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) { /* start scan, disable duplicate filtering */
btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT); if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
status = BTM_NO_RESOURCES;
} else { } else {
btm_ble_set_topology_mask(BTM_BLE_STATE_PASSIVE_SCAN_BIT); if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) {
btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT);
} else {
btm_ble_set_topology_mask(BTM_BLE_STATE_PASSIVE_SCAN_BIT);
}
} }
} }
return status; return status;
@ -2961,15 +2965,17 @@ void btm_ble_stop_scan(void)
{ {
BTM_TRACE_EVENT ("btm_ble_stop_scan "); BTM_TRACE_EVENT ("btm_ble_stop_scan ");
/* Clear the inquiry callback if set */ if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_DISABLE) {
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE; /* Clear the inquiry callback if set */
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
/* stop discovery now */ /* stop discovery now */
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE); btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
btm_update_scanner_filter_policy(SP_ADV_ALL); btm_update_scanner_filter_policy(SP_ADV_ALL);
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_SCAN; btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_SCAN;
}
} }
/******************************************************************************* /*******************************************************************************
** **
@ -3089,9 +3095,15 @@ static BOOLEAN btm_ble_adv_states_operation(BTM_TOPOLOGY_FUNC_PTR *p_handler, UI
*******************************************************************************/ *******************************************************************************/
tBTM_STATUS btm_ble_start_adv(void) tBTM_STATUS btm_ble_start_adv(void)
{ {
tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb;
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS rt = BTM_NO_RESOURCES; tBTM_STATUS rt = BTM_NO_RESOURCES;
BTM_TRACE_EVENT ("btm_ble_start_adv\n"); BTM_TRACE_EVENT ("btm_ble_start_adv\n");
if (BTM_BLE_IS_OBS_ACTIVE(p_ble_cb->scan_activity)) {
return BTM_NO_RESOURCES;
}
if (!btm_ble_adv_states_operation (btm_ble_topology_check, p_cb->evt_type)) { if (!btm_ble_adv_states_operation (btm_ble_topology_check, p_cb->evt_type)) {
return BTM_WRONG_MODE; return BTM_WRONG_MODE;
} }
@ -3133,10 +3145,12 @@ tBTM_STATUS btm_ble_start_adv(void)
*******************************************************************************/ *******************************************************************************/
tBTM_STATUS btm_ble_stop_adv(void) tBTM_STATUS btm_ble_stop_adv(void)
{ {
tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb;
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS rt = BTM_SUCCESS; tBTM_STATUS rt = BTM_SUCCESS;
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE
&& !BTM_BLE_IS_OBS_ACTIVE(p_ble_cb->scan_activity)) {
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) { if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
p_cb->fast_adv_on = FALSE; p_cb->fast_adv_on = FALSE;
p_cb->adv_mode = BTM_BLE_ADV_DISABLE; p_cb->adv_mode = BTM_BLE_ADV_DISABLE;

View File

@ -93,6 +93,12 @@ Structures
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_scan_rsp_data_raw_cmpl_evt_param .. doxygenstruct:: esp_ble_gap_cb_param_t::ble_scan_rsp_data_raw_cmpl_evt_param
:members: :members:
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_adv_start_cmpl_evt_param
:members:
.. doxygenstruct:: esp_ble_gap_cb_param_t::ble_scan_start_cmpl_evt_param
:members:
Functions Functions
^^^^^^^^^ ^^^^^^^^^

View File

@ -295,6 +295,12 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par
esp_ble_gap_start_scanning(duration); esp_ble_gap_start_scanning(duration);
break; break;
} }
case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT:
//scan start complete event to indicate scan start successfully or failed
if (param->scan_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(GATTC_TAG, "Scan start failed\n");
}
break;
case ESP_GAP_BLE_SCAN_RESULT_EVT: { case ESP_GAP_BLE_SCAN_RESULT_EVT: {
esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param; esp_ble_gap_cb_param_t *scan_result = (esp_ble_gap_cb_param_t *)param;
switch (scan_result->scan_rst.search_evt) { switch (scan_result->scan_rst.search_evt) {

View File

@ -151,6 +151,12 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT: case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
esp_ble_gap_start_advertising(&test_adv_params); esp_ble_gap_start_advertising(&test_adv_params);
break; break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
//advertising start complete event to indicate advertising start successfully or failed
if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(GATTS_TAG, "Advertising start failed\n");
}
break;
default: default:
break; break;
} }

View File

@ -203,6 +203,12 @@ static void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param
case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT: case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
esp_ble_gap_start_advertising(&heart_rate_adv_params); esp_ble_gap_start_advertising(&heart_rate_adv_params);
break; break;
case ESP_GAP_BLE_ADV_START_COMPLETE_EVT:
//advertising start complete event to indicate advertising start successfully or failed
if (param->adv_start_cmpl.status != ESP_BT_STATUS_SUCCESS) {
ESP_LOGE(GATTS_TABLE_TAG, "Advertising start failed\n");
}
break;
default: default:
break; break;
} }