OSDN Git Service

GATT: make last service end group handle equal to 0xFFFF
authorJakub Pawlowski <jpawlowski@google.com>
Mon, 16 Apr 2018 14:55:06 +0000 (07:55 -0700)
committerJakub Pawlowski <jpawlowski@google.com>
Tue, 17 Apr 2018 06:25:37 +0000 (06:25 +0000)
ESR06 (errata 4065) added sentence:
"The End Group Handle of the last service in a device can be 0xFFFF."
It talks about last service, not last primary service. Right now,
secondary service added after last primary service will result in in
last primary service being corrupted - descriptor added to last
characteristic, and some characteristics added.

Bug: 78107486
Change-Id: I6a146fce2c946cdff176ff79f147830e29d3b807

stack/gatt/gatt_api.cc
stack/gatt/gatt_int.h
stack/gatt/gatt_sr.cc

index 4faacf4..b983318 100644 (file)
@@ -125,12 +125,13 @@ static bool is_gatt_attr_type(const Uuid& uuid) {
   return false;
 }
 
-/** Update the the last primary info for the service list info */
-static void gatt_update_last_pri_srv_info() {
-  gatt_cb.last_primary_s_handle = 0;
+/** Update the the last service info for the service list info */
+static void gatt_update_last_srv_info() {
+  gatt_cb.last_service_handle = 0;
 
-  for (tGATT_SRV_LIST_ELEM& el : *gatt_cb.srv_list_info)
-    if (el.is_primary) gatt_cb.last_primary_s_handle = el.s_hdl;
+  for (tGATT_SRV_LIST_ELEM& el : *gatt_cb.srv_list_info) {
+    gatt_cb.last_service_handle = el.s_hdl;
+  }
 }
 
 /*******************************************************************************
@@ -291,7 +292,7 @@ uint16_t GATTS_AddService(tGATT_IF gatt_if, btgatt_db_element_t* service,
     elem.sdp_handle = 0;
   }
 
-  gatt_update_last_pri_srv_info();
+  gatt_update_last_srv_info();
 
   VLOG(1) << StringPrintf(
       "%s: allocated el: s_hdl=%d e_hdl=%d type=0x%x sdp_hdl=0x%x", __func__,
@@ -389,7 +390,7 @@ void GATTS_StopService(uint16_t service_handle) {
   }
 
   gatt_cb.srv_list_info->erase(it);
-  gatt_update_last_pri_srv_info();
+  gatt_update_last_srv_info();
 }
 /*******************************************************************************
  *
index 7100420..a542b05 100644 (file)
@@ -361,7 +361,7 @@ typedef struct {
   fixed_queue_t* sign_op_queue;
 
   uint16_t next_handle;     /* next available handle */
-  uint16_t last_primary_s_handle; /* handle of last primary service */
+  uint16_t last_service_handle; /* handle of last service */
   tGATT_SVC_CHG gattp_attr; /* GATT profile attribute service change */
   tGATT_IF gatt_if;
   std::list<tGATT_HDL_LIST_ELEM>* hdl_list_info;
index f955fbf..877a881 100644 (file)
@@ -482,8 +482,8 @@ static tGATT_STATUS gatt_build_primary_service_rsp(
 
     UINT16_TO_STREAM(p, el.s_hdl);
 
-    if (gatt_cb.last_primary_s_handle &&
-        gatt_cb.last_primary_s_handle == el.s_hdl) {
+    if (gatt_cb.last_service_handle &&
+        gatt_cb.last_service_handle == el.s_hdl) {
       VLOG(1) << "Use 0xFFFF for the last primary attribute";
       /* see GATT ERRATA 4065, 4063, ATT ERRATA 4062 */
       UINT16_TO_STREAM(p, 0xFFFF);