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 067de4d9871..311c5d281ca 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -154,8 +154,8 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params) return ESP_FAIL; } - if (ESP_BLE_IS_VALID_PARAM(params->min_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(params->max_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(params->min_int, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(params->max_int, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(params->timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((params->timeout * 10) >= ((1 + params->latency) * ((params->max_int * 5) >> 1))) && params->min_int <= params->max_int) { @@ -393,8 +393,8 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr, return ESP_ERR_INVALID_ARG; } - if (ESP_BLE_IS_VALID_PARAM(min_conn_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(max_conn_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(min_conn_int, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(max_conn_int, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(supervision_tout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (slave_latency <= ESP_BLE_CONN_LATENCY_MAX) && ((supervision_tout * 10) >= ((1 + slave_latency) * ((max_conn_int * 5) >> 1))) && min_conn_int <= max_conn_int) { @@ -1747,8 +1747,8 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, return ESP_ERR_INVALID_ARG; } - if (ESP_BLE_IS_VALID_PARAM(phy_1m_conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(phy_1m_conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(phy_1m_conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(phy_1m_conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(phy_1m_conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (phy_1m_conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((phy_1m_conn_params->supervision_timeout * 10) >= ((1 + phy_1m_conn_params->latency) * ((phy_1m_conn_params->interval_max * 5) >> 1))) && @@ -1771,8 +1771,8 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, return ESP_ERR_INVALID_ARG; } - if (ESP_BLE_IS_VALID_PARAM(phy_2m_conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(phy_2m_conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(phy_2m_conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(phy_2m_conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(phy_2m_conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (phy_2m_conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((phy_2m_conn_params->supervision_timeout * 10) >= ((1 + phy_2m_conn_params->latency) * ((phy_2m_conn_params->interval_max * 5) >> 1))) && @@ -1795,8 +1795,8 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, return ESP_ERR_INVALID_ARG; } - if (ESP_BLE_IS_VALID_PARAM(phy_coded_conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(phy_coded_conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(phy_coded_conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(phy_coded_conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(phy_coded_conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (phy_coded_conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((phy_coded_conn_params->supervision_timeout * 10) >= ((1 + phy_coded_conn_params->latency) * ((phy_coded_conn_params->interval_max * 5) >> 1))) && diff --git a/components/bt/host/bluedroid/api/esp_gattc_api.c b/components/bt/host/bluedroid/api/esp_gattc_api.c index b0d2458ca3c..0e2befd18d7 100644 --- a/components/bt/host/bluedroid/api/esp_gattc_api.c +++ b/components/bt/host/bluedroid/api/esp_gattc_api.c @@ -115,8 +115,8 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn } conn_params = creat_conn_params->phy_1m_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && @@ -138,8 +138,8 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn } conn_params = creat_conn_params->phy_2m_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && @@ -161,8 +161,8 @@ esp_err_t esp_ble_gattc_enh_open(esp_gatt_if_t gattc_if, esp_ble_gatt_creat_conn } conn_params = creat_conn_params->phy_coded_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && @@ -251,8 +251,8 @@ esp_err_t esp_ble_gattc_aux_open_with_pawr_synced(esp_gatt_if_t gattc_if, esp_bl } conn_params = pawr_conn_params->phy_1m_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && @@ -274,8 +274,8 @@ esp_err_t esp_ble_gattc_aux_open_with_pawr_synced(esp_gatt_if_t gattc_if, esp_bl } conn_params = pawr_conn_params->phy_2m_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && @@ -297,8 +297,8 @@ esp_err_t esp_ble_gattc_aux_open_with_pawr_synced(esp_gatt_if_t gattc_if, esp_bl } conn_params = pawr_conn_params->phy_coded_conn_params; - if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && - ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) && + if (ESP_BLE_IS_VALID_PARAM(conn_params->interval_min, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && + ESP_BLE_IS_VALID_PARAM(conn_params->interval_max, BLE_CONN_INT_MIN_HOST_CHECK, ESP_BLE_CONN_INT_MAX) && ESP_BLE_IS_VALID_PARAM(conn_params->supervision_timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) && (conn_params->latency <= ESP_BLE_CONN_LATENCY_MAX) && ((conn_params->supervision_timeout * 10) >= ((1 + conn_params->latency) * ((conn_params->interval_max * 5) >> 1))) && diff --git a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h index e4c9b9719db..bd4b2c7e763 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h +++ b/components/bt/host/bluedroid/api/include/api/esp_bt_defs.h @@ -216,12 +216,11 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */ #define ESP_BLE_PRIM_ADV_INT_MIN 0x000020 /*!< Minimum advertising interval for undirected and low duty cycle directed advertising */ #endif #define ESP_BLE_PRIM_ADV_INT_MAX 0xFFFFFF /*!< Maximum advertising interval for undirected and low duty cycle directed advertising */ -/* Lower bound (1.25 ms units) for host-side connection interval checks.*/ -#if defined(CONFIG_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT) && (CONFIG_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT) -#define ESP_BLE_CONN_INT_MIN 0x0001 -#else -#define ESP_BLE_CONN_INT_MIN 0x0006 -#endif +/* Public API constant pinned to the Bluetooth Core Spec minimum (7.5 ms). + * Applications that want a sub-spec connection interval must pass the + * desired value as an integer literal; whether it is actually accepted + * depends on the controller. */ +#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< Minimum connection interval, 7.5 ms (BLE Core Spec minimum) */ #define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */ #define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */ #define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */ @@ -238,8 +237,8 @@ typedef uint8_t esp_ble_phy_mask_t; typedef struct { uint16_t scan_interval; /*!< Initial scan interval, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ uint16_t scan_window; /*!< Initial scan window, in units of 0.625ms, the range is 0x0004(2.5ms) to 0xFFFF(10.24s). */ - uint16_t interval_min; /*!< Minimum connection interval, in units of 1.25 ms. Host validation uses ESP_BLE_CONN_INT_MIN as the lower bound; the interval the controller ultimately allows may be higher depending on its capability. Upper bound 0x0C80 (4 s). */ - uint16_t interval_max; /*!< Maximum connection interval, in units of 1.25 ms. Same bounds as interval_min. */ + uint16_t interval_min; /*!< Minimum connection interval, in units of 1.25 ms, the range is 0x0006(7.5ms) to 0x0C80(4s). Sub-spec values are accepted only if the controller supports them. */ + uint16_t interval_max; /*!< Maximum connection interval, in units of 1.25 ms, the range is 0x0006(7.5ms) to 0x0C80(4s). Same bounds as interval_min. */ uint16_t latency; /*!< Connection latency, the range is 0x0000(0) to 0x01F3(499). */ uint16_t supervision_timeout; /*!< Connection supervision timeout, in units of 10ms, the range is from 0x000A(100ms) to 0x0C80(32s). */ uint16_t min_ce_len; /*!< Minimum connection event length, in units of 0.625ms, setting to 0 for no preferred parameters. */ 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 76ce330e529..b886849626b 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 @@ -1958,7 +1958,7 @@ static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int, min_int = max_int; } - if (min_int < BTM_BLE_CONN_INT_MIN || max_int > BTM_BLE_CONN_INT_MAX) { + if (min_int < BLE_CONN_INT_MIN_HOST_CHECK || max_int > BTM_BLE_CONN_INT_MAX) { BTC_TRACE_ERROR("Invalid interval value.\n"); } 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 07bd62f1684..7caa9e6261a 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 @@ -382,19 +382,12 @@ #define UC_BT_BLE_HIGH_DUTY_ADV_INTERVAL FALSE #endif -/* Controls whether the Bluedroid host enforces the Bluetooth Core - * specification minimum BLE connection interval (0x0006 / 7.5 ms) during - * host-side parameter validation. - * - * - 1 : host-side lower bound is relaxed to 0x0001 (1.25 ms). The real - * lower bound is then enforced solely by the BLE controller. - * - 0 : host enforces the Bluetooth Core spec minimum (0x0006). +/* When set to 1, the Bluedroid host's parameter validation no longer enforces + * a minimum BLE connection interval; the actual lower limit is then left to + * the controller. See BLE_CONN_INT_MIN_HOST_CHECK in common/bt_target.h. * * Do not turn this on manually in menuconfig unless you know the implications. - * In normal IDF builds it follows the active Controller integration. The - * actual minimum connection interval is defined by the Controller, not by the - * Host; Controller configuration option names differ by chip and stack. - * See common/bt_target.h (BLE_CONN_INT_MIN_HW). */ + * In normal IDF builds it follows the active Controller integration. */ #ifdef CONFIG_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT #define UC_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT 1 #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 76f4a14ab06..99d6254d092 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -437,28 +437,21 @@ #define BLE_HIGH_DUTY_ADV_INTERVAL FALSE #endif -/* Minimum BLE connection interval (in 1.25 ms units) enforced by the Bluedroid - * host parameter validation. +/* Host-side parameter validation floor (in 1.25 ms units) for the BLE + * connection interval. Internal to the Bluedroid host: not sent on air, not + * exposed via the GATT Preferred Connection Parameters Characteristic, and + * not a public API constant - those use BTM_BLE_CONN_INT_MIN (0x0006). * - * - When host-side validation keeps the Core Spec floor: 0x0006 (7.5 ms). - * - When validation is relaxed for sub-spec intervals: 0x0001 (1.25 ms) so - * host-side checks no longer enforce the Core Spec minimum; whether a - * smaller connection interval is allowed and the real lower limit depend - * entirely on Controller capability and its own configuration (option - * names differ by Controller). Whether the relaxed mode is used is - * determined by how the Host is integrated with the Controller for each - * product, not documented here. - * - * Note: the relaxed lower bound is 0x0001 rather than 0x0000 so that all - * existing `uint16_t < MIN` / `uint16_t >= MIN` range checks in the stack - * remain well-defined under GCC `-Wtype-limits`. Since 0 is not a valid HCI - * connection interval anyway, this is functionally equivalent to disabling - * the host-side minimum check. */ -#ifndef BLE_CONN_INT_MIN_HW + * When UC_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT == 1 the host stops + * enforcing a minimum (the actual lower limit is then defined entirely by + * the controller). 0x0001 is used rather than 0x0000 so the existing + * `uint16_t < MIN` range checks remain well-defined under GCC + * `-Wtype-limits`. */ +#ifndef BLE_CONN_INT_MIN_HOST_CHECK #if (UC_BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT == 1) -#define BLE_CONN_INT_MIN_HW 0x0001 +#define BLE_CONN_INT_MIN_HOST_CHECK 0x0001 #else -#define BLE_CONN_INT_MIN_HW 0x0006 +#define BLE_CONN_INT_MIN_HOST_CHECK 0x0006 #endif #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index 71dcdc0768b..95b44c35889 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -578,8 +578,8 @@ void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, tout: %u", min_conn_int, max_conn_int, slave_latency, supervision_tout); - if (BTM_BLE_ISVALID_PARAM(min_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && - BTM_BLE_ISVALID_PARAM(max_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && + if (BTM_BLE_ISVALID_PARAM(min_conn_int, BLE_CONN_INT_MIN_HOST_CHECK, BTM_BLE_CONN_INT_MAX) && + BTM_BLE_ISVALID_PARAM(max_conn_int, BLE_CONN_INT_MIN_HOST_CHECK, BTM_BLE_CONN_INT_MAX) && BTM_BLE_ISVALID_PARAM(supervision_tout, BTM_BLE_CONN_SUP_TOUT_MIN, BTM_BLE_CONN_SUP_TOUT_MAX) && (slave_latency <= BTM_BLE_CONN_LATENCY_MAX || slave_latency == BTM_BLE_CONN_PARAM_UNDEF)) { if (p_dev_rec) { 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 27fdf5f5b2a..6084ffa6afa 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 @@ -122,7 +122,12 @@ typedef UINT8 tBTM_BLE_SFP; #define BTM_BLE_SCAN_INT_MAX 0x4000 #define BTM_BLE_SCAN_WIN_MIN 0x0004 #define BTM_BLE_SCAN_WIN_MAX 0x4000 -#define BTM_BLE_CONN_INT_MIN BLE_CONN_INT_MIN_HW /* host-side check limit; see BLE_CONN_INT_MIN_HW in common/bt_target.h */ +/* Bluetooth Core Spec minimum BLE connection interval (7.5 ms). Used inside + * the host stack wherever the on-air or interoperability semantics require + * the spec value. For host-side parameter validation (which can be relaxed + * to accept sub-spec intervals) use BLE_CONN_INT_MIN_HOST_CHECK from + * common/bt_target.h instead. */ +#define BTM_BLE_CONN_INT_MIN 0x0006 #define BTM_BLE_CONN_INT_MAX 0x0C80 #define BTM_BLE_CONN_LATENCY_MAX 499 #define BTM_BLE_CONN_SUP_TOUT_MIN 0x000A diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c index 817d0b94b83..65d4e643b06 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_ble.c @@ -377,9 +377,9 @@ void l2cble_scanner_conn_comp (UINT16 handle, BD_ADDR bda, tBLE_ADDR_TYPE type, p_lcb->ble_addr_type = type; /* If there are any preferred connection parameters, set them now */ - if ( (p_dev_rec->conn_params.min_conn_int >= BTM_BLE_CONN_INT_MIN ) && + if ( (p_dev_rec->conn_params.min_conn_int >= BLE_CONN_INT_MIN_HOST_CHECK ) && (p_dev_rec->conn_params.min_conn_int <= BTM_BLE_CONN_INT_MAX ) && - (p_dev_rec->conn_params.max_conn_int >= BTM_BLE_CONN_INT_MIN ) && + (p_dev_rec->conn_params.max_conn_int >= BLE_CONN_INT_MIN_HOST_CHECK ) && (p_dev_rec->conn_params.max_conn_int <= BTM_BLE_CONN_INT_MAX ) && (p_dev_rec->conn_params.slave_latency <= BTM_BLE_CONN_LATENCY_MAX ) && (p_dev_rec->conn_params.supervision_tout >= BTM_BLE_CONN_SUP_TOUT_MIN) && @@ -762,8 +762,8 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len) STREAM_TO_UINT16 (timeout, p); /* 0x000A - 0x0C80 */ /* If we are a master, the slave wants to update the parameters */ if (p_lcb->link_role == HCI_ROLE_MASTER) { - if (min_interval < BTM_BLE_CONN_INT_MIN || min_interval > BTM_BLE_CONN_INT_MAX || - max_interval < BTM_BLE_CONN_INT_MIN || max_interval > BTM_BLE_CONN_INT_MAX || + if (min_interval < BLE_CONN_INT_MIN_HOST_CHECK || min_interval > BTM_BLE_CONN_INT_MAX || + max_interval < BLE_CONN_INT_MIN_HOST_CHECK || max_interval > BTM_BLE_CONN_INT_MAX || latency > BTM_BLE_CONN_LATENCY_MAX || timeout < BTM_BLE_CONN_SUP_TOUT_MIN || timeout > BTM_BLE_CONN_SUP_TOUT_MAX || /* The supervision_timeout parameter defines the link supervision timeout for the connection.