mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
bt component: optimize scan feature
1. Add advertising data length and scan response length in scan result 2. Add scan continuously feature 3. Fix non connectable adv topology error 4. Increase BTC queue size
This commit is contained in:
parent
375b28650b
commit
a4f3312d9d
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user