Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82eb6b35 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

GATT: make last service end group handle equal to 0xFFFF

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
parent 11fd7114
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -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();
}
/*******************************************************************************
 *
+1 −1
Original line number Diff line number Diff line
@@ -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;
+2 −2
Original line number Diff line number Diff line
@@ -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);