diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index fc2b6127d3..6285bfbc61 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1410,6 +1410,13 @@ config BT_BLE_FEAT_POWER_CONTROL help Enable BLE power control feature +config BT_BLE_FEAT_CONN_SUBRATING + bool "Enable BLE connection subrating feature" + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_SUBRATE_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n + help + Enable BLE connection subrating feature + config BT_BLE_HIGH_DUTY_ADV_INTERVAL bool "Enable BLE high duty advertising interval feature" depends on BT_BLE_ENABLED diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index 29fe54a78c..da75e18f1b 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -1895,3 +1895,60 @@ esp_err_t esp_ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle, } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +esp_err_t esp_ble_gap_set_default_subrate(esp_ble_default_subrate_param_t *default_subrate_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!default_subrate_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SET_DEFALT_SUBRATE; + + arg.default_subrate_param.subrate_min = default_subrate_params->subrate_min; + arg.default_subrate_param.subrate_max = default_subrate_params->subrate_max; + arg.default_subrate_param.max_latency = default_subrate_params->max_latency; + arg.default_subrate_param.continuation_number = default_subrate_params->continuation_number; + arg.default_subrate_param.supervision_timeout = default_subrate_params->supervision_timeout; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + +esp_err_t esp_ble_gap_subrate_request(esp_ble_subrate_req_param_t *subrate_req_params) +{ + btc_msg_t msg = {0}; + btc_ble_5_gap_args_t arg; + + if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) { + return ESP_ERR_INVALID_STATE; + } + + if (!subrate_req_params) { + return ESP_ERR_NOT_ALLOWED; + } + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_SUBRATE_REQUEST; + + arg.subrate_req_param.conn_handle = subrate_req_params->conn_handle; + arg.subrate_req_param.subrate_min = subrate_req_params->subrate_min; + arg.subrate_req_param.subrate_max = subrate_req_params->subrate_max; + arg.subrate_req_param.max_latency = subrate_req_params->max_latency; + arg.subrate_req_param.continuation_number = subrate_req_params->continuation_number; + arg.subrate_req_param.supervision_timeout = subrate_req_params->supervision_timeout; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) + == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index abb430df09..4e4322adcf 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -240,6 +240,10 @@ typedef enum { ESP_GAP_BLE_SET_TRANS_PWR_RPTING_ENABLE_EVT, /*!< when enable or disable the reporting to the local Host of transmit power level changes complete, the event comes */ ESP_GAP_BLE_PATH_LOSS_THRESHOLD_EVT, /*!< when receive a path loss threshold crossing, the event comes */ ESP_GAP_BLE_TRANS_PWR_RPTING_EVT, /*!< when receive a transmit power level report, the event comes */ + // BLE connection subrating + ESP_GAP_BLE_SET_DEFAULT_SUBRATE_COMPLETE_EVT, /*!< when set default subrate complete, the event comes */ + ESP_GAP_BLE_SUBRATE_REQUEST_COMPLETE_EVT, /*!< when subrate request command complete, the event comes */ + ESP_GAP_BLE_SUBRATE_CHANGE_EVT, /*!< when Connection Subrate Update procedure has completed and some parameters of the specified connection have changed, the event comes */ ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */ } esp_gap_ble_cb_event_t; @@ -1121,6 +1125,36 @@ typedef enum { ESP_BLE_CONN_PATH_LOSS_ZONE_ENTERED_HIGH = 0x02, } esp_ble_path_loss_zone_t; +/** +* @brief Connection subrating default parameters +*/ +typedef struct { + uint16_t subrate_min; /*!< Minimum subrate factor allowed in requests by a Peripheral. Range: 0x0001 to 0x01F4, default: 0x0001 */ + uint16_t subrate_max; /*!< Maximum subrate factor allowed in requests by a Peripheral. Range: 0x0001 to 0x01F4, default: 0x0001. subrate_max × (max_latency + 1) should not be greater than 500 */ + uint16_t max_latency; /*!< Maximum Peripheral latency allowed in requests by a Peripheral, in units of subrated connection intervals. + Range: 0x0000 to 0x01F3, default: 0x0000 */ + uint16_t continuation_number; /*!< Minimum number of underlying connection events to remain active after a packet containing a Link Layer + PDU with a non-zero Length field is sent or received in requests by a Peripheral. Range: 0x0000 to 0x01F3, + default: 0x0000. continuation_number should not greater than or equal to subrate_max */ + uint16_t supervision_timeout; /*!< Maximum supervision timeout allowed in requests by a Peripheral (N * 10 ms). Range: 0x000A to 0x0C80, + Time Range: 100 ms to 32 s, default: 0x0C80 (32 s) */ +} esp_ble_default_subrate_param_t; + +/** +* @brief Connection subrating request parameters +*/ +typedef struct { + uint16_t conn_handle; /*!< Connection handle of the ACL */ + uint16_t subrate_min; /*!< Minimum subrate factor to be applied to the underlying connection interval. Range: 0x0001 to 0x01F4 */ + uint16_t subrate_max; /*!< Maximum subrate factor to be applied to the underlying connection interval. Range: 0x0001 to 0x01F4 */ + uint16_t max_latency; /*!< Maximum Peripheral latency for the connection in units of subrated connection intervals. Range: 0x0000 to 0x01F3 */ + uint16_t continuation_number; /*!< Minimum number of underlying connection events to remain active after a packet containing + a Link Layer PDU with a non-zero Length field is sent or received. Range: 0x0000 to 0x01F3 */ + uint16_t supervision_timeout; /*!< Supervision timeout for this connection (N * 10 ms). Range: 0x000A to 0x0C80, Time Range: 100 ms to 32 s + The supervision_timeout, in milliseconds, shall be greater than 2 × current connection interval × subrate_max × (max_latency + 1) */ +} esp_ble_subrate_req_param_t; + + /** * @brief Gap callback parameters union */ @@ -1716,6 +1750,31 @@ typedef union { } trans_power_report_evt; /*!< Event parameter of ESP_GAP_BLE_TRANS_PWR_RPTING_EVT */ #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + /** + * @brief ESP_GAP_BLE_SET_DEFAULT_SUBRATE_COMPLETE_EVT + */ + struct ble_default_subrate_evt { + esp_bt_status_t status; /*!< Indicate setting default subrate command success, status = (controller error code | 0x100) if status is not equal to 0 */ + } set_default_subrate_evt; /*!< Event parameter of ESP_GAP_BLE_SET_DEFAULT_SUBRATE_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_SUBRATE_REQUEST_COMPLETE_EVT + */ + struct ble_subrate_request_evt { + esp_bt_status_t status; /*!< Indicate subrate request command success, status = (controller error code | 0x100) if status is not equal to 0 */ + } subrate_req_cmpl_evt; /*!< Event parameter of ESP_GAP_BLE_SUBRATE_REQUEST_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_SUBRATE_CHANGE_EVT + */ + struct ble_subrate_change_evt { + esp_bt_status_t status; /*!< command succeeded or this event was generated following a request from the peer device. status = (controller error code | 0x100) if status is not equal to 0 */ + uint16_t conn_handle; /*!< connection handle */ + uint16_t subrate_factor; /*!< New subrate factor applied to the specified underlying connection interval, range 0x0001 to 0x01F4 */ + uint16_t peripheral_latency; /*!< New Peripheral latency for the connection in number of subrated connection events, range: 0x0000 to 0x01F3 */ + uint16_t continuation_number; /*!< Number of underlying connection events to remain active after a packet containing a Link Layer PDU with a non-zero Length field is sent or received, range: 0x0000 to 0x01F3 */ + uint16_t supervision_timeout; /*!< New supervision timeout for this connection(Time = N × 10 ms). Range: 0x000A to 0x0C80, Time Range: 100 ms to 32 s */ + } subrate_change_evt; /*!< Event parameter of ESP_GAP_BLE_SUBRATE_CHANGE_EVT */ +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } esp_ble_gap_cb_param_t; /** @@ -2986,6 +3045,46 @@ esp_err_t esp_ble_gap_set_path_loss_reporting_enable(uint16_t conn_handle, bool */ esp_err_t esp_ble_gap_set_transmit_power_reporting_enable(uint16_t conn_handle, bool local_enable, bool remote_enable); +/** + * @brief This function is used to set the initial values for the acceptable parameters for subrating requests, + * for all future ACL connections where the Controller is the Central. This command does not affect any + * existing connection. + * + * + * @param[in] default_subrate_params: The default subrate parameters. + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_set_default_subrate(esp_ble_default_subrate_param_t *default_subrate_params); + +/** + * @brief This function is used by a Central or a Peripheral to request a change to the subrating factor and/or other parameters + * applied to an existing connection. + * + * If this API is issued on the Central, the following rules shall apply when the Controller initiates the Connection Subrate Update procedure: + * 1. The Peripheral latency shall be less than or equal to max_latency. + * 2. The subrate factor shall be between subrate_min and subrate_max. + * 3. The continuation number shall be equal to the lesser of continuation_number and (subrate factor - 1). + * 4. The connection supervision timeout shall be equal to supervision_timeout. + * + * If this API is issued on the Peripheral, the following rules shall apply when the Controller initiates the Connection Subrate Request procedure: + * 1. The Peripheral latency shall be less than or equal to max_latency. + * 2. The minimum and maximum subrate factors shall be between subrate_min and subrate_max. + * 3. The continuation number shall be equal to the lesser of continuation_number and (maximum subrate factor - 1). + * 4.The connection supervision timeout shall be equal to supervision_timeout. + * + * + * @param[in] subrate_req_params: The subrate request parameters. + * + * + * @return + * - ESP_OK : success + * - other : failed + */ +esp_err_t esp_ble_gap_subrate_request(esp_ble_subrate_req_param_t *subrate_req_params); #ifdef __cplusplus } diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 027caae80b..3593226431 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -6304,6 +6304,20 @@ void bta_dm_api_set_trans_power_reporting_en(tBTA_DM_MSG *p_data) } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void bta_dm_api_set_default_subrate(tBTA_DM_MSG *p_data) +{ + BTM_BleSetDefaultSubrate(p_data->default_subrate.subrate_min, p_data->default_subrate.subrate_max, p_data->default_subrate.max_latency, + p_data->default_subrate.continuation_number, p_data->default_subrate.supervision_timeout); +} + +void bta_dm_api_subrate_request(tBTA_DM_MSG *p_data) +{ + BTM_BleSubrateRequest(p_data->subrate_request.conn_handle, p_data->subrate_request.subrate_min, p_data->subrate_request.subrate_max, + p_data->subrate_request.max_latency, p_data->subrate_request.continuation_number, p_data->subrate_request.supervision_timeout); +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #if (BLE_HOST_SETUP_STORAGE_EN == TRUE) /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 732be79f80..698fff90e4 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -3099,6 +3099,41 @@ void BTA_DmBleGapSetTransPwrRptEnable(uint16_t conn_handle, uint8_t local_enable } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void BTA_DmBleGapSetDefaultSubrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency, uint16_t continuation_number, uint16_t supervision_timeout) +{ + tBTA_DM_API_BLE_SET_DEFAULT_SUBRATE *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_SET_DEFAULT_SUBRATE *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_DEFAULT_SUBRATE))) + != NULL) { + p_msg->hdr.event = BTA_DM_API_SET_DEFALT_SUBRATE; + 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; + bta_sys_sendmsg(p_msg); + } +} + +void BTA_DmBleGapSubrateReqest(uint16_t conn_handle, uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency, uint16_t continuation_number, uint16_t supervision_timeout) +{ + tBTA_DM_API_BLE_SUBRATE_REQUEST *p_msg; + + if ((p_msg = (tBTA_DM_API_BLE_SUBRATE_REQUEST *)osi_malloc(sizeof(tBTA_DM_API_BLE_SUBRATE_REQUEST))) + != NULL) { + p_msg->hdr.event = BTA_DM_API_SUBRATE_REQUEST; + p_msg->conn_handle = conn_handle; + 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; + bta_sys_sendmsg(p_msg); + } +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + /******************************************************************************* ** ** Function BTA_VendorInit diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 19b213cd26..a21f36c3d6 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -337,6 +337,10 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_api_set_path_loss_reporting_en, /* BTA_DM_API_SET_PATH_LOSS_REPORTING_EN */ bta_dm_api_set_trans_power_reporting_en, /* BTA_DM_API_SET_TRANS_POWER_REPORTING_EN */ #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + bta_dm_api_set_default_subrate, /* BTA_DM_API_SET_DEFALT_SUBRATE */ + bta_dm_api_subrate_request, /* BTA_DM_API_SUBRATE_REQUEST */ +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) }; diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index b92561fa33..89514ba668 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -328,6 +328,10 @@ enum { BTA_DM_API_SET_PATH_LOSS_REPORTING_EN, BTA_DM_API_SET_TRANS_POWER_REPORTING_EN, #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + BTA_DM_API_SET_DEFALT_SUBRATE, + BTA_DM_API_SUBRATE_REQUEST, +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) BTA_DM_MAX_EVT }; @@ -1114,6 +1118,27 @@ typedef struct { } tBTA_DM_API_BLE_SET_TRANS_PWR_RPT_ENABLE; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +typedef struct { + BT_HDR hdr; + UINT16 subrate_min; + UINT16 subrate_max; + UINT16 max_latency; + UINT16 continuation_number; + UINT16 supervision_timeout; +} tBTA_DM_API_BLE_SET_DEFAULT_SUBRATE; + +typedef struct { + BT_HDR hdr; + UINT16 conn_handle; + UINT16 subrate_min; + UINT16 subrate_max; + UINT16 max_latency; + UINT16 continuation_number; + UINT16 supervision_timeout; +} tBTA_DM_API_BLE_SUBRATE_REQUEST; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #endif /* BLE_INCLUDED */ #if (BLE_HOST_REMOVE_AN_ACL_EN == TRUE) @@ -1832,6 +1857,10 @@ typedef union { tBTA_DM_API_BLE_SET_PATH_LOSS_RPT_ENABLE path_loss_rpt_en; tBTA_DM_API_BLE_SET_TRANS_PWR_RPT_ENABLE trans_pwr_rpt_en; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + tBTA_DM_API_BLE_SET_DEFAULT_SUBRATE default_subrate; + tBTA_DM_API_BLE_SUBRATE_REQUEST subrate_request; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } tBTA_DM_MSG; @@ -2492,5 +2521,8 @@ void bta_dm_api_set_path_loss_report_params(tBTA_DM_MSG *p_data); void bta_dm_api_set_path_loss_reporting_en(tBTA_DM_MSG *p_data); void bta_dm_api_set_trans_power_reporting_en(tBTA_DM_MSG *p_data); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) - +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void bta_dm_api_set_default_subrate(tBTA_DM_MSG *p_data); +void bta_dm_api_subrate_request(tBTA_DM_MSG *p_data); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) #endif /* BTA_DM_INT_H */ diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 8d412590f0..b098b9a540 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1689,6 +1689,11 @@ typedef struct { #define BTA_BLE_GAP_PATH_LOSS_THRESHOLD_EVT BTM_BLE_GAP_PATH_LOSS_THRESHOLD_EVT #define BTA_BLE_GAP_TRANMIT_POWER_REPORTING_EVT BTM_BLE_GAP_TRANMIT_POWER_REPORTING_EVT #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define BTA_BLE_GAP_SET_DEFAULT_SUBRATE_EVT BTM_BLE_GAP_SET_DEFAULT_SUBRATE_EVT +#define BTA_BLE_GAP_SUBRATE_REQUEST_EVT BTM_BLE_GAP_SUBRATE_REQUEST_EVT +#define BTA_BLE_GAP_SUBRATE_CHANGE_EVT BTM_BLE_GAP_SUBRATE_CHANGE_EVT +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) #define BTA_DM_BLE_5_GAP_UNKNOWN_EVT BTM_BLE_5_GAP_UNKNOWN_EVT typedef tBTM_BLE_5_GAP_EVENT tBTA_DM_BLE_5_GAP_EVENT; @@ -3072,6 +3077,12 @@ void BTA_DmBleGapSetPathLossRptParams(uint16_t conn_handle, uint8_t high_thresho void BTA_DmBleGapSetPathLossRptEnable(uint16_t conn_handle, uint8_t enable); void BTA_DmBleGapSetTransPwrRptEnable(uint16_t conn_handle, uint8_t local_enable, uint8_t remote_enable); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void BTA_DmBleGapSetDefaultSubrate(uint16_t subrate_min, uint16_t subrate_max, uint16_t max_latency, + uint16_t continuation_number, uint16_t supervision_timeout); +void BTA_DmBleGapSubrateReqest(uint16_t conn_handle, uint16_t subrate_min, uint16_t subrate_max, + uint16_t max_latency, uint16_t continuation_number, uint16_t supervision_timeout); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 7f1e74dfa1..c5c5e8ef9d 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1251,6 +1251,25 @@ static void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.trans_power_report_evt.delta = params->trans_pwr_report_evt.delta; break; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case BTA_BLE_GAP_SET_DEFAULT_SUBRATE_EVT: + msg.act = ESP_GAP_BLE_SET_DEFAULT_SUBRATE_COMPLETE_EVT; + param.set_default_subrate_evt.status = btc_btm_status_to_esp_status(params->status); + break; + case BTA_BLE_GAP_SUBRATE_REQUEST_EVT: + msg.act = ESP_GAP_BLE_SUBRATE_REQUEST_COMPLETE_EVT; + param.subrate_req_cmpl_evt.status = btc_btm_status_to_esp_status(params->status); + break; + case BTA_BLE_GAP_SUBRATE_CHANGE_EVT: + msg.act = ESP_GAP_BLE_SUBRATE_CHANGE_EVT; + param.subrate_change_evt.status = btc_btm_status_to_esp_status(params->subrate_change_evt.status); + param.subrate_change_evt.conn_handle = params->subrate_change_evt.conn_handle; + param.subrate_change_evt.subrate_factor = params->subrate_change_evt.subrate_factor; + param.subrate_change_evt.peripheral_latency = params->subrate_change_evt.peripheral_latency; + param.subrate_change_evt.continuation_number = params->subrate_change_evt.continuation_number; + param.subrate_change_evt.supervision_timeout = params->subrate_change_evt.supervision_timeout; + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) default: break; } @@ -2585,6 +2604,16 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmBleGapSetTransPwrRptEnable(arg_5->set_trans_pwr_rpting_en.conn_handle, arg_5->set_trans_pwr_rpting_en.local_enable, arg_5->set_trans_pwr_rpting_en.remote_enable); break; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case BTC_GAP_BLE_SET_DEFALT_SUBRATE: + BTA_DmBleGapSetDefaultSubrate(arg_5->default_subrate_param.subrate_min, arg_5->default_subrate_param.subrate_max, arg_5->default_subrate_param.max_latency, + arg_5->default_subrate_param.continuation_number, arg_5->default_subrate_param.supervision_timeout); + break; + case BTC_GAP_BLE_SUBRATE_REQUEST: + BTA_DmBleGapSubrateReqest(arg_5->subrate_req_param.conn_handle, arg_5->subrate_req_param.subrate_min, arg_5->subrate_req_param.subrate_max, + arg_5->subrate_req_param.max_latency, arg_5->subrate_req_param.continuation_number, arg_5->subrate_req_param.supervision_timeout); + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) default: break; } diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 0398544769..56e0e734ab 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -129,6 +129,10 @@ typedef enum { BTC_GAP_BLE_SET_PATH_LOSS_REPORTING_EN, BTC_GAP_BLE_SET_TRANS_POWER_REPORTING_EN, #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + BTC_GAP_BLE_SET_DEFALT_SUBRATE, + BTC_GAP_BLE_SUBRATE_REQUEST, +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -496,6 +500,25 @@ typedef union { uint8_t remote_enable; } set_trans_pwr_rpting_en; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + // BTC_GAP_BLE_SET_DEFALT_SUBRATE + struct default_subrate_param_args { + uint16_t subrate_min; + uint16_t subrate_max; + uint16_t max_latency; + uint16_t continuation_number; + uint16_t supervision_timeout; + } default_subrate_param; + // BTC_GAP_BLE_SUBRATE_REQUEST + struct subrate_req_param_args { + uint16_t conn_handle; + uint16_t subrate_min; + uint16_t subrate_max; + uint16_t max_latency; + uint16_t continuation_number; + uint16_t supervision_timeout; + } subrate_req_param; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } btc_ble_5_gap_args_t; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index 750a00776f..3201ce67ee 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -300,6 +300,12 @@ #define UC_BT_BLE_FEAT_POWER_CONTROL FALSE #endif +#ifdef CONFIG_BT_BLE_FEAT_CONN_SUBRATING +#define UC_BT_BLE_FEAT_CONN_SUBRATING CONFIG_BT_BLE_FEAT_CONN_SUBRATING +#else +#define UC_BT_BLE_FEAT_CONN_SUBRATING FALSE +#endif + #ifdef CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL #define UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL CONFIG_BT_BLE_HIGH_DUTY_ADV_INTERVAL #else diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index 084ef739b5..0df3907fd5 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -371,6 +371,12 @@ #define BLE_FEAT_POWER_CONTROL_EN FALSE #endif +#if (UC_BT_BLE_FEAT_CONN_SUBRATING == TRUE) +#define BLE_FEAT_CONN_SUBRATING TRUE +#else +#define BLE_FEAT_CONN_SUBRATING FALSE +#endif + #if (UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL == TRUE) #define BLE_HIGH_DUTY_ADV_INTERVAL TRUE #else diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index a0006f8487..70474ee4d6 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -31,7 +31,7 @@ #include "osi/future.h" #include "config/stack_config.h" #if (BLE_50_FEATURE_SUPPORT == TRUE) -const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x03\xff\xff\xff\xff" }; +const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x07\xff\xff\xff\xff" }; #else const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" }; #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index a75d74e0f7..52ffbe113b 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -1663,3 +1663,47 @@ void btm_ble_transmit_power_report_evt(tBTM_BLE_TRANS_POWER_REPORT_EVT *params) } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void BTM_BleSetDefaultSubrate(UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, UINT16 continuation_number, UINT16 supervision_timeout) +{ + 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_subrate(subrate_min, subrate_max, max_latency, continuation_number, supervision_timeout)) != 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_GAP_SET_DEFAULT_SUBRATE_EVT, &cb_params); +} + +void BTM_BleSubrateRequest(UINT16 conn_handle, UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, UINT16 continuation_number, UINT16 supervision_timeout) +{ + btsnd_hcic_ble_subrate_request(conn_handle, subrate_min, subrate_max, max_latency, continuation_number, supervision_timeout); +} + +void btm_subrate_req_cmd_status(UINT8 status) +{ + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if (status != HCI_SUCCESS) { + status = (status | BTM_HCI_ERROR); + } + cb_params.status = status; + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SUBRATE_REQUEST_EVT, &cb_params); +} + +void btm_ble_subrate_change_evt(tBTM_BLE_SUBRATE_CHANGE_EVT *params) +{ + if (params->status != HCI_SUCCESS) { + params->status = (params->status | BTM_HCI_ERROR); + } + + BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_SUBRATE_CHANGE_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)params); +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index 8315767b54..ea67c89643 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -596,6 +596,9 @@ void btm_ble_cte_req_failed_evt(tBTM_BLE_CTE_REQ_FAILED_EVT *params); void btm_ble_path_loss_threshold_evt(tBTM_BLE_PATH_LOSS_THRESHOLD_EVT *params); void btm_ble_transmit_power_report_evt(tBTM_BLE_TRANS_POWER_REPORT_EVT *params); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void btm_ble_subrate_change_evt(tBTM_BLE_SUBRATE_CHANGE_EVT *params); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) /* #ifdef __cplusplus diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 5eb4374b7a..81244e87bf 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -1124,6 +1124,11 @@ void btm_ble_big_sync_terminate_complete(UINT8 hci_status, UINT8 big_handle); void btm_enh_read_trans_pwr_level_cmpl_evt(uint8_t *p); void btm_read_remote_trans_pwr_level_cmpl(UINT8 status); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void btm_subrate_req_cmd_status(UINT8 status); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + /* Internal functions provided by btm_sco.c ******************************************** */ diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index c6925b9aa6..53fdfba58a 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -224,6 +224,10 @@ static void btu_ble_path_loss_threshold_evt(UINT8 *p); static void btu_ble_transmit_power_report_evt(UINT8 *p); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +static void btu_ble_subrate_change_evt(UINT8 *p); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #if (BLE_42_ADV_EN == TRUE) extern osi_sem_t adv_enable_sem; extern osi_sem_t adv_data_sem; @@ -577,6 +581,11 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_ble_transmit_power_report_evt(p); break; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case HCI_BLE_SUBRATE_CHANGE_EVT: + btu_ble_subrate_change_evt(p); + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } break; #endif /* BLE_INCLUDED */ @@ -1580,6 +1589,11 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_read_remote_trans_pwr_level_cmpl(status); break; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + case HCI_BLE_SUBRATE_REQUEST: + btm_subrate_req_cmd_status(status); + break; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) default: /* If command failed to start, we may need to tell BTM */ if (status != HCI_SUCCESS) { @@ -3046,6 +3060,26 @@ static void btu_ble_transmit_power_report_evt(UINT8 *p) } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +static void btu_ble_subrate_change_evt(UINT8 *p) +{ + tBTM_BLE_SUBRATE_CHANGE_EVT subrate_change_evt = {0}; + if (!p) { + HCI_TRACE_ERROR("%s, Invalid params.", __func__); + return; + } + + STREAM_TO_UINT8(subrate_change_evt.status, p); + STREAM_TO_UINT16(subrate_change_evt.conn_handle, p); + STREAM_TO_UINT16(subrate_change_evt.subrate_factor, p); + STREAM_TO_UINT16(subrate_change_evt.peripheral_latency, p); + STREAM_TO_UINT16(subrate_change_evt.continuation_number, p); + STREAM_TO_UINT16(subrate_change_evt.supervision_timeout, p); + + btm_ble_subrate_change_evt(&subrate_change_evt); +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + /********************************************** ** End of BLE Events Handler ***********************************************/ diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index c643cd0457..5ce942bd1f 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -2750,3 +2750,57 @@ UINT8 btsnd_hcic_ble_set_trans_pwr_rpt_enable(uint16_t conn_handle, uint8_t loca return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +UINT8 btsnd_hcic_ble_set_default_subrate(UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, + UINT16 continuation_number, UINT16 supervision_timeout) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("hci set default subrate, subrate_min %d subrate_max %d max_latency %d continuation_number %d supervision_timeout %d", + subrate_min, subrate_max, max_latency, continuation_number, supervision_timeout); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SUBRATE_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_SUBRATE); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_DEFAULT_SUBRATE_PARAMS_LEN); + + 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); + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_subrate_request(UINT16 conn_handle, UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, + UINT16 continuation_number, UINT16 supervision_timeout) +{ + BT_HDR *p; + UINT8 *pp; + + HCI_TRACE_DEBUG("hci subrate req, conn_handle %d subrate_min %d subrate_max %d max_latency %d continuation_number %d supervision_timeout %d", + conn_handle, subrate_min, subrate_max, max_latency, continuation_number, supervision_timeout); + + HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SUBRATE_REQ_LENGTH_PARAMS_LEN); + + pp = (UINT8 *)(p + 1); + + UINT16_TO_STREAM(pp, HCI_BLE_SUBRATE_REQUEST); + UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SUBRATE_REQ_LENGTH_PARAMS_LEN); + + UINT16_TO_STREAM(pp, conn_handle); + 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); + + btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p); + return TRUE; +} +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index 5f68f02f7a..4d52f936f5 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -1081,7 +1081,12 @@ typedef void (tBTM_SET_VENDOR_EVT_MASK_CBACK) (tBTM_STATUS status); #define BTM_BLE_GAP_PATH_LOSS_THRESHOLD_EVT 46 #define BTM_BLE_GAP_TRANMIT_POWER_REPORTING_EVT 47 #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) -#define BTM_BLE_5_GAP_UNKNOWN_EVT 50 +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define BTM_BLE_GAP_SET_DEFAULT_SUBRATE_EVT 48 +#define BTM_BLE_GAP_SUBRATE_REQUEST_EVT 49 +#define BTM_BLE_GAP_SUBRATE_CHANGE_EVT 50 +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define BTM_BLE_5_GAP_UNKNOWN_EVT 51 typedef UINT8 tBTM_BLE_5_GAP_EVENT; #if (BLE_FEAT_ISO_EN == TRUE) @@ -1431,9 +1436,19 @@ typedef struct { UINT8 tx_power_level_flag; INT8 delta; } __attribute__((packed)) tBTM_BLE_TRANS_POWER_REPORT_EVT; - #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +typedef struct { + UINT8 status; + UINT16 conn_handle; + UINT16 subrate_factor; + UINT16 peripheral_latency; + UINT16 continuation_number; + UINT16 supervision_timeout; +} __attribute__((packed)) tBTM_BLE_SUBRATE_CHANGE_EVT; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE) typedef struct { @@ -1797,6 +1812,9 @@ typedef union { tBTM_BLE_PATH_LOSS_THRESHOLD_EVT path_loss_thres_evt; tBTM_BLE_TRANS_POWER_REPORT_EVT trans_pwr_report_evt; #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) + tBTM_BLE_SUBRATE_CHANGE_EVT subrate_change_evt; +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) } tBTM_BLE_5_GAP_CB_PARAMS; typedef struct { @@ -3330,4 +3348,12 @@ void BTM_BleSetPathLossRptEnable(uint16_t conn_handle, uint8_t enable); void BTM_BleSetTransPwrRptEnable(uint16_t conn_handle, uint8_t local_enable, uint8_t remote_enable); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +void BTM_BleSetDefaultSubrate(UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, + UINT16 continuation_number, UINT16 supervision_timeout); + +void BTM_BleSubrateRequest(UINT16 conn_handle, UINT16 subrate_min, UINT16 subrate_max, + UINT16 max_latency, UINT16 continuation_number, UINT16 supervision_timeout); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #endif diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index f2cdd6c06c..1ad0b56d00 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -438,6 +438,11 @@ #define HCI_BLE_SET_TRANS_POWER_REPORTING_ENABLE (0x007A | HCI_GRP_BLE_CMDS) #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define HCI_BLE_SET_DEFAULT_SUBRATE (0x007D | HCI_GRP_BLE_CMDS) +#define HCI_BLE_SUBRATE_REQUEST (0x007E | HCI_GRP_BLE_CMDS) +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + // Vendor OGF define #define HCI_VENDOR_OGF 0x3F @@ -909,6 +914,10 @@ #define HCI_BLE_TRANS_POWER_REPORTING_EVT 0x21 #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define HCI_BLE_SUBRATE_CHANGE_EVT 0x23 +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + /* Definitions for LE Channel Map */ #define HCI_BLE_CHNL_MAP_SIZE 5 diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index 25deeeabc5..60635a48ee 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -1230,4 +1230,15 @@ UINT8 btsnd_hcic_ble_set_path_loss_rpt_params(uint16_t conn_handle, uint8_t high UINT8 btsnd_hcic_ble_set_path_loss_rpt_enable(uint16_t conn_handle, uint8_t enable); UINT8 btsnd_hcic_ble_set_trans_pwr_rpt_enable(uint16_t conn_handle, uint8_t local_enable, uint8_t remote_enable); #endif // #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) + +#if (BLE_FEAT_CONN_SUBRATING == TRUE) +#define HCIC_PARAM_SIZE_SET_DEFAULT_SUBRATE_PARAMS_LEN 10 +#define HCIC_PARAM_SIZE_SUBRATE_REQ_LENGTH_PARAMS_LEN 12 +UINT8 btsnd_hcic_ble_set_default_subrate(UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, + UINT16 continuation_number, UINT16 supervision_timeout); + +UINT8 btsnd_hcic_ble_subrate_request(UINT16 conn_handle, UINT16 subrate_min, UINT16 subrate_max, UINT16 max_latency, + UINT16 continuation_number, UINT16 supervision_timeout); +#endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #endif