feat(ble/bluedroid): add Shorter Connection Intervals host support (Core 6.2)

Co-authored-by: Cursor <cursoragent@cursor.com>


(cherry picked from commit 2a8a96d650)

Co-authored-by: zhiweijian <zhiweijian@espressif.com>
This commit is contained in:
Zhi Wei Jian
2026-06-26 09:08:25 +08:00
co-authored by Cursor
parent acfed7c42d
commit 28c67947f4
20 changed files with 943 additions and 0 deletions
+13
View File
@@ -1627,6 +1627,19 @@ config BT_BLE_FEAT_LL_EXT_FEAT
Enable LL Extended Feature Set (Bluetooth Core 6.0).
Supports LE Read All Local/Remote Supported Features HCI commands.
config BT_BLE_FEAT_SHORTER_CONN_INTERVALS
bool "Enable BLE Shorter Connection Intervals (Core 6.2)"
depends on BT_BLE_FEAT_CONN_SUBRATING && (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_SHORTER_CONN_INTERVALS_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
default n
help
Enable Shorter Connection Intervals feature (Bluetooth Core 6.2).
Requires Connection Subrating (Core 5.3) per [Vol 6] Part B, Section 4.6.50.
Supports LE Connection Rate Request, LE Set Default Rate Parameters,
LE Read Minimum Supported Connection Interval commands and LE Connection Rate Change event.
Connection intervals use 125 us units (minimum 375 us). Use esp_ble_gap_connection_rate_request(),
esp_ble_gap_set_default_rate_parameters(), esp_ble_gap_read_min_supported_connection_interval()
and ESP_BLE_GAP_CONN_RATE_* conversion macros in esp_gap_ble_api.h.
menuconfig BT_BLE_42_FEATURES_SUPPORTED
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
depends on BT_BLE_ENABLED
@@ -2097,6 +2097,157 @@ esp_err_t esp_ble_gap_read_all_remote_features(const esp_ble_gap_read_all_remote
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
static bool esp_ble_gap_conn_rate_common_params_valid(uint16_t conn_interval_min,
uint16_t conn_interval_max,
uint16_t subrate_min,
uint16_t subrate_max,
uint16_t max_latency,
uint16_t continuation_number,
uint16_t supervision_timeout,
uint16_t min_ce_len,
uint16_t max_ce_len)
{
if (conn_interval_min < ESP_BLE_GAP_CONN_RATE_INTERVAL_MIN ||
conn_interval_max < ESP_BLE_GAP_CONN_RATE_INTERVAL_MIN ||
conn_interval_min > conn_interval_max ||
conn_interval_max > ESP_BLE_GAP_CONN_RATE_INTERVAL_MAX) {
return false;
}
if (subrate_min < ESP_BLE_GAP_CONN_RATE_SUBRATE_MIN ||
subrate_max < ESP_BLE_GAP_CONN_RATE_SUBRATE_MIN ||
subrate_min > subrate_max ||
subrate_max > ESP_BLE_GAP_CONN_RATE_SUBRATE_MAX) {
return false;
}
if (continuation_number >= subrate_max ||
continuation_number > ESP_BLE_GAP_CONN_RATE_CONTINUATION_NUMBER_MAX) {
return false;
}
if (max_latency > ESP_BLE_GAP_CONN_RATE_MAX_LATENCY_MAX) {
return false;
}
if ((uint32_t)subrate_max * (uint32_t)(max_latency + 1U) >
ESP_BLE_GAP_CONN_RATE_SUBRATE_LATENCY_PRODUCT_MAX) {
return false;
}
if (supervision_timeout < ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_MIN ||
supervision_timeout > ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_MAX) {
return false;
}
if ((uint32_t)conn_interval_max * (uint32_t)subrate_max * (uint32_t)(max_latency + 1U) >=
(uint32_t)supervision_timeout * ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_FACTOR) {
return false;
}
if (min_ce_len > max_ce_len) {
return false;
}
return true;
}
static bool esp_ble_gap_connection_rate_params_valid(const esp_ble_gap_connection_rate_request_params_t *params)
{
return esp_ble_gap_conn_rate_common_params_valid(params->conn_interval_min,
params->conn_interval_max,
params->subrate_min,
params->subrate_max,
params->max_latency,
params->continuation_number,
params->supervision_timeout,
params->min_ce_len,
params->max_ce_len);
}
static bool esp_ble_gap_default_rate_params_valid(const esp_ble_gap_default_rate_param_t *params)
{
return esp_ble_gap_conn_rate_common_params_valid(params->conn_interval_min,
params->conn_interval_max,
params->subrate_min,
params->subrate_max,
params->max_latency,
params->continuation_number,
params->supervision_timeout,
params->min_ce_len,
params->max_ce_len);
}
esp_err_t esp_ble_gap_connection_rate_request(const esp_ble_gap_connection_rate_request_params_t *params)
{
btc_msg_t msg = {0};
btc_ble_5_gap_args_t arg;
memset(&arg, 0, sizeof(arg));
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (params == NULL) {
return ESP_ERR_INVALID_ARG;
}
if (!esp_ble_gap_connection_rate_params_valid(params)) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_CONNECTION_RATE_REQUEST;
arg.connection_rate_request.conn_handle = params->conn_handle;
arg.connection_rate_request.conn_interval_min = params->conn_interval_min;
arg.connection_rate_request.conn_interval_max = params->conn_interval_max;
arg.connection_rate_request.subrate_min = params->subrate_min;
arg.connection_rate_request.subrate_max = params->subrate_max;
arg.connection_rate_request.max_latency = params->max_latency;
arg.connection_rate_request.continuation_number = params->continuation_number;
arg.connection_rate_request.supervision_timeout = params->supervision_timeout;
arg.connection_rate_request.min_ce_len = params->min_ce_len;
arg.connection_rate_request.max_ce_len = params->max_ce_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_default_rate_parameters(const esp_ble_gap_default_rate_param_t *params)
{
btc_msg_t msg = {0};
btc_ble_5_gap_args_t arg;
memset(&arg, 0, sizeof(arg));
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (params == NULL) {
return ESP_ERR_INVALID_ARG;
}
if (!esp_ble_gap_default_rate_params_valid(params)) {
return ESP_ERR_INVALID_ARG;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS;
arg.set_default_rate_parameters.conn_interval_min = params->conn_interval_min;
arg.set_default_rate_parameters.conn_interval_max = params->conn_interval_max;
arg.set_default_rate_parameters.subrate_min = params->subrate_min;
arg.set_default_rate_parameters.subrate_max = params->subrate_max;
arg.set_default_rate_parameters.max_latency = params->max_latency;
arg.set_default_rate_parameters.continuation_number = params->continuation_number;
arg.set_default_rate_parameters.supervision_timeout = params->supervision_timeout;
arg.set_default_rate_parameters.min_ce_len = params->min_ce_len;
arg.set_default_rate_parameters.max_ce_len = params->max_ce_len;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_read_min_supported_connection_interval(void)
{
btc_msg_t msg = {0};
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL;
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -278,6 +278,10 @@ typedef enum {
ESP_GAP_BLE_FRAME_SPACE_UPDATE_COMPLETE_EVT, /*!< When frame space update complete, the event comes */
ESP_GAP_BLE_READ_ALL_LOCAL_SUPP_FEAT_COMPLETE_EVT, /*!< When read all local supported LE features complete, the event comes */
ESP_GAP_BLE_READ_ALL_REMOTE_FEAT_COMPLETE_EVT, /*!< When read all remote LE features complete, the event comes */
ESP_GAP_BLE_CONNECTION_RATE_REQUEST_COMPLETE_EVT, /*!< When connection rate request command complete, the event comes */
ESP_GAP_BLE_CONN_RATE_CHANGE_EVT, /*!< When connection rate change event is received, the event comes */
ESP_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT, /*!< When set default rate parameters complete, the event comes */
ESP_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT, /*!< When read minimum supported connection interval complete, the event comes */
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
} esp_gap_ble_cb_event_t;
@@ -1342,6 +1346,70 @@ typedef struct {
} esp_ble_gap_read_all_remote_feat_params_t;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_UNIT_US 125
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_MIN 3
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_MAX 0x7D00
#define ESP_BLE_GAP_CONN_RATE_SUBRATE_MIN 0x0001
#define ESP_BLE_GAP_CONN_RATE_SUBRATE_MAX 0x01F4
#define ESP_BLE_GAP_CONN_RATE_MAX_LATENCY_MAX 0x01F3
#define ESP_BLE_GAP_CONN_RATE_SUBRATE_LATENCY_PRODUCT_MAX 500
#define ESP_BLE_GAP_CONN_RATE_CONTINUATION_NUMBER_MAX 0x01F3
#define ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_MIN 0x000A
#define ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_MAX 0x0C80
#define ESP_BLE_GAP_CONN_RATE_SUPERVISION_TIMEOUT_FACTOR 40
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_US(units) \
((uint32_t)(units) * ESP_BLE_GAP_CONN_RATE_INTERVAL_UNIT_US)
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_FROM_US(us) \
((uint16_t)(((us) + (ESP_BLE_GAP_CONN_RATE_INTERVAL_UNIT_US - 1U)) / ESP_BLE_GAP_CONN_RATE_INTERVAL_UNIT_US))
#define ESP_BLE_GAP_CONN_RATE_INTERVAL_FROM_MS(ms) \
ESP_BLE_GAP_CONN_RATE_INTERVAL_FROM_US((uint32_t)(ms) * 1000U)
#define ESP_BLE_GAP_CONN_RATE_EFF_INTERVAL_US(interval, subrate) \
(ESP_BLE_GAP_CONN_RATE_INTERVAL_US(interval) * (uint32_t)(subrate))
/**
* @brief Parameters for requesting a connection rate update (Shorter Connection Intervals)
*/
typedef struct {
uint16_t conn_handle; /*!< Connection handle */
uint16_t conn_interval_min; /*!< Minimum connection interval in 125 us units. Range: 0x0003 to 0x7D00 */
uint16_t conn_interval_max; /*!< Maximum connection interval in 125 us units. Range: 0x0003 to 0x7D00 */
uint16_t subrate_min; /*!< Minimum subrate factor. Range: 0x0001 to 0x01F4 */
uint16_t subrate_max; /*!< Maximum subrate factor. Range: 0x0001 to 0x01F4 */
uint16_t max_latency; /*!< Maximum Peripheral latency in subrated connection intervals. Range: 0x0000 to 0x01F3 */
uint16_t continuation_number; /*!< Continuation number. Range: 0x0000 to 0x01F3 */
uint16_t supervision_timeout; /*!< Supervision timeout in 10 ms units. Range: 0x000A to 0x0C80 */
uint16_t min_ce_len; /*!< Minimum connection event length in 125 us units */
uint16_t max_ce_len; /*!< Maximum connection event length in 125 us units */
} esp_ble_gap_connection_rate_request_params_t;
/**
* @brief Default connection rate parameters for future Central connections
*/
typedef struct {
uint16_t conn_interval_min; /*!< Minimum connection interval in 125 us units. Range: 0x0003 to 0x7D00 */
uint16_t conn_interval_max; /*!< Maximum connection interval in 125 us units. Range: 0x0003 to 0x7D00 */
uint16_t subrate_min; /*!< Minimum subrate factor. Range: 0x0001 to 0x01F4 */
uint16_t subrate_max; /*!< Maximum subrate factor. Range: 0x0001 to 0x01F4 */
uint16_t max_latency; /*!< Maximum Peripheral latency in subrated connection intervals. Range: 0x0000 to 0x01F3 */
uint16_t continuation_number; /*!< Continuation number. Range: 0x0000 to 0x01F3 */
uint16_t supervision_timeout; /*!< Supervision timeout in 10 ms units. Range: 0x000A to 0x0C80 */
uint16_t min_ce_len; /*!< Minimum connection event length in 125 us units */
uint16_t max_ce_len; /*!< Maximum connection event length in 125 us units */
} esp_ble_gap_default_rate_param_t;
#define ESP_BLE_GAP_CONN_RATE_MAX_INTERVAL_GROUPS 41
/**
* @brief Supported connection interval group returned by read minimum supported connection interval
*/
typedef struct {
uint16_t min_125us; /*!< Lower bound of supported interval group in 125 us units */
uint16_t max_125us; /*!< Upper bound of supported interval group in 125 us units */
uint16_t stride_125us; /*!< Stride between supported intervals in 125 us units */
} esp_ble_gap_min_conn_interval_group_t;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
typedef enum {
@@ -2345,6 +2413,45 @@ typedef union {
uint8_t le_features[ESP_BLE_GAP_LL_EXT_FEAT_DATA_LEN]; /*!< Remote LE features data */
} read_all_remote_feat; /*!< Event parameter of ESP_GAP_BLE_READ_ALL_REMOTE_FEAT_COMPLETE_EVT */
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
/**
* @brief ESP_GAP_BLE_CONNECTION_RATE_REQUEST_COMPLETE_EVT
*
* Reported when the HCI Connection Rate Request command is accepted or rejected by the controller,
* or when the host fails to send the command locally.
*/
struct ble_connection_rate_request_cmpl_param {
esp_bt_status_t status; /*!< Command success status, or host/controller error code */
uint16_t conn_handle; /*!< Connection handle */
} connection_rate_req_cmpl; /*!< Event parameter of ESP_GAP_BLE_CONNECTION_RATE_REQUEST_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_CONN_RATE_CHANGE_EVT
*/
struct ble_conn_rate_change_evt {
esp_bt_status_t status; /*!< Indicate connection rate change status */
uint16_t conn_handle; /*!< Connection handle */
uint16_t conn_interval; /*!< Underlying connection interval in 125 us units */
uint16_t subrate_factor; /*!< Subrate factor applied to the connection interval */
uint16_t peripheral_latency; /*!< Peripheral latency in subrated connection intervals */
uint16_t continuation_number; /*!< Continuation number */
uint16_t supervision_timeout; /*!< Supervision timeout in 10 ms units */
} conn_rate_change_evt; /*!< Event parameter of ESP_GAP_BLE_CONN_RATE_CHANGE_EVT. Effective interval (us) = ESP_BLE_GAP_CONN_RATE_EFF_INTERVAL_US(conn_interval, subrate_factor) */
/**
* @brief ESP_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT
*/
struct ble_set_default_rate_parameters_cmpl_param {
esp_bt_status_t status; /*!< Indicate set default rate parameters operation success status */
} set_default_rate_parameters_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT
*/
struct ble_read_min_supp_conn_interval_cmpl_param {
esp_bt_status_t status; /*!< Indicate read minimum supported connection interval operation success status */
uint8_t min_supported_conn_interval; /*!< Minimum supported connection interval in 125 us units */
uint8_t num_groups; /*!< Number of supported interval groups; 0 if only RCV is supported */
esp_ble_gap_min_conn_interval_group_t groups[ESP_BLE_GAP_CONN_RATE_MAX_INTERVAL_GROUPS];
} read_min_supp_conn_interval; /*!< Event parameter of ESP_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT */
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
/**
* @brief ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT
*/
@@ -4266,6 +4373,61 @@ esp_err_t esp_ble_gap_read_all_local_supp_features(void);
esp_err_t esp_ble_gap_read_all_remote_features(const esp_ble_gap_read_all_remote_feat_params_t *params);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
/**
* @brief Request a connection rate update (Shorter Connection Intervals, Core 6.2).
*
* This API may be used by a Central or a Peripheral to request a change to the
* connection interval, subrate factor, and/or other connection parameters.
* `conn_interval_min/max` use 125 us units (minimum 375 us = 3).
* Use ESP_BLE_GAP_CONN_RATE_INTERVAL_FROM_MS() or ESP_BLE_GAP_CONN_RATE_INTERVAL_FROM_US()
* to convert from common time units.
*
* When the controller accepts or rejects the HCI command, `ESP_GAP_BLE_CONNECTION_RATE_REQUEST_COMPLETE_EVT`
* is reported with `status` and `conn_handle`. On command acceptance, `ESP_GAP_BLE_CONN_RATE_CHANGE_EVT`
* subsequently reports the applied parameters. The effective connection interval in microseconds is:
* ESP_BLE_GAP_CONN_RATE_EFF_INTERVAL_US(conn_interval, subrate_factor).
*
* @param[in] params : Pointer to connection rate request parameters.
*
* @return - ESP_OK : success (command sent)
* - ESP_ERR_INVALID_ARG : invalid parameters
* - ESP_ERR_INVALID_STATE : Bluedroid is not enabled
* - ESP_FAIL : other failures
*
*/
esp_err_t esp_ble_gap_connection_rate_request(const esp_ble_gap_connection_rate_request_params_t *params);
/**
* @brief Set default connection rate parameters for future Central connections (Core 6.2).
*
* Preconfigures the default connection rate parameters that may be requested by a
* Peripheral on new ACL connections where the local device is Central.
*
* @param[in] params : Pointer to default rate parameters.
*
* @return - ESP_OK : success
* - ESP_ERR_INVALID_ARG : invalid parameters
* - ESP_ERR_INVALID_STATE : Bluedroid is not enabled
* - ESP_FAIL : other failures
*
*/
esp_err_t esp_ble_gap_set_default_rate_parameters(const esp_ble_gap_default_rate_param_t *params);
/**
* @brief Read the Controller minimum supported connection interval and interval groups.
*
* On success, `ESP_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT` returns the
* minimum supported interval and optional interval groups. If `num_groups` is 0,
* the Controller only supports Rounded Connection Interval Values (RCV).
*
* @return - ESP_OK : success (command sent)
* - ESP_ERR_INVALID_STATE : Bluedroid is not enabled
* - ESP_FAIL : other failures
*
*/
esp_err_t esp_ble_gap_read_min_supported_connection_interval(void);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -6037,6 +6037,40 @@ void bta_dm_ble_gap_read_all_remote_features(tBTA_DM_MSG *p_data)
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
void bta_dm_ble_gap_connection_rate_request(tBTA_DM_MSG *p_data)
{
BTM_BleConnectionRateRequest(p_data->ble_connection_rate_request.conn_handle,
p_data->ble_connection_rate_request.conn_interval_min,
p_data->ble_connection_rate_request.conn_interval_max,
p_data->ble_connection_rate_request.subrate_min,
p_data->ble_connection_rate_request.subrate_max,
p_data->ble_connection_rate_request.max_latency,
p_data->ble_connection_rate_request.continuation_number,
p_data->ble_connection_rate_request.supervision_timeout,
p_data->ble_connection_rate_request.min_ce_len,
p_data->ble_connection_rate_request.max_ce_len);
}
void bta_dm_ble_gap_set_default_rate_parameters(tBTA_DM_MSG *p_data)
{
BTM_BleSetDefaultRateParameters(p_data->ble_set_default_rate_parameters.conn_interval_min,
p_data->ble_set_default_rate_parameters.conn_interval_max,
p_data->ble_set_default_rate_parameters.subrate_min,
p_data->ble_set_default_rate_parameters.subrate_max,
p_data->ble_set_default_rate_parameters.max_latency,
p_data->ble_set_default_rate_parameters.continuation_number,
p_data->ble_set_default_rate_parameters.supervision_timeout,
p_data->ble_set_default_rate_parameters.min_ce_len,
p_data->ble_set_default_rate_parameters.max_ce_len);
}
void bta_dm_ble_gap_read_min_supp_conn_interval(tBTA_DM_MSG *p_data)
{
(void)p_data;
BTM_BleReadMinSuppConnInterval();
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_ISO_EN == TRUE)
@@ -3356,7 +3356,77 @@ void BTA_DmBleGapReadAllRemoteFeatures(UINT16 conn_handle, UINT8 page_requested)
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
void BTA_DmBleGapConnectionRateRequest(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len)
{
tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST *p_msg;
APPL_TRACE_API("%s", __func__);
if ((p_msg = (tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST *)
osi_malloc(sizeof(tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST));
p_msg->hdr.event = BTA_DM_API_CONNECTION_RATE_REQUEST_EVT;
p_msg->conn_handle = conn_handle;
p_msg->conn_interval_min = conn_interval_min;
p_msg->conn_interval_max = conn_interval_max;
p_msg->subrate_min = subrate_min;
p_msg->subrate_max = subrate_max;
p_msg->max_latency = max_latency;
p_msg->continuation_number = continuation_number;
p_msg->supervision_timeout = supervision_timeout;
p_msg->min_ce_len = min_ce_len;
p_msg->max_ce_len = max_ce_len;
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
void BTA_DmBleGapSetDefaultRateParameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len)
{
tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS *p_msg;
APPL_TRACE_API("%s", __func__);
if ((p_msg = (tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS *)
osi_malloc(sizeof(tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS));
p_msg->hdr.event = BTA_DM_API_SET_DEFAULT_RATE_PARAMETERS_EVT;
p_msg->conn_interval_min = conn_interval_min;
p_msg->conn_interval_max = conn_interval_max;
p_msg->subrate_min = subrate_min;
p_msg->subrate_max = subrate_max;
p_msg->max_latency = max_latency;
p_msg->continuation_number = continuation_number;
p_msg->supervision_timeout = supervision_timeout;
p_msg->min_ce_len = min_ce_len;
p_msg->max_ce_len = max_ce_len;
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
void BTA_DmBleGapReadMinSuppConnInterval(void)
{
tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL *p_msg;
APPL_TRACE_API("%s", __func__);
if ((p_msg = (tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL *)
osi_malloc(sizeof(tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL));
p_msg->hdr.event = BTA_DM_API_READ_MIN_SUPP_CONN_INTERVAL_EVT;
bta_sys_sendmsg(p_msg);
} else {
APPL_TRACE_ERROR("%s malloc failed", __func__);
}
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_ISO_EN == TRUE)
@@ -339,6 +339,11 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_gap_read_all_local_supp_features, /* BTA_DM_API_READ_ALL_LOCAL_SUPP_FEAT_EVT */
bta_dm_ble_gap_read_all_remote_features, /* BTA_DM_API_READ_ALL_REMOTE_FEAT_EVT */
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
bta_dm_ble_gap_connection_rate_request, /* BTA_DM_API_CONNECTION_RATE_REQUEST_EVT */
bta_dm_ble_gap_set_default_rate_parameters, /* BTA_DM_API_SET_DEFAULT_RATE_PARAMETERS_EVT */
bta_dm_ble_gap_read_min_supp_conn_interval, /* BTA_DM_API_READ_MIN_SUPP_CONN_INTERVAL_EVT */
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
};
@@ -333,6 +333,11 @@ enum {
BTA_DM_API_READ_ALL_LOCAL_SUPP_FEAT_EVT,
BTA_DM_API_READ_ALL_REMOTE_FEAT_EVT,
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
BTA_DM_API_CONNECTION_RATE_REQUEST_EVT,
BTA_DM_API_SET_DEFAULT_RATE_PARAMETERS_EVT,
BTA_DM_API_READ_MIN_SUPP_CONN_INTERVAL_EVT,
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
BTA_DM_MAX_EVT
};
@@ -1430,6 +1435,38 @@ typedef struct {
} tBTA_DM_API_READ_ALL_REMOTE_FEAT;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
typedef struct {
BT_HDR hdr;
UINT16 conn_handle;
UINT16 conn_interval_min;
UINT16 conn_interval_max;
UINT16 subrate_min;
UINT16 subrate_max;
UINT16 max_latency;
UINT16 continuation_number;
UINT16 supervision_timeout;
UINT16 min_ce_len;
UINT16 max_ce_len;
} tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST;
typedef struct {
BT_HDR hdr;
UINT16 conn_interval_min;
UINT16 conn_interval_max;
UINT16 subrate_min;
UINT16 subrate_max;
UINT16 max_latency;
UINT16 continuation_number;
UINT16 supervision_timeout;
UINT16 min_ce_len;
UINT16 max_ce_len;
} tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS;
typedef struct {
BT_HDR hdr;
} tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
typedef struct {
@@ -1879,6 +1916,11 @@ typedef union {
tBTA_DM_API_READ_ALL_LOCAL_SUPP_FEAT ble_read_all_local_supp_feat;
tBTA_DM_API_READ_ALL_REMOTE_FEAT ble_read_all_remote_feat;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
tBTA_DM_API_BLE_CONNECTION_RATE_REQUEST ble_connection_rate_request;
tBTA_DM_API_BLE_SET_DEFAULT_RATE_PARAMETERS ble_set_default_rate_parameters;
tBTA_DM_API_BLE_READ_MIN_SUPP_CONN_INTERVAL ble_read_min_supp_conn_interval;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_42_DTM_TEST_EN == TRUE)
tBTA_DM_API_BLE_DTM_TX_START dtm_tx_start;
tBTA_DM_API_BLE_DTM_RX_START dtm_rx_start;
@@ -2572,6 +2614,11 @@ extern void bta_dm_ble_gap_read_all_local_supp_features(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_read_all_remote_features(tBTA_DM_MSG *p_data);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
extern void bta_dm_ble_gap_connection_rate_request(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_default_rate_parameters(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_read_min_supp_conn_interval(tBTA_DM_MSG *p_data);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_ISO_EN == TRUE)
@@ -1619,6 +1619,12 @@ typedef struct {
#define BTA_DM_BLE_5_GAP_READ_ALL_REMOTE_FEAT_COMPLETE_EVT BTM_BLE_5_GAP_READ_ALL_REMOTE_FEAT_COMPLETE_EVT
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define BTA_DM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT BTM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_CONN_RATE_CHANGE_EVT BTM_BLE_5_GAP_CONN_RATE_CHANGE_EVT
#define BTA_DM_BLE_5_GAP_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT BTM_BLE_5_GAP_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT
#define BTA_DM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT BTM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
@@ -3092,6 +3098,19 @@ extern void BTA_DmBleGapReadAllLocalSuppFeatures(void);
extern void BTA_DmBleGapReadAllRemoteFeatures(UINT16 conn_handle, UINT8 page_requested);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
extern void BTA_DmBleGapConnectionRateRequest(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len);
extern void BTA_DmBleGapSetDefaultRateParameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max,
UINT16 max_latency, UINT16 continuation_number,
UINT16 supervision_timeout, UINT16 min_ce_len,
UINT16 max_ce_len);
extern void BTA_DmBleGapReadMinSuppConnInterval(void);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_FEAT_ISO_EN == TRUE)
@@ -1335,6 +1335,53 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event,
break;
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
case BTA_DM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_CONNECTION_RATE_REQUEST_COMPLETE_EVT;
param.connection_rate_req_cmpl.status = btc_btm_status_to_esp_status(params->conn_rate_request.status);
param.connection_rate_req_cmpl.conn_handle = params->conn_rate_request.conn_handle;
break;
}
case BTA_DM_BLE_5_GAP_CONN_RATE_CHANGE_EVT: {
msg.act = ESP_GAP_BLE_CONN_RATE_CHANGE_EVT;
param.conn_rate_change_evt.status = btc_btm_status_to_esp_status(params->conn_rate_change.status);
param.conn_rate_change_evt.conn_handle = params->conn_rate_change.conn_handle;
param.conn_rate_change_evt.conn_interval = params->conn_rate_change.conn_interval;
param.conn_rate_change_evt.subrate_factor = params->conn_rate_change.subrate_factor;
param.conn_rate_change_evt.peripheral_latency = params->conn_rate_change.peripheral_latency;
param.conn_rate_change_evt.continuation_number = params->conn_rate_change.continuation_number;
param.conn_rate_change_evt.supervision_timeout = params->conn_rate_change.supervision_timeout;
break;
}
case BTA_DM_BLE_5_GAP_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT;
param.set_default_rate_parameters_cmpl.status = btc_btm_status_to_esp_status(params->status);
break;
}
case BTA_DM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT: {
msg.act = ESP_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT;
param.read_min_supp_conn_interval.status =
btc_btm_status_to_esp_status(params->read_min_supp_conn_interval.status);
param.read_min_supp_conn_interval.min_supported_conn_interval =
params->read_min_supp_conn_interval.min_supported_conn_interval;
param.read_min_supp_conn_interval.num_groups =
params->read_min_supp_conn_interval.num_groups;
if (params->read_min_supp_conn_interval.groups != NULL) {
for (uint8_t i = 0; i < params->read_min_supp_conn_interval.num_groups; i++) {
param.read_min_supp_conn_interval.groups[i].min_125us =
params->read_min_supp_conn_interval.groups[i].min_125us;
param.read_min_supp_conn_interval.groups[i].max_125us =
params->read_min_supp_conn_interval.groups[i].max_125us;
param.read_min_supp_conn_interval.groups[i].stride_125us =
params->read_min_supp_conn_interval.groups[i].stride_125us;
}
} else {
memset(param.read_min_supp_conn_interval.groups, 0,
sizeof(param.read_min_supp_conn_interval.groups));
}
break;
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_50_EXTEND_ADV_EN == TRUE)
case BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT: {
param.adv_terminate.status = params->adv_term.status;
@@ -3603,6 +3650,34 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
arg_5->read_all_remote_feat.page_requested);
break;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
case BTC_GAP_BLE_CONNECTION_RATE_REQUEST:
BTA_DmBleGapConnectionRateRequest(arg_5->connection_rate_request.conn_handle,
arg_5->connection_rate_request.conn_interval_min,
arg_5->connection_rate_request.conn_interval_max,
arg_5->connection_rate_request.subrate_min,
arg_5->connection_rate_request.subrate_max,
arg_5->connection_rate_request.max_latency,
arg_5->connection_rate_request.continuation_number,
arg_5->connection_rate_request.supervision_timeout,
arg_5->connection_rate_request.min_ce_len,
arg_5->connection_rate_request.max_ce_len);
break;
case BTC_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS:
BTA_DmBleGapSetDefaultRateParameters(arg_5->set_default_rate_parameters.conn_interval_min,
arg_5->set_default_rate_parameters.conn_interval_max,
arg_5->set_default_rate_parameters.subrate_min,
arg_5->set_default_rate_parameters.subrate_max,
arg_5->set_default_rate_parameters.max_latency,
arg_5->set_default_rate_parameters.continuation_number,
arg_5->set_default_rate_parameters.supervision_timeout,
arg_5->set_default_rate_parameters.min_ce_len,
arg_5->set_default_rate_parameters.max_ce_len);
break;
case BTC_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL:
BTA_DmBleGapReadMinSuppConnInterval();
break;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
case BTC_GAP_BLE_SET_PA_SUBEVT_DATA:
BTA_DmBleGapSetPASubevtData(arg_5->per_adv_subevent_data_params.adv_handle, arg_5->per_adv_subevent_data_params.num_subevents_with_data, (uint8_t *)(arg_5->per_adv_subevent_data_params.subevent_params));
@@ -158,6 +158,11 @@ typedef enum {
BTC_GAP_BLE_READ_ALL_LOCAL_SUPP_FEAT,
BTC_GAP_BLE_READ_ALL_REMOTE_FEAT,
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
BTC_GAP_BLE_CONNECTION_RATE_REQUEST,
BTC_GAP_BLE_SET_DEFAULT_RATE_PARAMETERS,
BTC_GAP_BLE_READ_MIN_SUPP_CONN_INTERVAL,
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
BTC_GAP_BLE_READ_CHANNEL_MAP,
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
BTC_GAP_BLE_SET_PA_SUBEVT_DATA,
@@ -628,6 +633,31 @@ typedef union {
uint8_t page_requested;
} read_all_remote_feat;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
struct connection_rate_request_args {
uint16_t conn_handle;
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t subrate_min;
uint16_t subrate_max;
uint16_t max_latency;
uint16_t continuation_number;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} connection_rate_request;
struct set_default_rate_parameters_args {
uint16_t conn_interval_min;
uint16_t conn_interval_max;
uint16_t subrate_min;
uint16_t subrate_max;
uint16_t max_latency;
uint16_t continuation_number;
uint16_t supervision_timeout;
uint16_t min_ce_len;
uint16_t max_ce_len;
} set_default_rate_parameters;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
// BTC_GAP_BLE_SET_PA_SUBEVT_DATA
struct per_adv_subevent_data_params_args {
@@ -428,6 +428,11 @@
#define UC_BT_BLE_FEAT_LL_EXT_FEAT FALSE
#endif
#ifdef CONFIG_BT_BLE_FEAT_SHORTER_CONN_INTERVALS
#define UC_BT_BLE_FEAT_SHORTER_CONN_INTERVALS CONFIG_BT_BLE_FEAT_SHORTER_CONN_INTERVALS
#else
#define UC_BT_BLE_FEAT_SHORTER_CONN_INTERVALS FALSE
#endif
#ifdef CONFIG_BT_BLE_VENDOR_HCI_EN
@@ -469,6 +469,11 @@
#define BLE_FEAT_LL_EXT_FEAT FALSE
#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE) && (UC_BT_BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define BLE_FEAT_SHORTER_CONN_INTERVALS TRUE
#else
#define BLE_FEAT_SHORTER_CONN_INTERVALS FALSE
#endif
#if (UC_BT_BLE_VENDOR_HCI_EN == TRUE)
@@ -1581,6 +1581,137 @@ void btm_ble_read_all_remote_features_complete_evt(UINT8 *p)
}
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
tBTM_STATUS BTM_BleConnectionRateRequest(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len)
{
tHCI_STATUS err;
err = btsnd_hcic_ble_connection_rate_request(conn_handle, conn_interval_min, conn_interval_max,
subrate_min, subrate_max, max_latency,
continuation_number, supervision_timeout,
min_ce_len, max_ce_len);
if (err != HCI_SUCCESS) {
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
cb_params.conn_rate_request.status = BTM_HCI_ERROR | err;
cb_params.conn_rate_request.conn_handle = conn_handle;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT, &cb_params);
return BTM_NO_RESOURCES;
}
return BTM_CMD_STARTED;
}
void btm_conn_rate_req_cmd_status(UINT8 status, UINT16 conn_handle)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if (status != HCI_SUCCESS) {
status = (status | BTM_HCI_ERROR);
}
cb_params.conn_rate_request.status = status;
cb_params.conn_rate_request.conn_handle = conn_handle;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT, &cb_params);
}
void btm_ble_conn_rate_change_evt(tBTM_BLE_CONN_RATE_CHANGE *params)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if (!params) {
return;
}
/* Like btm_ble_subrate_change_evt(), notify the application only.
* Do not fold interval*subrate into L2CAP current_used_conn_interval:
* that field is UINT16 in 1.25 ms units and cannot represent SCI
* effective intervals; apps use ESP_GAP_BLE_CONN_RATE_CHANGE_EVT and
* ESP_BLE_GAP_CONN_RATE_EFF_INTERVAL_US() instead. */
cb_params.conn_rate_change = *params;
if (cb_params.conn_rate_change.status != HCI_SUCCESS) {
cb_params.conn_rate_change.status |= BTM_HCI_ERROR;
}
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_CONN_RATE_CHANGE_EVT, &cb_params);
}
void BTM_BleSetDefaultRateParameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len)
{
tBTM_STATUS status = BTM_SUCCESS;
tHCI_STATUS err = HCI_SUCCESS;
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if ((err = btsnd_hcic_ble_set_default_rate_parameters(conn_interval_min, conn_interval_max,
subrate_min, subrate_max, max_latency,
continuation_number, supervision_timeout,
min_ce_len, max_ce_len)) != HCI_SUCCESS) {
BTM_TRACE_ERROR("%s cmd err=0x%x", __func__, err);
status = BTM_HCI_ERROR | err;
}
cb_params.status = status;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_DEFAULT_RATE_PARAMETERS_COMPLETE_EVT, &cb_params);
}
tBTM_STATUS BTM_BleReadMinSuppConnInterval(void)
{
if (!btsnd_hcic_ble_read_min_supp_conn_interval()) {
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
cb_params.read_min_supp_conn_interval.status = BTM_HCI_ERROR | HCI_ERR_MEMORY_FULL;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT, &cb_params);
return BTM_NO_RESOURCES;
}
return BTM_CMD_STARTED;
}
void btm_ble_read_min_supp_conn_interval_cmd_status(UINT8 status)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
if (status == HCI_SUCCESS) {
return;
}
cb_params.read_min_supp_conn_interval.status = status | BTM_HCI_ERROR;
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT, &cb_params);
}
void btm_ble_read_min_supp_conn_interval_complete(UINT8 *p)
{
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
UINT8 num_groups;
if (!p) {
return;
}
STREAM_TO_UINT8(cb_params.read_min_supp_conn_interval.status, p);
if (cb_params.read_min_supp_conn_interval.status == HCI_SUCCESS) {
STREAM_TO_UINT8(cb_params.read_min_supp_conn_interval.min_supported_conn_interval, p);
STREAM_TO_UINT8(num_groups, p);
if (num_groups > BTM_BLE_MAX_CONN_INTERVAL_GROUPS) {
BTM_TRACE_WARNING("%s num_groups %u exceeds max %u", __func__, num_groups,
BTM_BLE_MAX_CONN_INTERVAL_GROUPS);
num_groups = BTM_BLE_MAX_CONN_INTERVAL_GROUPS;
}
cb_params.read_min_supp_conn_interval.num_groups = num_groups;
cb_params.read_min_supp_conn_interval.groups = btm_ble_min_conn_interval_groups;
for (UINT8 i = 0; i < num_groups; i++) {
STREAM_TO_UINT16(btm_ble_min_conn_interval_groups[i].min_125us, p);
STREAM_TO_UINT16(btm_ble_min_conn_interval_groups[i].max_125us, p);
STREAM_TO_UINT16(btm_ble_min_conn_interval_groups[i].stride_125us, p);
}
} else {
cb_params.read_min_supp_conn_interval.status |= BTM_HCI_ERROR;
}
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_READ_MIN_SUPP_CONN_INTERVAL_COMPLETE_EVT, &cb_params);
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BLE_50_EXTEND_ADV_EN == TRUE)
@@ -606,6 +606,10 @@ void btm_ble_frame_space_update_complete_evt(UINT8 *p);
void btm_ble_read_all_local_supp_features_complete(UINT8 *p);
void btm_ble_read_all_remote_features_complete_evt(UINT8 *p);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
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 (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);
@@ -1205,6 +1205,15 @@ void btm_subrate_req_cmd_status(UINT8 status);
void btm_frame_space_update_cmd_status(UINT8 status, UINT16 conn_handle);
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_LL_EXT_FEAT == TRUE)
void btm_read_all_remote_feat_cmd_status(UINT8 status);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
void btm_conn_rate_req_cmd_status(UINT8 status, UINT16 conn_handle);
void btm_ble_read_min_supp_conn_interval_cmd_status(UINT8 status);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
void btm_ble_cs_read_local_supp_caps_cmpl_evt(UINT8 *p);
void btm_ble_cs_read_remote_supp_caps_cmd_status(UINT8 status);
@@ -1520,6 +1520,11 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
btm_ble_read_all_local_supp_features_complete(p);
break;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
case HCI_BLE_READ_MIN_SUPP_CONN_INTERVAL:
btm_ble_read_min_supp_conn_interval_complete(p);
break;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#endif /* (BLE_INCLUDED == TRUE) */
default: {
@@ -1701,6 +1706,26 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
break;
}
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_LL_EXT_FEAT == TRUE)
case HCI_BLE_READ_ALL_REMOTE_FEATURES:
btm_read_all_remote_feat_cmd_status(status);
break;
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
case HCI_BLE_CONNECTION_RATE_REQUEST:
{
UINT16 conn_handle = HCI_INVALID_HANDLE;
if (p_cmd != NULL) {
p_cmd++; /* skip param length */
STREAM_TO_UINT16(conn_handle, p_cmd);
}
btm_conn_rate_req_cmd_status(status, conn_handle);
break;
}
case HCI_BLE_READ_MIN_SUPP_CONN_INTERVAL:
btm_ble_read_min_supp_conn_interval_cmd_status(status);
break;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
case HCI_BLE_CS_READ_REMOTE_SUPP_CAPS:
btm_ble_cs_read_remote_supp_caps_cmd_status(status);
@@ -3187,6 +3187,86 @@ 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_SHORTER_CONN_INTERVALS == TRUE)
UINT8 btsnd_hcic_ble_connection_rate_request(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("hci conn rate req, handle %u int [%u, %u] subrate [%u, %u] latency %u cont %u timeout %u ce [%u, %u]",
conn_handle, conn_interval_min, conn_interval_max, subrate_min, subrate_max,
max_latency, continuation_number, supervision_timeout, min_ce_len, max_ce_len);
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CONNECTION_RATE_REQUEST);
UINT16_TO_STREAM(pp, HCI_BLE_CONNECTION_RATE_REQUEST);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CONNECTION_RATE_REQUEST);
UINT16_TO_STREAM(pp, conn_handle);
UINT16_TO_STREAM(pp, conn_interval_min);
UINT16_TO_STREAM(pp, conn_interval_max);
UINT16_TO_STREAM(pp, subrate_min);
UINT16_TO_STREAM(pp, subrate_max);
UINT16_TO_STREAM(pp, max_latency);
UINT16_TO_STREAM(pp, continuation_number);
UINT16_TO_STREAM(pp, supervision_timeout);
UINT16_TO_STREAM(pp, min_ce_len);
UINT16_TO_STREAM(pp, max_ce_len);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return HCI_SUCCESS;
}
UINT8 btsnd_hcic_ble_set_default_rate_parameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max,
UINT16 max_latency, UINT16 continuation_number,
UINT16 supervision_timeout, UINT16 min_ce_len,
UINT16 max_ce_len)
{
BT_HDR *p;
UINT8 *pp;
HCI_TRACE_DEBUG("hci set default rate, int [%u, %u] subrate [%u, %u] latency %u cont %u timeout %u ce [%u, %u]",
conn_interval_min, conn_interval_max, subrate_min, subrate_max,
max_latency, continuation_number, supervision_timeout, min_ce_len, max_ce_len);
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_RATE_PARAMETERS);
UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_RATE_PARAMETERS);
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_DEFAULT_RATE_PARAMETERS);
UINT16_TO_STREAM(pp, conn_interval_min);
UINT16_TO_STREAM(pp, conn_interval_max);
UINT16_TO_STREAM(pp, subrate_min);
UINT16_TO_STREAM(pp, subrate_max);
UINT16_TO_STREAM(pp, max_latency);
UINT16_TO_STREAM(pp, continuation_number);
UINT16_TO_STREAM(pp, supervision_timeout);
UINT16_TO_STREAM(pp, min_ce_len);
UINT16_TO_STREAM(pp, max_ce_len);
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
}
BOOLEAN btsnd_hcic_ble_read_min_supp_conn_interval(void)
{
BT_HDR *p;
UINT8 *pp;
if ((p = HCI_GET_CMD_BUF(0)) == NULL) {
return FALSE;
}
pp = (UINT8 *)(p + 1);
p->len = HCIC_PREAMBLE_SIZE;
p->offset = 0;
UINT16_TO_STREAM(pp, HCI_BLE_READ_MIN_SUPP_CONN_INTERVAL);
UINT8_TO_STREAM(pp, 0);
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
return TRUE;
}
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
UINT8 btsnd_hcic_ble_set_periodic_adv_subevt_data(UINT8 adv_handle, UINT8 num_subevents_with_data, ble_subevent_params *subevent_params)
@@ -1001,6 +1001,12 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st
#define BTM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT 79
#define BTM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT 80
#endif // #if (BLE_FEAT_DBAF == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define BTM_BLE_5_GAP_CONNECTION_RATE_REQUEST_COMPLETE_EVT 81
#define BTM_BLE_5_GAP_CONN_RATE_CHANGE_EVT 82
#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)
#define BTM_BLE_5_GAP_UNKNOWN_EVT 91
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
@@ -1282,6 +1288,37 @@ typedef struct {
} tBTM_BLE_FRAME_SPACE_UPDATE;
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
typedef struct {
tBTM_STATUS status;
UINT16 conn_handle;
} tBTM_BLE_CONNECTION_RATE_REQUEST_CMPL;
typedef struct {
tBTM_STATUS status;
UINT16 conn_handle;
UINT16 conn_interval;
UINT16 subrate_factor;
UINT16 peripheral_latency;
UINT16 continuation_number;
UINT16 supervision_timeout;
} tBTM_BLE_CONN_RATE_CHANGE;
#define BTM_BLE_MAX_CONN_INTERVAL_GROUPS 41
typedef struct {
UINT16 min_125us;
UINT16 max_125us;
UINT16 stride_125us;
} tBTM_BLE_MIN_CONN_INTERVAL_GROUP;
typedef struct {
tBTM_STATUS status;
UINT8 min_supported_conn_interval;
UINT8 num_groups;
tBTM_BLE_MIN_CONN_INTERVAL_GROUP *groups;
} tBTM_BLE_READ_MIN_SUPP_CONN_INTERVAL;
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
typedef struct {
@@ -2001,6 +2038,11 @@ typedef union {
#if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
tBTM_BLE_FRAME_SPACE_UPDATE frame_space_update;
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
tBTM_BLE_CONNECTION_RATE_REQUEST_CMPL conn_rate_request;
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)
} tBTM_BLE_5_GAP_CB_PARAMS;
typedef struct {
@@ -3179,6 +3221,18 @@ tBTM_STATUS BTM_BleReadAllLocalSuppFeatures(void);
tBTM_STATUS BTM_BleReadAllRemoteFeatures(UINT16 conn_handle, UINT8 page_requested);
#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
tBTM_STATUS BTM_BleConnectionRateRequest(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len);
void BTM_BleSetDefaultRateParameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len);
tBTM_STATUS BTM_BleReadMinSuppConnInterval(void);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -495,6 +495,11 @@
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define HCI_BLE_CONNECTION_RATE_REQUEST (0x00A1 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_SET_DEFAULT_RATE_PARAMETERS (0x00A2 | HCI_GRP_BLE_CMDS)
#define HCI_BLE_READ_MIN_SUPP_CONN_INTERVAL (0x00A3 | HCI_GRP_BLE_CMDS)
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
// Vendor OGF define
#define HCI_VENDOR_OGF 0x3F
@@ -1000,6 +1005,9 @@
#endif // #if (BLE_FEAT_FRAME_SPACE_UPDATE == TRUE)
#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#define HCI_BLE_CONN_RATE_CHANGE_EVT 0x37
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
#define HCI_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT 0x2C
@@ -859,6 +859,22 @@ 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_SHORTER_CONN_INTERVALS == TRUE)
#define HCIC_PARAM_SIZE_CONNECTION_RATE_REQUEST 20
#define HCIC_PARAM_SIZE_SET_DEFAULT_RATE_PARAMETERS 18
UINT8 btsnd_hcic_ble_connection_rate_request(UINT16 conn_handle, UINT16 conn_interval_min,
UINT16 conn_interval_max, UINT16 subrate_min,
UINT16 subrate_max, UINT16 max_latency,
UINT16 continuation_number, UINT16 supervision_timeout,
UINT16 min_ce_len, UINT16 max_ce_len);
UINT8 btsnd_hcic_ble_set_default_rate_parameters(UINT16 conn_interval_min, UINT16 conn_interval_max,
UINT16 subrate_min, UINT16 subrate_max,
UINT16 max_latency, UINT16 continuation_number,
UINT16 supervision_timeout, UINT16 min_ce_len,
UINT16 max_ce_len);
BOOLEAN btsnd_hcic_ble_read_min_supp_conn_interval(void);
#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE)
/* ULP HCI command */
BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask);