feat(ble/bluedroid): Allow add vendor descriptor by service table create API

(cherry picked from commit 8207bd11e7)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
Zhi Wei Jian
2026-03-26 17:23:54 +08:00
parent cb66025dbb
commit 24e375dc10
@@ -247,7 +247,14 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
//set the attribute table create service flag to true //set the attribute table create service flag to true
btc_creat_tab_env.is_tab_creat_svc = true; btc_creat_tab_env.is_tab_creat_svc = true;
btc_creat_tab_env.num_handle = max_nb_attr; btc_creat_tab_env.num_handle = max_nb_attr;
/* After CHAR_DECLARE, the next row is the characteristic value (any UUID length); skip it here so
* a 16-bit characteristic UUID is not mistaken for a descriptor. */
bool skip_next_attr_row = false;
for(int i = 0; i < max_nb_attr; i++){ for(int i = 0; i < max_nb_attr; i++){
if (skip_next_attr_row) {
skip_next_attr_row = false;
continue;
}
if(gatts_attr_db[i].att_desc.uuid_length == ESP_UUID_LEN_16){ if(gatts_attr_db[i].att_desc.uuid_length == ESP_UUID_LEN_16){
uuid = (gatts_attr_db[i].att_desc.uuid_p[1] << 8) + (gatts_attr_db[i].att_desc.uuid_p[0]); uuid = (gatts_attr_db[i].att_desc.uuid_p[1] << 8) + (gatts_attr_db[i].att_desc.uuid_p[0]);
} }
@@ -363,6 +370,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
BTC_TRACE_ERROR("%s failed\n", __func__); BTC_TRACE_ERROR("%s failed\n", __func__);
return; return;
} }
skip_next_attr_row = true;
} }
} }
@@ -382,7 +390,8 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
case ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR: case ESP_GATT_UUID_ENV_SENSING_CONFIG_DESCR:
case ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR: case ESP_GATT_UUID_ENV_SENSING_MEASUREMENT_DESCR:
case ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR: case ESP_GATT_UUID_ENV_SENSING_TRIGGER_DESCR:
case ESP_GATT_UUID_TIME_TRIGGER_DESCR: { case ESP_GATT_UUID_TIME_TRIGGER_DESCR:
default: {
uint16_t svc_hal = btc_creat_tab_env.svc_start_hdl; uint16_t svc_hal = btc_creat_tab_env.svc_start_hdl;
tBT_UUID bta_char_uuid; tBT_UUID bta_char_uuid;
esp_bt_uuid_t uuid_temp; esp_bt_uuid_t uuid_temp;
@@ -407,9 +416,6 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
} }
break; break;
} }
default:
future_free(future_p);
break;
} }