]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: fix service change event params error
authorzhiweijian <zhiweijian@espressif.com>
Thu, 29 Mar 2018 08:11:16 +0000 (16:11 +0800)
committerzhiweijian <zhiweijian@espressif.com>
Thu, 29 Mar 2018 08:11:16 +0000 (16:11 +0800)
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
components/bt/bluedroid/bta/include/bta_gatt_api.h
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c

index c9189b20df4d6a958c181b60620daff5d3df5155..9a9f153870690dc802b2debbd9844d59f2125f1a 100644 (file)
@@ -1837,7 +1837,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
         }
         /* notify applicationf or service change */
         if (p_clrcb->p_cback != NULL) {
-            (* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)p_srcb->server_bda);
+            tBTA_GATTC_SERVICE_CHANGE srvc_chg= {0};
+            memcpy(srvc_chg.remote_bda, p_srcb->server_bda, sizeof(BD_ADDR));
+            srvc_chg.conn_id = conn_id;
+            (* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)&srvc_chg);
         }
 
     }
index 95f681521646916a3593fed65a8a4437328d32b1..4410cea58a056906872510b4b64de0f4998b6654 100644 (file)
@@ -387,27 +387,30 @@ typedef struct {
     BD_ADDR             remote_bda;
 } tBTA_GATTC_DISCONNECT;
 
-
+typedef struct {
+    UINT16              conn_id;
+    BD_ADDR             remote_bda;
+} tBTA_GATTC_SERVICE_CHANGE;
 
 typedef union {
     tBTA_GATT_STATUS        status;
 
-    tBTA_GATTC_SEARCH_CMPL  search_cmpl;          /* discovery complete */
-    tBTA_GATTC_SRVC_RES     srvc_res;          /* discovery result */
-    tBTA_GATTC_REG          reg_oper;              /* registration data */
+    tBTA_GATTC_SEARCH_CMPL  search_cmpl;    /* discovery complete */
+    tBTA_GATTC_SRVC_RES     srvc_res;       /* discovery result */
+    tBTA_GATTC_REG          reg_oper;       /* registration data */
     tBTA_GATTC_OPEN         open;
     tBTA_GATTC_CONNECT      connect;
     tBTA_GATTC_CLOSE        close;
     tBTA_GATTC_DISCONNECT   disconnect;
-    tBTA_GATTC_READ         read;             /* read attribute/descriptor data */
-    tBTA_GATTC_WRITE        write;            /* write complete data */
-    tBTA_GATTC_EXEC_CMPL    exec_cmpl;       /*  execute complete */
-    tBTA_GATTC_NOTIFY       notify;           /* notification/indication event data */
+    tBTA_GATTC_READ         read;           /* read attribute/descriptor data */
+    tBTA_GATTC_WRITE        write;          /* write complete data */
+    tBTA_GATTC_EXEC_CMPL    exec_cmpl;      /*  execute complete */
+    tBTA_GATTC_NOTIFY       notify;         /* notification/indication event data */
     tBTA_GATTC_ENC_CMPL_CB  enc_cmpl;
-    BD_ADDR                 remote_bda;     /* service change event */
     tBTA_GATTC_CFG_MTU      cfg_mtu;        /* configure MTU operation */
     tBTA_GATTC_CONGEST      congest;
     tBTA_GATTC_QUEUE_FULL   queue_full;
+    tBTA_GATTC_SERVICE_CHANGE srvc_chg;     /* service change event */
 } tBTA_GATTC;
 
 /* GATTC enable callback function */
index 3a66df1985ce52d6b27ac5837826617119440d7c..de229426794c6eb1739775fa9da9cb0fdff567be 100644 (file)
@@ -913,8 +913,10 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
         break;
     }
     case BTA_GATTC_SRVC_CHG_EVT: {
-        memcpy(param.srvc_chg.remote_bda, arg->remote_bda, sizeof(esp_bd_addr_t));
-        btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, ESP_GATT_IF_NONE, &param);
+        tBTA_GATTC_SERVICE_CHANGE *srvc_change = &arg->srvc_chg;
+        gattc_if = BTC_GATT_GET_GATT_IF(srvc_change->conn_id);
+        memcpy(param.srvc_chg.remote_bda, srvc_change->remote_bda, sizeof(esp_bd_addr_t));
+        btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, gattc_if, &param);
         break;
     }
     case BTA_GATTC_QUEUE_FULL_EVT: {