]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: modify close event and disconnection event params
authorzhiweijian <zhiweijian@espressif.com>
Mon, 16 Oct 2017 08:27:38 +0000 (16:27 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Wed, 1 Nov 2017 02:40:03 +0000 (10:40 +0800)
- modify close event params
- modify disconnection event params
- modify connect event params

12 files changed:
components/bt/bluedroid/api/include/esp_gattc_api.h
components/bt/bluedroid/api/include/esp_gatts_api.h
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
components/bt/bluedroid/bta/include/bta_gatt_api.h
components/bt/bluedroid/bta/include/bta_gattc_int.h
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c
components/bt/bluedroid/btc/profile/std/gatt/btc_gatts.c
examples/bluetooth/ble_spp_client/main/spp_client_demo.c
examples/bluetooth/gatt_client/main/gattc_demo.c
examples/bluetooth/gatt_security_client/main/example_ble_sec_gattc_demo.c
examples/bluetooth/gatt_server/main/gatts_demo.c

index b72466b82c1c64d1067f7e910629578cb8dc4f64..6a6aa579cfcd255820cca4f515448617ca5258d6 100644 (file)
@@ -201,7 +201,6 @@ typedef union {
      * @brief ESP_GATTC_CONNECT_EVT
      */
     struct gattc_connect_evt_param {
-        esp_gatt_status_t status;       /*!< Operation status */
         uint16_t conn_id;               /*!< Connection id */
         esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
     } connect;                          /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
@@ -210,7 +209,7 @@ typedef union {
      * @brief ESP_GATTC_DISCONNECT_EVT
      */
     struct gattc_disconnect_evt_param {
-        esp_gatt_status_t status;       /*!< Operation status */
+        esp_gatt_conn_reason_t reason;  /*!< disconnection reason */
         uint16_t conn_id;               /*!< Connection id */
         esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
     } disconnect;                       /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
index d964ac9b9dc8b068ed4952fabc0117e641191a35..87869bb6fe0c67d4b57d56507c9a7bb1497a0bc5 100644 (file)
@@ -193,7 +193,6 @@ typedef union {
     struct gatts_connect_evt_param {
         uint16_t conn_id;               /*!< Connection id */
         esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
-        bool is_connected;              /*!< Indicate it is connected or not */
     } connect;                          /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
 
     /**
@@ -202,7 +201,7 @@ typedef union {
     struct gatts_disconnect_evt_param {
         uint16_t conn_id;               /*!< Connection id */
         esp_bd_addr_t remote_bda;       /*!< Remote bluetooth device address */
-        bool is_connected;              /*!< Indicate it is connected or not */
+        esp_gatt_conn_reason_t reason;  /*!< Indicate the reason of disconnection */
     } disconnect;                       /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */
 
     /**
index 25814059bcd8bd813fc605fae5cff497ceb4c536..1a9306001c30f6ef68f5b0dbb55788aba3c58a58 100644 (file)
@@ -711,7 +711,6 @@ void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
 {
     if (p_rcb) {
         bta_gattc_send_connect_cback(p_rcb,
-                                     BTA_GATT_OK,
                                      p_data->int_conn.remote_bda,
                                      p_data->int_conn.hdr.layer_specific);
 
@@ -730,7 +729,7 @@ void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
 {
     if (p_rcb) {
         bta_gattc_send_disconnect_cback(p_rcb,
-                                     BTA_GATT_OK,
+                                     p_data->int_conn.reason,
                                      p_data->int_conn.remote_bda,
                                      p_data->int_conn.hdr.layer_specific);
 
@@ -793,7 +792,7 @@ void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
     if (p_data->hdr.event == BTA_GATTC_API_CLOSE_EVT) {
         cb_data.close.status = GATT_Disconnect(p_data->hdr.layer_specific);
     } else if (p_data->hdr.event == BTA_GATTC_INT_DISCONN_EVT) {
-        cb_data.close.status = p_data->int_conn.reason;
+        cb_data.close.status = BTA_GATT_OK;
         cb_data.close.reason = p_data->int_conn.reason;
     }
 
index dfa685f67dba4858538e967f93757ebe84dc738d..864a85fe8ec8ee006de8f8c806942cd83268b64c 100644 (file)
@@ -653,15 +653,13 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
 ** Returns
 **
 *******************************************************************************/
-void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
-                                BD_ADDR remote_bda, UINT16 conn_id)
+void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id)
 {
     tBTA_GATTC      cb_data;
 
     if (p_clreg->p_cback) {
         memset(&cb_data, 0, sizeof(tBTA_GATTC));
 
-        cb_data.connect.status = status;
         cb_data.connect.client_if = p_clreg->client_if;
         cb_data.connect.conn_id = conn_id;
         bdcpy(cb_data.connect.remote_bda, remote_bda);
@@ -679,7 +677,7 @@ void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS sta
 ** Returns
 **
 *******************************************************************************/
-void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason,
                                 BD_ADDR remote_bda, UINT16 conn_id)
 {
     tBTA_GATTC      cb_data;
@@ -687,7 +685,7 @@ void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS
     if (p_clreg->p_cback) {
         memset(&cb_data, 0, sizeof(tBTA_GATTC));
 
-        cb_data.disconnect.status = status;
+        cb_data.disconnect.reason = reason;
         cb_data.disconnect.client_if = p_clreg->client_if;
         cb_data.disconnect.conn_id = conn_id;
         bdcpy(cb_data.disconnect.remote_bda, remote_bda);
index 35fb42d71acb1422bac06d5f8172d4da8379861d..6c17368f5e536860a7201e39e285f62564af8c3a 100644 (file)
@@ -367,14 +367,13 @@ typedef struct {
 } tBTA_GATTC_ENC_CMPL_CB;
 
 typedef struct {
-    tBTA_GATT_STATUS    status;
     UINT16              conn_id;
     tBTA_GATTC_IF       client_if;
     BD_ADDR             remote_bda;
 } tBTA_GATTC_CONNECT;
 
 typedef struct {
-    tBTA_GATT_STATUS    status;
+    tGATT_DISCONN_REASON reason;
     UINT16              conn_id;
     tBTA_GATTC_IF       client_if;
     BD_ADDR             remote_bda;
index 3a1e719159518c2fb66895e856a0ea923acbccc1..f54c0fbee70b4740b320d31b9f6e7e78d4836918 100644 (file)
@@ -438,9 +438,8 @@ extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *
 extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
 extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
                                        BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport,  UINT16 mtu);
-extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
-                                BD_ADDR remote_bda, UINT16 conn_id);
-extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id);
+extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason,
                                 BD_ADDR remote_bda, UINT16 conn_id);
 extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
 extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
index d3149bf8520ff1d0359297f39eec6b6ec0e2cd14..5b33f0f77c0fb8926e5ada902e7c503e5c4a2a6e 100644 (file)
@@ -858,7 +858,6 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
         tBTA_GATTC_CONNECT *connect = &arg->connect;
 
         gattc_if = connect->client_if;
-        param.connect.status = connect->status;
         param.connect.conn_id = BTC_GATT_GET_CONN_ID(connect->conn_id);
         memcpy(param.connect.remote_bda, connect->remote_bda, sizeof(esp_bd_addr_t));
         btc_gattc_cb_to_app(ESP_GATTC_CONNECT_EVT, gattc_if, &param);
@@ -879,7 +878,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
         tBTA_GATTC_DISCONNECT *disconnect = &arg->disconnect;
 
         gattc_if = disconnect->client_if;
-        param.disconnect.status = disconnect->status;
+        param.disconnect.reason = disconnect->reason;
         param.disconnect.conn_id = BTC_GATT_GET_CONN_ID(disconnect->conn_id);
         memcpy(param.disconnect.remote_bda, disconnect->remote_bda, sizeof(esp_bd_addr_t));
         btc_gattc_cb_to_app(ESP_GATTC_DISCONNECT_EVT, gattc_if, &param);
index df2d742127caea9189a67dd2b5cbc4ce3ca230ca..75c53b893892ad3993abdf3c6fedce9b33737be7 100644 (file)
@@ -849,7 +849,6 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
     case BTA_GATTS_CONNECT_EVT:
         gatts_if = p_data->conn.server_if;
         param.connect.conn_id = BTC_GATT_GET_CONN_ID(p_data->conn.conn_id);
-        param.connect.is_connected = true;
         memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
 
         btc_gatts_cb_to_app(ESP_GATTS_CONNECT_EVT, gatts_if, &param);
@@ -857,7 +856,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
     case BTA_GATTS_DISCONNECT_EVT:
         gatts_if = p_data->conn.server_if;
         param.disconnect.conn_id = BTC_GATT_GET_CONN_ID(p_data->conn.conn_id);
-        param.disconnect.is_connected = false;
+        param.disconnect.reason = p_data->conn.reason;
         memcpy(param.disconnect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
 
         btc_gatts_cb_to_app(ESP_GATTS_DISCONNECT_EVT, gatts_if, &param);
index 7b570eaf4046971097ed58ea362b32876ddaf3d8..9eadc13b7f1e7dcf4fdbc9daf97d17ee66046a53 100644 (file)
@@ -698,21 +698,17 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
         esp_ble_gap_set_scan_params(&ble_scan_params);
         break;
     case ESP_GATTC_CONNECT_EVT:
-        if(p_data->connect.status != ESP_GATT_OK){
-            ESP_LOGI(GATTC_TAG, "connect fail, status = %d", p_data->connect.status);
-            break;
-        }
         spp_gattc_if = gattc_if;
         is_connect = true;
         spp_conn_id = p_data->connect.conn_id;
         memcpy(gl_profile_tab[PROFILE_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));
-        ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT: conn_id=%d, gatt_if = %d, status =%d", spp_conn_id, gattc_if, p_data->connect.status);
+        ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT: conn_id=%d, gatt_if = %d", spp_conn_id, gattc_if);
         ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
         esp_log_buffer_hex(GATTC_TAG, gl_profile_tab[PROFILE_APP_ID].remote_bda, sizeof(esp_bd_addr_t));
         esp_ble_gattc_search_service(gattc_if, spp_conn_id, NULL);
         break;
     case ESP_GATTC_DISCONNECT_EVT:
-        ESP_LOGI(GATTC_TAG, "disconnect , status = %d", p_data->disconnect.status);
+        ESP_LOGI(GATTC_TAG, "disconnect");
         free_gattc_srv_db();
         esp_ble_gap_start_scanning(0xffff);
         break;
index 14290c2d870086b5d78b6b83d2e755b8f2c94ae8..a2be74da52242ae5615a18a285de996716a7683d 100644 (file)
@@ -112,8 +112,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
         }
         break;
     case ESP_GATTC_CONNECT_EVT:{
-        //p_data->connect.status always be ESP_GATT_OK
-        ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT conn_id %d, if %d, status %d", p_data->connect.conn_id, gattc_if, p_data->connect.status);
+        ESP_LOGI(GATTC_TAG, "ESP_GATTC_CONNECT_EVT conn_id %d, if %d", p_data->connect.conn_id, gattc_if);
         gl_profile_tab[PROFILE_A_APP_ID].conn_id = p_data->connect.conn_id;
         memcpy(gl_profile_tab[PROFILE_A_APP_ID].remote_bda, p_data->connect.remote_bda, sizeof(esp_bd_addr_t));
         ESP_LOGI(GATTC_TAG, "REMOTE BDA:");
@@ -296,7 +295,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
     case ESP_GATTC_DISCONNECT_EVT:
         connect = false;
         get_server = false;
-        ESP_LOGI(GATTC_TAG, "ESP_GATTC_DISCONNECT_EVT, status = %d", p_data->disconnect.status);
+        ESP_LOGI(GATTC_TAG, "ESP_GATTC_DISCONNECT_EVT, reason = %d", p_data->disconnect.reason);
         break;
     default:
         break;
index 6ae360e654a1db3f180380e70e2a65fe80172148..7838dd89dde036088b7d9c13ae4be7894039611d 100644 (file)
@@ -306,7 +306,7 @@ static void gattc_profile_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
         ESP_LOGI(GATTC_TAG, "Write char success ");
         break;
     case ESP_GATTC_DISCONNECT_EVT:
-        ESP_LOGI(GATTC_TAG, "ESP_GATTC_DISCONNECT_EVT, status = %d", p_data->disconnect.status);
+        ESP_LOGI(GATTC_TAG, "ESP_GATTC_DISCONNECT_EVT, reason = %d", p_data->disconnect.reason);
         connect = false;
         get_service = false;
         break;
index a60d567c86b14304c7b7a793a2c4e4ab901d6bd7..885702e9fec906fb871702994f0821db699c11af 100644 (file)
@@ -478,11 +478,10 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
         conn_params.max_int = 0x20;    // max_int = 0x20*1.25ms = 40ms
         conn_params.min_int = 0x10;    // min_int = 0x10*1.25ms = 20ms
         conn_params.timeout = 400;    // timeout = 400*10ms = 4000ms
-        ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONNECT_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:, is_conn %d",
+        ESP_LOGI(GATTS_TAG, "ESP_GATTS_CONNECT_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:",
                  param->connect.conn_id,
                  param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2],
-                 param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5],
-                 param->connect.is_connected);
+                 param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5]);
         gl_profile_tab[PROFILE_A_APP_ID].conn_id = param->connect.conn_id;
         //start sent the update connection parameters to the peer device.
         esp_ble_gap_update_conn_params(&conn_params);
@@ -624,11 +623,10 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
     case ESP_GATTS_STOP_EVT:
         break;
     case ESP_GATTS_CONNECT_EVT:
-        ESP_LOGI(GATTS_TAG, "CONNECT_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:, is_conn %d",
+        ESP_LOGI(GATTS_TAG, "CONNECT_EVT, conn_id %d, remote %02x:%02x:%02x:%02x:%02x:%02x:",
                  param->connect.conn_id,
                  param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2],
-                 param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5],
-                 param->connect.is_connected);
+                 param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5]);
         gl_profile_tab[PROFILE_B_APP_ID].conn_id = param->connect.conn_id;
         break;
     case ESP_GATTS_DISCONNECT_EVT: