diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 1d55516157..782c3793a3 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -121,6 +121,14 @@ config BT_GATTS_ENABLE help This option can be disabled when the app work only on gatt client mode +config BT_GATTS_PPCP_CHAR_GAP + bool "Enable Peripheral Preferred Connection Parameters characteristic in GAP service" + depends on BT_GATTS_ENABLE + default n + help + This enables "Peripheral Preferred Connection Parameters" characteristic (UUID: 0x2A04) in GAP service that has + connection parameters like min/max connection interval, slave latency and supervision timeout multiplier + choice BT_GATTS_SEND_SERVICE_CHANGE_MODE prompt "GATTS Service Change Mode" default BT_GATTS_SEND_SERVICE_CHANGE_AUTO 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 4081f9b420..9ceea1388e 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -4874,6 +4874,9 @@ void bta_dm_ble_set_conn_params (tBTA_DM_MSG *p_data) p_data->ble_set_conn_params.conn_int_max, p_data->ble_set_conn_params.slave_latency, p_data->ble_set_conn_params.supervision_tout); + + BTM_BleConfigConnParams(p_data->ble_set_conn_params.conn_int_min, p_data->ble_set_conn_params.conn_int_max, + p_data->ble_set_conn_params.slave_latency, p_data->ble_set_conn_params.supervision_tout); } /******************************************************************************* @@ -4958,6 +4961,9 @@ void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data) p_data->ble_update_conn_params.latency, p_data->ble_update_conn_params.timeout)) { APPL_TRACE_ERROR("Update connection parameters failed!"); + } else { + BTM_BleConfigConnParams(p_data->ble_update_conn_params.min_int, p_data->ble_update_conn_params.max_int, + p_data->ble_update_conn_params.latency, p_data->ble_update_conn_params.timeout); } } /******************************************************************************* 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 cd05ce5fac..63da318a86 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 @@ -159,6 +159,12 @@ #define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK FALSE #endif +#ifdef CONFIG_BT_GATTS_PPCP_CHAR_GAP +#define UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP CONFIG_BT_GATTS_PPCP_CHAR_GAP +#else +#define UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP FALSE +#endif + #ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE #define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE #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 a21b2764ee..309ea6b1d3 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -383,6 +383,10 @@ #define SCAN_QUEUE_CONGEST_CHECK FALSE #endif +#ifdef UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP +#define BTM_PERIPHERAL_ENABLED UC_CONFIG_BT_GATTS_PPCP_CHAR_GAP +#endif + #ifdef UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE #define GATTS_SEND_SERVICE_CHANGE_MODE UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 1ba597946f..0c337169b9 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -910,6 +910,34 @@ void BTM_BleConfigLocalIcon(uint16_t icon) BTM_TRACE_ERROR("%s\n", __func__); #endif } + +/******************************************************************************* +** +** Function BTM_BleConfigConnParams +** +** Description This function is called to set the connection parameters +** +** Parameters int_min: minimum connection interval +** int_max: maximum connection interval +** latency: slave latency +** timeout: supervision timeout +** +*******************************************************************************/ +void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout) +{ +#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE) + tGAP_BLE_ATTR_VALUE p_value; + + p_value.conn_param.int_min = int_min; + p_value.conn_param.int_max = int_max; + p_value.conn_param.latency = latency; + p_value.conn_param.sp_tout = timeout; + GAP_BleAttrDBUpdate(GATT_UUID_GAP_PREF_CONN_PARAM, &p_value); +#else + BTM_TRACE_ERROR("%s\n", __func__); +#endif +} + /******************************************************************************* ** ** Function BTM_BleMaxMultiAdvInstanceCount 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 a8900ec321..fe16d073ea 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 @@ -1718,6 +1718,20 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_l *******************************************************************************/ void BTM_BleConfigLocalIcon(uint16_t icon); +/******************************************************************************* +** +** Function BTM_BleConfigConnParams +** +** Description This function is called to set the connection parameters +** +** Parameters int_min: minimum connection interval +** int_max: maximum connection interval +** latency: slave latency +** timeout: supervision timeout +** +*******************************************************************************/ +void BTM_BleConfigConnParams(uint16_t int_min, uint16_t int_max, uint16_t latency, uint16_t timeout); + /******************************************************************************* ** ** Function BTM_BleLocalPrivacyEnabled