feat(ble/bluedroid): add LE UTP host support (Core 6.2)

(cherry picked from commit 3844e24207)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
Zhi Wei Jian
2026-06-26 09:08:26 +08:00
parent 28c67947f4
commit c7fc14a076
18 changed files with 423 additions and 8 deletions
@@ -1713,6 +1713,58 @@ void btm_ble_read_min_supp_conn_interval_complete(UINT8 *p)
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
tBTM_STATUS BTM_BleEnableUtpOtaMode(UINT8 enable)
{
tHCI_STATUS err;
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_enable_utp_ota_mode(enable)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("LE EnableUtpOtaMode: cmd err=0x%x", err);
status = BTM_HCI_ERROR | err;
}
cb_params.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_ENABLE_UTP_OTA_MODE_COMPLETE_EVT, &cb_params);
return status;
}
tBTM_STATUS BTM_BleUtpSend(UINT8 data_len, const UINT8 *p_data)
{
tHCI_STATUS err;
tBTM_STATUS status = BTM_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_utp_send(data_len, p_data)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("LE UtpSend: cmd err=0x%x", err);
status = BTM_HCI_ERROR | err;
}
cb_params.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_UTP_SEND_COMPLETE_EVT, &cb_params);
return status;
}
void btm_ble_utp_receive_evt(UINT8 *p, UINT16 len)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
UINT8 data_len;
if (!p || len < 1) {
return;
}
STREAM_TO_UINT8(data_len, p);
if (data_len == 0 || len < (UINT16)(1 + data_len)) {
return;
}
cb_params.utp_receive.len = data_len;
cb_params.utp_receive.data = p;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_UTP_RECEIVE_EVT, &cb_params);
}
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BLE_50_EXTEND_ADV_EN == TRUE)
void btm_ble_scan_req_received_evt(tBTM_BLE_SCAN_REQ_RECEIVED *params)
@@ -610,6 +610,9 @@ void btm_ble_read_all_remote_features_complete_evt(UINT8 *p);
void btm_ble_conn_rate_change_evt(tBTM_BLE_CONN_RATE_CHANGE *params);
void btm_ble_read_min_supp_conn_interval_complete(UINT8 *p);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
void btm_ble_utp_receive_evt(UINT8 *p, UINT16 len);
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
void btm_ble_pa_subevt_data_req_evt(tBTM_BLE_PA_SUBEVT_DATA_REQ_EVT *params);
void btm_ble_pa_rsp_rpt_evt(tBTM_BLE_PA_RSP_REPORT_EVT *params);
@@ -3186,6 +3186,48 @@ UINT8 btsnd_hcic_ble_read_all_remote_features(UINT16 conn_handle, UINT8 page_req
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
UINT8 btsnd_hcic_ble_enable_utp_ota_mode(UINT8 enable)
{
BT_HDR *p;
UINT8 *pp;
if (enable > 1) {
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ENABLE_UTP_OTA_MODE);
UINT16_TO_STREAM(pp, HCI_BLE_ENABLE_UTP_OTA_MODE);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ENABLE_UTP_OTA_MODE);
UINT8_TO_STREAM(pp, enable);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
UINT8 btsnd_hcic_ble_utp_send(UINT8 data_len, const UINT8 *p_data)
{
BT_HDR *p;
UINT8 *pp;
UINT16 param_len;
if (data_len == 0 || data_len > BLE_UTP_DATA_MAX_LEN || p_data == NULL) {
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}
param_len = HCIC_PARAM_SIZE_UTP_SEND_HDR + data_len;
if (param_len > HCIC_PARAM_SIZE_UTP_SEND_MAX) {
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}
HCIC_BLE_CMD_CREATED_U8(p, pp, param_len);
UINT16_TO_STREAM(pp, HCI_BLE_UTP_SEND);
UINT8_TO_STREAM(pp, param_len);
UINT8_TO_STREAM(pp, data_len);
ARRAY_TO_STREAM(pp, p_data, data_len);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
UINT8 btsnd_hcic_ble_connection_rate_request(UINT16 conn_handle, UINT16 conn_interval_min,
@@ -1007,6 +1007,11 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st
#define BTM_BLE_5_GAP_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT 86
#define BTM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT 87
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
#define BTM_BLE_5_GAP_ENABLE_UTP_OTA_MODE_COMPLETE_EVT 83
#define BTM_BLE_5_GAP_UTP_SEND_COMPLETE_EVT 84
#define BTM_BLE_5_GAP_UTP_RECEIVE_EVT 85
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#define BTM_BLE_5_GAP_UNKNOWN_EVT 91
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
@@ -1320,6 +1325,12 @@ typedef struct {
} tBTM_BLE_READ_MIN_SUPP_CONN_INTERVAL;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
typedef struct {
UINT8 len;
UINT8 *data;
} tBTM_BLE_UTP_RECEIVE;
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
typedef struct {
UINT16 sync_handle;
@@ -2043,6 +2054,9 @@ typedef union {
tBTM_BLE_CONN_RATE_CHANGE conn_rate_change;
tBTM_BLE_READ_MIN_SUPP_CONN_INTERVAL read_min_supp_conn_interval;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
tBTM_BLE_UTP_RECEIVE utp_receive;
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
} tBTM_BLE_5_GAP_CB_PARAMS;
typedef struct {
@@ -3234,6 +3248,10 @@ void BTM_BleSetDefaultRateParameters(UINT16 conn_interval_min, UINT16 conn_inter
tBTM_STATUS BTM_BleReadMinSuppConnInterval(void);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
tBTM_STATUS BTM_BleEnableUtpOtaMode(UINT8 enable);
tBTM_STATUS BTM_BleUtpSend(UINT8 data_len, const UINT8 *p_data);
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_50_DTM_TEST_EN == TRUE)
@@ -494,6 +494,10 @@
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
#define HCI_BLE_ENABLE_UTP_OTA_MODE (0x009F | HCI_GRP_BLE_CMDS)
#define HCI_BLE_UTP_SEND (0x00A0 | HCI_GRP_BLE_CMDS)
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define HCI_BLE_CONNECTION_RATE_REQUEST (0x00A1 | HCI_GRP_BLE_CMDS)
@@ -1004,6 +1008,9 @@
#define HCI_BLE_FRAME_SPACE_UPDATE_COMPLETE_EVT 0x35
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
#define HCI_BLE_UTP_RECEIVE_EVT 0x36
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define HCI_BLE_CONN_RATE_CHANGE_EVT 0x37
@@ -858,6 +858,15 @@ BOOLEAN btsnd_hcic_ble_read_all_local_supp_features(void);
UINT8 btsnd_hcic_ble_read_all_remote_features(UINT16 conn_handle, UINT8 page_requested);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_LE_UTP == TRUE)
#define HCIC_PARAM_SIZE_ENABLE_UTP_OTA_MODE 1
#define HCIC_PARAM_SIZE_UTP_SEND_HDR 1
#define HCIC_PARAM_SIZE_UTP_SEND_MAX 255
#define BLE_UTP_DATA_MAX_LEN 254
UINT8 btsnd_hcic_ble_enable_utp_ota_mode(UINT8 enable);
UINT8 btsnd_hcic_ble_utp_send(UINT8 data_len, const UINT8 *p_data);
#endif // #if (BLE_FEAT_LE_UTP == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define HCIC_PARAM_SIZE_CONNECTION_RATE_REQUEST 20