mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(bt): Fix ble periodic advertising data length 0 error
- Fixed issues about data length 0 when set ext adv data,ext scan rsp data and periodic adv data
This commit is contained in:
parent
b4b4306677
commit
0e9974a918
@ -2804,7 +2804,7 @@ void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16
|
||||
p_msg->is_scan_rsp = is_scan_rsp;
|
||||
p_msg->instance = instance;
|
||||
p_msg->length = length;
|
||||
p_msg->data = (UINT8 *)(p_msg + 1);
|
||||
p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL;
|
||||
if (data) {
|
||||
memcpy(p_msg->data, data, length);
|
||||
}
|
||||
@ -2894,6 +2894,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length,
|
||||
p_msg->length = length;
|
||||
p_msg->data = (UINT8 *)(p_msg + 1);
|
||||
memcpy(p_msg->data, data, length);
|
||||
p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL;
|
||||
//start sent the msg to the bta system control moudle
|
||||
bta_sys_sendmsg(p_msg);
|
||||
} else {
|
||||
|
@ -1082,7 +1082,7 @@ static tBTM_STATUS btm_ble_ext_adv_params_validate(tBTM_BLE_GAP_EXT_ADV_PARAMS *
|
||||
|
||||
static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len, UINT8 *data)
|
||||
{
|
||||
if (!data) {
|
||||
if (data == NULL && len > 0) {
|
||||
BTM_TRACE_ERROR("%s, the extend adv data is NULL. line %d", __func__, __LINE__);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
@ -1273,17 +1273,16 @@ UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
|
||||
UINT8_TO_STREAM(pp, operation);
|
||||
UINT8_TO_STREAM(pp, fragment_prefrence);
|
||||
|
||||
if (p_data != NULL && data_len > 0) {
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
|
||||
ARRAY_TO_STREAM (pp, p_data, data_len);
|
||||
} else {
|
||||
return FALSE;
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
|
||||
if (p_data != NULL && data_len > 0){
|
||||
ARRAY_TO_STREAM (pp, p_data, data_len);
|
||||
}
|
||||
|
||||
uint8_t status = btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return status;
|
||||
|
||||
@ -1309,16 +1308,13 @@ UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
|
||||
|
||||
memset(pp, 0, data_len);
|
||||
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
if (p_data != NULL && data_len > 0) {
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
|
||||
ARRAY_TO_STREAM (pp, p_data, data_len);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
@ -1455,16 +1451,14 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
|
||||
|
||||
//memset(pp, 0, len);
|
||||
|
||||
if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
|
||||
len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, len);
|
||||
|
||||
if (p_data != NULL && len > 0) {
|
||||
if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
|
||||
len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, len);
|
||||
|
||||
ARRAY_TO_STREAM (pp, p_data, len);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
|
Loading…
Reference in New Issue
Block a user