mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
components/bt: Fix ble sync periodic adv report lost data issue
This commit is contained in:
parent
f173016d86
commit
947d082b44
@ -949,8 +949,10 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
|
||||
case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT:
|
||||
msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT;
|
||||
memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_reprot_t));
|
||||
memcpy(param.ext_adv_report.params.adv_data,
|
||||
params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len);
|
||||
if (params->ext_adv_report.adv_data) {
|
||||
memcpy(param.ext_adv_report.params.adv_data,
|
||||
params->ext_adv_report.adv_data, params->ext_adv_report.adv_data_len);
|
||||
}
|
||||
break;
|
||||
case BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT:
|
||||
msg.act = ESP_GAP_BLE_SCAN_TIMEOUT_EVT;
|
||||
@ -980,8 +982,10 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
|
||||
msg.act = ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT;
|
||||
memcpy(¶m.period_adv_report, ¶ms->period_adv_report,
|
||||
sizeof(esp_ble_gap_periodic_adv_report_t));
|
||||
memcpy(param.period_adv_report.params.data, params->period_adv_report.data,
|
||||
params->period_adv_report.data_length);
|
||||
if (params->period_adv_report.data) {
|
||||
memcpy(param.period_adv_report.params.data, params->period_adv_report.data,
|
||||
params->period_adv_report.data_length);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT: {
|
||||
|
@ -355,7 +355,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
case HCI_BLE_EVENT:
|
||||
STREAM_TO_UINT8 (ble_sub_code, p);
|
||||
|
||||
hci_evt_len--;
|
||||
HCI_TRACE_DEBUG("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
|
||||
|
||||
switch (ble_sub_code) {
|
||||
@ -2208,7 +2208,12 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
|
||||
STREAM_TO_UINT8(ext_adv_report.dir_addr_type, p);
|
||||
STREAM_TO_BDADDR(ext_adv_report.dir_addr, p);
|
||||
STREAM_TO_UINT8(ext_adv_report.adv_data_len, p);
|
||||
ext_adv_report.adv_data = p;
|
||||
if (ext_adv_report.adv_data_len) {
|
||||
ext_adv_report.adv_data = p;
|
||||
} else {
|
||||
ext_adv_report.adv_data = NULL;
|
||||
}
|
||||
|
||||
btm_ble_ext_adv_report_evt(&ext_adv_report);
|
||||
p += ext_adv_report.adv_data_len;
|
||||
}
|
||||
@ -2247,8 +2252,8 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len)
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt_len < sizeof(tBTM_PERIOD_ADV_REPORT)) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params, the adv len is to short.", __func__);
|
||||
if (evt_len < MIN_BLE_PERIODIC_ADV_REPORT_LEN) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params, the adv len is too short.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2259,12 +2264,16 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len)
|
||||
STREAM_TO_UINT8(adv_report.data_status, p);
|
||||
STREAM_TO_UINT8(adv_report.data_length, p);
|
||||
|
||||
if (evt_len <= adv_report.data_length) {
|
||||
if ((evt_len - MIN_BLE_PERIODIC_ADV_REPORT_LEN) != adv_report.data_length) {
|
||||
HCI_TRACE_ERROR("%s, Invalid ev_len = %d is less than adv len = %d", __func__, evt_len, adv_report.data_length);
|
||||
return;
|
||||
}
|
||||
|
||||
adv_report.data = p;
|
||||
if (adv_report.data_length) {
|
||||
adv_report.data = p;
|
||||
} else {
|
||||
adv_report.data = NULL;
|
||||
}
|
||||
|
||||
btm_ble_periodic_adv_report_evt(&adv_report);
|
||||
|
||||
|
@ -702,6 +702,7 @@ typedef void (tBTM_BLE_PF_PARAM_CBACK) (tBTM_BLE_PF_ACTION action_type,
|
||||
tBTM_BLE_REF_VALUE ref_value, tBTM_STATUS status);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#define MAX_BLE_ADV_INSTANCE 10
|
||||
#define MIN_BLE_PERIODIC_ADV_REPORT_LEN 7
|
||||
typedef struct {
|
||||
UINT8 inst_id;
|
||||
BOOLEAN configured;
|
||||
|
Loading…
Reference in New Issue
Block a user