فهرست منبع

Merge branch 'feature/new_gap_char' into 'master'

Enable characteristic 0x2A04 in GAP service

See merge request espressif/esp-idf!5809
Jiang Jiang Jian 6 سال پیش
والد
کامیت
0be0859e73

+ 8 - 0
components/bt/host/bluedroid/Kconfig.in

@@ -121,6 +121,14 @@ config BT_GATTS_ENABLE
     help
     help
         This option can be disabled when the app work only on gatt client mode
         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
 choice BT_GATTS_SEND_SERVICE_CHANGE_MODE
     prompt "GATTS Service Change Mode"
     prompt "GATTS Service Change Mode"
     default BT_GATTS_SEND_SERVICE_CHANGE_AUTO
     default BT_GATTS_SEND_SERVICE_CHANGE_AUTO

+ 6 - 0
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.conn_int_max,
                              p_data->ble_set_conn_params.slave_latency,
                              p_data->ble_set_conn_params.slave_latency,
                              p_data->ble_set_conn_params.supervision_tout);
                              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.latency,
                                   p_data->ble_update_conn_params.timeout)) {
                                   p_data->ble_update_conn_params.timeout)) {
         APPL_TRACE_ERROR("Update connection parameters failed!");
         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);
     }
     }
 }
 }
 /*******************************************************************************
 /*******************************************************************************

+ 6 - 0
components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h

@@ -159,6 +159,12 @@
 #define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK   FALSE
 #define UC_BT_BLE_HOST_QUEUE_CONGESTION_CHECK   FALSE
 #endif
 #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
 #ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE    CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE    CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #else
 #else

+ 4 - 0
components/bt/host/bluedroid/common/include/common/bt_target.h

@@ -383,6 +383,10 @@
 #define SCAN_QUEUE_CONGEST_CHECK  FALSE
 #define SCAN_QUEUE_CONGEST_CHECK  FALSE
 #endif
 #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
 #ifdef UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #define GATTS_SEND_SERVICE_CHANGE_MODE UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #define GATTS_SEND_SERVICE_CHANGE_MODE UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE
 #endif
 #endif

+ 28 - 0
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__);
     BTM_TRACE_ERROR("%s\n", __func__);
 #endif
 #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
 ** Function          BTM_BleMaxMultiAdvInstanceCount

+ 14 - 0
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);
 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
 ** Function         BTM_BleLocalPrivacyEnabled