component/bt: fix periodic adv parameters detection issue

This commit is contained in:
xiewenxiang 2021-12-23 17:30:31 +08:00
parent b0133c72a0
commit ab2148a390
2 changed files with 11 additions and 11 deletions

View File

@ -209,7 +209,8 @@ static void parse_ble_read_adv_max_len_response(
{ {
uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_MAX_ADV_DATA_LEN, 1 /* bytes after */); uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_MAX_ADV_DATA_LEN, 1 /* bytes after */);
STREAM_TO_UINT8(*adv_max_len_ptr, stream); // Size: 2 Octets ; Value: 0x001F 0x0672 ; Maximum supported advertising data length
STREAM_TO_UINT16(*adv_max_len_ptr, stream);
osi_free(response); osi_free(response);
} }

View File

@ -689,23 +689,16 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data
{ {
tBTM_STATUS status = BTM_SUCCESS; tBTM_STATUS status = BTM_SUCCESS;
tHCI_STATUS err = HCI_SUCCESS; tHCI_STATUS err = HCI_SUCCESS;
uint16_t rem_len; uint16_t rem_len = len;
UINT8 operation = 0; UINT8 operation = 0;
UINT16 data_offset = 0; UINT16 data_offset = 0;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((status = btm_ble_ext_adv_set_data_validate(instance, len, data)) != BTM_SUCCESS) { if ((status = btm_ble_ext_adv_set_data_validate(instance, len, data)) != BTM_SUCCESS) {
BTM_TRACE_ERROR("%s, invalid extend adv data.", __func__); BTM_TRACE_ERROR("%s, invalid extend adv data.", __func__);
goto end;
} }
if (len > controller_get_interface()->ble_get_ext_adv_data_max_len()) {
BTM_TRACE_ERROR("%s, The adv data len(%d) is longer then the controller adv max len(%d)",
__func__, len, controller_get_interface()->ble_get_ext_adv_data_max_len());
status = BTM_ILLEGAL_VALUE;
}
rem_len = len;
do { do {
UINT8 send_data_len = (rem_len > BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX) ? BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX : rem_len; UINT8 send_data_len = (rem_len > BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX) ? BTM_BLE_PERIODIC_ADV_DATA_LEN_MAX : rem_len;
@ -729,8 +722,8 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data
data_offset += send_data_len; data_offset += send_data_len;
} while(rem_len); } while(rem_len);
end:
cb_params.status = status; cb_params.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT, &cb_params); BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT, &cb_params);
return status; return status;
@ -1108,6 +1101,12 @@ static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len,
BTM_TRACE_ERROR("%s, for the legacy adv, the adv data length can't exceed 31. line %d", __func__, __LINE__); BTM_TRACE_ERROR("%s, for the legacy adv, the adv data length can't exceed 31. line %d", __func__, __LINE__);
return BTM_ILLEGAL_VALUE; return BTM_ILLEGAL_VALUE;
} }
} else {
if (len > controller_get_interface()->ble_get_ext_adv_data_max_len()) {
BTM_TRACE_ERROR("%s, The adv data len(%d) is longer then the controller adv max len(%d)",
__func__, len, controller_get_interface()->ble_get_ext_adv_data_max_len());
return BTM_ILLEGAL_VALUE;
}
} }
return BTM_SUCCESS; return BTM_SUCCESS;