bluedroid: fix ble adv data construct for device name

This commit is contained in:
chenjianhua 2023-05-06 14:26:16 +08:00
parent dfe7cffd09
commit 747daffc28

View File

@ -2169,9 +2169,10 @@ UINT8 *btm_ble_build_adv_data(tBTM_BLE_AD_MASK *p_data_mask, UINT8 **p_dst,
#if BTM_MAX_LOC_BD_NAME_LEN > 0 #if BTM_MAX_LOC_BD_NAME_LEN > 0
if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) { if (len > MIN_ADV_LENGTH && data_mask & BTM_BLE_AD_BIT_DEV_NAME) {
if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) { if (strlen(btm_cb.cfg.bd_name) > (UINT16)(len - MIN_ADV_LENGTH)) {
*p++ = len - MIN_ADV_LENGTH + 1; cp_len = (UINT16)(len - MIN_ADV_LENGTH);
*p++ = cp_len + 1;
*p++ = BTM_BLE_AD_TYPE_NAME_SHORT; *p++ = BTM_BLE_AD_TYPE_NAME_SHORT;
ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, len - MIN_ADV_LENGTH); ARRAY_TO_STREAM(p, btm_cb.cfg.bd_name, cp_len);
} else { } else {
cp_len = (UINT16)strlen(btm_cb.cfg.bd_name); cp_len = (UINT16)strlen(btm_cb.cfg.bd_name);
*p++ = cp_len + 1; *p++ = cp_len + 1;