diff --git a/components/bt/bluedroid/api/include/esp_gap_ble_api.h b/components/bt/bluedroid/api/include/esp_gap_ble_api.h index 8b5882d270..3456008bb6 100644 --- a/components/bt/bluedroid/api/include/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/esp_gap_ble_api.h @@ -273,6 +273,8 @@ typedef union { uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX + ESP_BLE_SCAN_RSP_DATA_LEN_MAX]; /*!< Received EIR */ int flag; /*!< Advertising data flag bit */ int num_resps; /*!< Scan result number */ + uint8_t adv_data_len; /*!< Adv data length */ + uint8_t scan_rsp_len; /*!< Scan response length */ } scan_rst; /*!< Event parameter of ESP_GAP_BLE_SCAN_RESULT_EVT */ /** * @brief ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index 8ebd3a8f31..40b0347797 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -4028,7 +4028,6 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data) *******************************************************************************/ static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir) { - ; tBTA_DM_SEARCH result; tBTM_INQ_INFO *p_inq_info; APPL_TRACE_DEBUG("bta_dm_observe_results_cb") @@ -4039,6 +4038,8 @@ static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir) result.inq_res.inq_result_type = p_inq->inq_result_type; result.inq_res.device_type = p_inq->device_type; result.inq_res.flag = p_inq->flag; + result.inq_res.adv_data_len = p_inq->adv_data_len; + result.inq_res.scan_rsp_len = p_inq->scan_rsp_len; /* application will parse EIR to find out remote device name */ result.inq_res.p_eir = p_eir; diff --git a/components/bt/bluedroid/bta/include/bta_api.h b/components/bt/bluedroid/bta/include/bta_api.h index 8e4b927aa4..241b32eebd 100644 --- a/components/bt/bluedroid/bta/include/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta_api.h @@ -1003,6 +1003,8 @@ typedef struct { tBTM_BLE_EVT_TYPE ble_evt_type; tBT_DEVICE_TYPE device_type; UINT8 flag; + UINT8 adv_data_len; + UINT8 scan_rsp_len; #endif } tBTA_DM_INQ_RES; diff --git a/components/bt/bluedroid/btc/core/btc_task.c b/components/bt/bluedroid/btc/core/btc_task.c index a245f54d28..0ca5c9a42b 100644 --- a/components/bt/bluedroid/btc/core/btc_task.c +++ b/components/bt/bluedroid/btc/core/btc_task.c @@ -101,10 +101,10 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg memcpy(&lmsg, msg, sizeof(btc_msg_t)); if (arg) { lmsg.arg = (void *)GKI_getbuf(arg_len); - memset(lmsg.arg, 0x00, arg_len); //important, avoid arg which have no length if (lmsg.arg == NULL) { return BT_STATUS_NOMEM; } + memset(lmsg.arg, 0x00, arg_len); //important, avoid arg which have no length memcpy(lmsg.arg, arg, arg_len); if (copy_func) { copy_func(&lmsg, lmsg.arg, arg); diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 9e158c592e..fd20d35767 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -476,6 +476,9 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data param.scan_rst.ble_addr_type = p_data->inq_res.ble_addr_type; param.scan_rst.ble_evt_type = p_data->inq_res.ble_evt_type; param.scan_rst.flag = p_data->inq_res.flag; + param.scan_rst.num_resps = 1; + param.scan_rst.adv_data_len = p_data->inq_res.adv_data_len; + param.scan_rst.scan_rsp_len = p_data->inq_res.scan_rsp_len; memcpy(param.scan_rst.ble_adv, p_data->inq_res.p_eir, sizeof(param.scan_rst.ble_adv)); break; } @@ -530,7 +533,7 @@ 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)) { + if ((results_cb != NULL) && (start_scan_cb != NULL)) { ///Start scan the device BTA_DmBleObserve(true, duration, results_cb, start_scan_cb); } else { diff --git a/components/bt/bluedroid/osi/include/thread.h b/components/bt/bluedroid/osi/include/thread.h index 2b900c72d2..c148cef70c 100644 --- a/components/bt/bluedroid/osi/include/thread.h +++ b/components/bt/bluedroid/osi/include/thread.h @@ -61,7 +61,7 @@ enum { #define BTC_TASK_STACK_SIZE (CONFIG_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) //by menuconfig #define BTC_TASK_NAME "btcT" #define BTC_TASK_PRIO (configMAX_PRIORITIES - 6) -#define BTC_TASK_QUEUE_NUM 20 +#define BTC_TASK_QUEUE_NUM 60 void btu_task_post(uint32_t sig); void hci_host_task_post(void); diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index 07c63b4963..5864419e27 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -1080,7 +1080,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, btm_ble_set_topology_mask(BTM_BLE_STATE_HI_DUTY_DIR_ADV_BIT); }else if(adv_type == BTM_BLE_CONNECT_LO_DUTY_DIR_EVT){ btm_ble_set_topology_mask(BTM_BLE_STATE_LO_DUTY_DIR_ADV_BIT); - }else if(adv_type == BTM_BLE_CONNECT_LO_DUTY_DIR_EVT){ + }else if(adv_type == BTM_BLE_NON_CONNECT_EVT){ btm_ble_set_topology_mask(BTM_BLE_STATE_NON_CONN_ADV_BIT); } @@ -2367,12 +2367,13 @@ void btm_ble_cache_adv_data(tBTM_INQ_RESULTS *p_cur, UINT8 data_len, UINT8 *p, U tBTM_BLE_INQ_CB *p_le_inq_cb = &btm_cb.ble_ctr_cb.inq_var; UINT8 *p_cache; UINT8 length; - UNUSED(p_cur); /* cache adv report/scan response data */ if (evt_type != BTM_BLE_SCAN_RSP_EVT) { p_le_inq_cb->adv_len = 0; memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX); + p_cur->adv_data_len = 0; + p_cur->scan_rsp_len = 0; } if (data_len > 0) { @@ -2391,6 +2392,13 @@ void btm_ble_cache_adv_data(tBTM_INQ_RESULTS *p_cur, UINT8 data_len, UINT8 *p, U } } + if (evt_type != BTM_BLE_SCAN_RSP_EVT) { + p_cur->adv_data_len = p_le_inq_cb->adv_len; + } + else { + p_cur->scan_rsp_len = p_le_inq_cb->adv_len - p_cur->adv_data_len; + } + /* parse service UUID from adv packet and save it in inq db eir_uuid */ /* TODO */ } diff --git a/components/bt/bluedroid/stack/include/btm_api.h b/components/bt/bluedroid/stack/include/btm_api.h index 2d1edcb609..4406217cbf 100644 --- a/components/bt/bluedroid/stack/include/btm_api.h +++ b/components/bt/bluedroid/stack/include/btm_api.h @@ -611,6 +611,8 @@ typedef struct { UINT8 ble_addr_type; tBTM_BLE_EVT_TYPE ble_evt_type; UINT8 flag; + UINT8 adv_data_len; + UINT8 scan_rsp_len; #endif } tBTM_INQ_RESULTS; diff --git a/examples/bluetooth/gatt_client/main/gattc_demo.c b/examples/bluetooth/gatt_client/main/gattc_demo.c index 9985ccdc3b..e531df0991 100644 --- a/examples/bluetooth/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/gatt_client/main/gattc_demo.c @@ -308,6 +308,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par for (int i = 0; i < 6; i++) { ESP_LOGI(GATTC_TAG, "%x:", scan_result->scan_rst.bda[i]); } + ESP_LOGI(GATTC_TAG, "Searched Adv Data Len %d, Scan Response Len %d\n", scan_result->scan_rst.adv_data_len, scan_result->scan_rst.scan_rsp_len); ESP_LOGI(GATTC_TAG, "\n"); adv_name = esp_ble_resolve_adv_data(scan_result->scan_rst.ble_adv, ESP_BLE_AD_TYPE_NAME_CMPL, &adv_name_len);