]> granicus.if.org Git - esp-idf/commitdiff
component/bt: fixed the discover primary service not correct if server changes servic...
authorYulong <huangyulong@espressif.com>
Tue, 16 May 2017 13:10:37 +0000 (09:10 -0400)
committerYulong <huangyulong@espressif.com>
Tue, 16 May 2017 13:10:37 +0000 (09:10 -0400)
components/bt/bluedroid/api/esp_gattc_api.c
components/bt/bluedroid/btc/profile/std/gatt/btc_gattc.c
components/bt/bluedroid/btc/profile/std/include/btc_gattc.h

index bb368a68de1a549738821f6e4f1a96cd34aa6cca..1b4714d4377f98b3e9cea15596932c1a5aa97b75 100644 (file)
@@ -482,5 +482,22 @@ esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
     return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
 }
 
+esp_gatt_status_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
+{
+    btc_msg_t msg;
+    btc_ble_gattc_args_t arg;
+
+    if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
+        return ESP_ERR_INVALID_STATE;
+    }
+
+    msg.sig = BTC_SIG_API_CALL;
+    msg.pid = BTC_PID_GATTC;
+    msg.act = BTC_GATTC_ACT_CACHE_REFRESH;
+    memcpy(arg.cache_refresh.remote_bda, remote_bda, sizeof(esp_bd_addr_t));
+
+    return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
 #endif  ///GATTC_INCLUDED == TRUE
 
index 4d126ff6c342843552f3e27f3995e05d4bf41e67..eaeb904a4d25de0062ae94dc87008a0e78a87257 100644 (file)
@@ -551,6 +551,9 @@ void btc_gattc_call_handler(btc_msg_t *msg)
     case BTC_GATTC_ACT_UNREG_FOR_NOTIFY:
         btc_gattc_unreg_for_notify(arg);
         break;
+    case BTC_GATTC_ACT_CACHE_REFRESH:
+        BTA_GATTC_Refresh(arg->cache_refresh.remote_bda);
+        break;
     default:
         LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
         break;
index 2528668381c00ce7f09d2837d587c91b70bfa980..1374dc0a721a91458831eff616a101592a3b6c43 100644 (file)
@@ -41,7 +41,8 @@ typedef enum {
     BTC_GATTC_ACT_PREPARE_WRITE_CHAR_DESCR,
     BTC_GATTC_ACT_EXECUTE_WRITE,
     BTC_GATTC_ACT_REG_FOR_NOTIFY,
-    BTC_GATTC_ACT_UNREG_FOR_NOTIFY
+    BTC_GATTC_ACT_UNREG_FOR_NOTIFY,
+    BTC_GATTC_ACT_CACHE_REFRESH,
 } btc_gattc_act_t;
 
 /* btc_ble_gattc_args_t */
@@ -186,6 +187,10 @@ typedef union {
         esp_gatt_srvc_id_t service_id;
         esp_gatt_id_t char_id;
     } unreg_for_notify;
+    //BTC_GATTC_ACT_CACHE_REFRESH,
+    struct cache_refresh_arg {
+        esp_bd_addr_t remote_bda;
+    } cache_refresh;
 } btc_ble_gattc_args_t;
 
 void btc_gattc_call_handler(btc_msg_t *msg);