OSDN Git Service

HID multi-device refactoring
authorJakub Pawlowski <jpawlowski@google.com>
Tue, 8 Mar 2016 20:36:46 +0000 (12:36 -0800)
committerJakub Pawlowski <jpawlowski@google.com>
Wed, 9 Mar 2016 04:50:38 +0000 (20:50 -0800)
We don't really support multiple HID services in same device.
We shouldn't use default value 0 for service id.
We shouldn't merge service id and characteristic id into one field,
as it's done not right right now.

Bug: 27455533
Change-Id: I46cc1b62bb2c7393e62f3b1a8e4650706954a066

bta/hh/bta_hh_int.h
bta/hh/bta_hh_le.c
bta/include/bta_hh_co.h

index 2db0cf1..d7ee649 100644 (file)
@@ -191,8 +191,8 @@ typedef struct
 {
     UINT8                   index;
     BOOLEAN                 in_use;
-    UINT8                   inst_id;    /* share service instance ID and report instance ID, as
-                                           hi 4 for service instance ID, low 4 as charatceristic instance ID */
+    UINT8                   srvc_inst_id;
+    UINT8                   char_inst_id;
     tBTA_HH_RPT_TYPE        rpt_type;
     UINT16                  uuid;
     UINT8                   prop;
@@ -208,6 +208,7 @@ typedef struct
 typedef struct
 {
     BOOLEAN                 in_use;
+    UINT8                   srvc_inst_id;
     tBTA_HH_LE_RPT          report[BTA_HH_LE_RPT_MAX];
 
 #define BTA_HH_LE_PROTO_MODE_BIT        0x01
@@ -223,10 +224,6 @@ typedef struct
 
 }tBTA_HH_LE_HID_SRVC;
 
-#ifndef BTA_HH_LE_HID_SRVC_MAX
-#define BTA_HH_LE_HID_SRVC_MAX      1
-#endif
-
 /* convert a HID handle to the LE CB index */
 #define BTA_HH_GET_LE_CB_IDX(x)         (((x) >> 4) - 1)
 /* convert a GATT connection ID to HID device handle, it is the hi 4 bits of a UINT8 */
@@ -267,12 +264,10 @@ typedef struct
     tBTA_HH_STATUS      status;
     tBTA_GATT_REASON    reason;
     BOOLEAN             is_le_device;
-    tBTA_HH_LE_HID_SRVC hid_srvc[BTA_HH_LE_HID_SRVC_MAX];
+    tBTA_HH_LE_HID_SRVC hid_srvc;
     UINT16              conn_id;
     BOOLEAN             in_bg_conn;
-    UINT8               total_srvc;
     UINT8               clt_cfg_idx;
-    UINT8               cur_srvc_index; /* currently discovering service index */
     BOOLEAN             scps_supported;
 
 #define BTA_HH_LE_SCPS_NOTIFY_NONE    0
index f5e2044..c47aa58 100644 (file)
 
 #define BTA_HH_LE_RPT_TYPE_VALID(x)     ((x) <= BTA_LE_HID_RPT_FEATURE && (x)>=BTA_LE_HID_RPT_INPUT)
 
-#define BTA_HH_LE_RPT_INST_ID_MAP(s,c)  (UINT8)(((s)<<4)|(c))
-#define BTA_HH_LE_RPT_GET_SRVC_INST_ID(x)  (UINT8)(x  >> 4)
-#define BTA_HH_LE_RPT_GET_RPT_INST_ID(x)  (UINT8)(x & 0x0f)
-
-
 #define BTA_HH_LE_PROTO_BOOT_MODE      0x00
 #define BTA_HH_LE_PROTO_REPORT_MODE      0x01
 
@@ -89,8 +84,6 @@ static void bta_hh_process_cache_rpt (tBTA_HH_DEV_CB *p_cb,
                                       tBTA_HH_RPT_CACHE_ENTRY *p_rpt_cache,
                                       UINT8 num_rpt);
 
-#define BTA_HH_LE_SRVC_DEF      0
-
 #if BTA_HH_DEBUG == TRUE
 static const char *bta_hh_le_rpt_name[4] =
 {
@@ -112,48 +105,37 @@ static const char *bta_hh_le_rpt_name[4] =
 *******************************************************************************/
 static void bta_hh_le_hid_report_dbg(tBTA_HH_DEV_CB *p_cb)
 {
-    UINT8 i , j;
-    tBTA_HH_LE_RPT  *p_rpt;
-    char *  rpt_name;
+    APPL_TRACE_DEBUG("%s: HID Report DB", __func__);
 
-    APPL_TRACE_DEBUG("HID Report DB");
-    for (i = 0; i < BTA_HH_LE_HID_SRVC_MAX; i ++)
-    {
-        if (p_cb->hid_srvc[i].in_use)
-        {
-            p_rpt = &p_cb->hid_srvc[i].report[0];
+    if (!p_cb->hid_srvc.in_use)
+        return;
 
-            APPL_TRACE_DEBUG("\t HID serivce inst: %d", i);
+    tBTA_HH_LE_RPT  *p_rpt = &p_cb->hid_srvc.report[0];
 
-            for (j = 0; j < BTA_HH_LE_RPT_MAX; j ++, p_rpt++)
-            {
-                rpt_name = "Unknown";
-                if (p_rpt->in_use)
-                {
-                    if (p_rpt->uuid == GATT_UUID_HID_REPORT)
-                        rpt_name = "Report";
-                    if (p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT)
-                        rpt_name = "Boot KB Input";
-                    if (p_rpt->uuid == GATT_UUID_HID_BT_KB_OUTPUT)
-                        rpt_name = "Boot KB Output";
-                    if (p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT)
-                        rpt_name = "Boot MI Input";
-
-
-                    APPL_TRACE_DEBUG("\t\t [%s- 0x%04x] [Type: %s], [ReportID: %d] [inst_id: %d]  [Clt_cfg: %d]",
-                        rpt_name,
-                        p_rpt->uuid ,
-                        ((p_rpt->rpt_type < 4) ? bta_hh_le_rpt_name[p_rpt->rpt_type] : "UNKNOWN"),
-                        p_rpt->rpt_id,
-                        p_rpt->inst_id,
-                        p_rpt->client_cfg_value);
-                }
-                else
-                    break;
-            }
-        }
-        else
+    for (int j = 0; j < BTA_HH_LE_RPT_MAX; j ++, p_rpt++)
+    {
+        char *  rpt_name = "Unknown";
+
+        if (!p_rpt->in_use)
             break;
+
+        if (p_rpt->uuid == GATT_UUID_HID_REPORT)
+            rpt_name = "Report";
+        if (p_rpt->uuid == GATT_UUID_HID_BT_KB_INPUT)
+            rpt_name = "Boot KB Input";
+        if (p_rpt->uuid == GATT_UUID_HID_BT_KB_OUTPUT)
+            rpt_name = "Boot KB Output";
+        if (p_rpt->uuid == GATT_UUID_HID_BT_MOUSE_INPUT)
+            rpt_name = "Boot MI Input";
+
+        APPL_TRACE_DEBUG("\t\t [%s- 0x%04x] [Type: %s], [ReportID: %d] [srvc_inst_id: %d] [char_inst_id: %d] [Clt_cfg: %d]",
+            rpt_name,
+            p_rpt->uuid ,
+            ((p_rpt->rpt_type < 4) ? bta_hh_le_rpt_name[p_rpt->rpt_type] : "UNKNOWN"),
+            p_rpt->rpt_id,
+            p_rpt->srvc_inst_id,
+            p_rpt->char_inst_id,
+            p_rpt->client_cfg_value);
     }
 }
 
@@ -302,31 +284,6 @@ BOOLEAN bta_hh_is_le_device(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda)
 
 /*******************************************************************************
 **
-** Function         bta_hh_le_add_hid_srvc_entry
-**
-** Description      Add a HID service entry in the HID device control block
-**
-** Parameters:
-**
-*******************************************************************************/
-BOOLEAN bta_hh_le_add_hid_srvc_entry(tBTA_HH_DEV_CB *p_dev_cb, UINT8 idx)
-{
-    BOOLEAN added = FALSE;
-
-    if (idx < BTA_HH_LE_HID_SRVC_MAX)
-    {
-        p_dev_cb->hid_srvc[idx].in_use = TRUE;
-        added = TRUE;
-    }
-    else
-    {
-        APPL_TRACE_ERROR("DB full,max HID service entry!");
-    }
-    return added;
-}
-
-/*******************************************************************************
-**
 ** Function         bta_hh_le_open_conn
 **
 ** Description      open a GATT connection first.
@@ -441,15 +398,10 @@ tBTA_HH_DEV_CB * bta_hh_le_find_dev_cb_by_bda(BD_ADDR bda)
 *******************************************************************************/
 UINT8 bta_hh_le_find_service_inst_by_battery_inst_id(tBTA_HH_DEV_CB *p_cb, UINT8 ba_inst_id)
 {
-    UINT8   i;
-
-    for (i = 0; i < BTA_HH_LE_HID_SRVC_MAX; i ++)
+    if (p_cb->hid_srvc.in_use &&
+        p_cb->hid_srvc.incl_srvc_inst == ba_inst_id)
     {
-        if (p_cb->hid_srvc[i].in_use &&
-            p_cb->hid_srvc[i].incl_srvc_inst == ba_inst_id)
-        {
-            return i;
-        }
+        return p_cb->hid_srvc.srvc_inst_id;
     }
     return BTA_HH_IDX_INVALID;
 }
@@ -479,12 +431,13 @@ tBTA_HH_LE_RPT * bta_hh_le_find_report_entry(tBTA_HH_DEV_CB *p_cb,
             return NULL;
     }
 
-    p_rpt = &p_cb->hid_srvc[hid_inst_id].report[0];
+    p_rpt = &p_cb->hid_srvc.report[0];
 
     for (i = 0; i < BTA_HH_LE_RPT_MAX; i ++, p_rpt ++)
     {
         if (p_rpt->uuid == rpt_uuid &&
-            p_rpt->inst_id == BTA_HH_LE_RPT_INST_ID_MAP(srvc_inst_id, char_inst_id))
+            p_rpt->srvc_inst_id == srvc_inst_id &&
+            p_rpt->char_inst_id == char_inst_id)
         {
 
             return p_rpt;
@@ -555,19 +508,21 @@ tBTA_HH_LE_RPT * bta_hh_le_find_alloc_report_entry(tBTA_HH_DEV_CB *p_cb,
         if (hid_inst_id == BTA_HH_IDX_INVALID)
             return NULL;
     }
-    p_rpt = &p_cb->hid_srvc[hid_inst_id].report[0];
+    p_rpt = &p_cb->hid_srvc.report[0];
 
     for (i = 0; i < BTA_HH_LE_RPT_MAX; i ++, p_rpt ++)
     {
         if (!p_rpt->in_use ||
             (p_rpt->uuid == rpt_uuid &&
-             p_rpt->inst_id == BTA_HH_LE_RPT_INST_ID_MAP(srvc_inst_id, inst_id)))
+             p_rpt->srvc_inst_id == srvc_inst_id &&
+             p_rpt->char_inst_id == inst_id))
         {
             if (!p_rpt->in_use)
             {
                 p_rpt->in_use   = TRUE;
                 p_rpt->index    = i;
-                p_rpt->inst_id  = BTA_HH_LE_RPT_INST_ID_MAP(srvc_inst_id, inst_id);
+                p_rpt->srvc_inst_id  = srvc_inst_id;
+                p_rpt->char_inst_id  = inst_id;
                 p_rpt->prop     = prop;
                 p_rpt->uuid     = rpt_uuid;
 
@@ -676,9 +631,9 @@ void bta_hh_le_read_rpt_ref_descr(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_LE_RPT *p_rp
 
             if (bta_hh_le_read_char_dscrpt(p_dev_cb,
                                             srvc_uuid,
-                                            BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt->inst_id),
+                                            p_rpt->srvc_inst_id,
                                             char_uuid,
-                                            BTA_HH_LE_RPT_GET_RPT_INST_ID(p_rpt->inst_id),
+                                            p_rpt->char_inst_id,
                                             GATT_UUID_RPT_REF_DESCR)
                 == BTA_HH_OK)
             {
@@ -736,7 +691,8 @@ void bta_hh_le_save_rpt_ref(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_LE_RPT  *p_rpt,
         rpt_entry.rpt_type  = p_rpt->rpt_type;
         rpt_entry.rpt_uuid  = p_rpt->uuid;
         rpt_entry.prop      = p_rpt->prop;
-        rpt_entry.inst_id   = p_rpt->inst_id;
+        rpt_entry.srvc_inst_id = p_rpt->srvc_inst_id;
+        rpt_entry.char_inst_id = p_rpt->char_inst_id;
 
         bta_hh_le_co_rpt_info(p_dev_cb->addr,
                               &rpt_entry,
@@ -781,11 +737,11 @@ void bta_hh_le_save_ext_rpt_ref(tBTA_HH_DEV_CB *p_dev_cb,
         p_data->p_value && p_data->p_value->unformat.len == 2)
     {
         pp = p_data->p_value->unformat.p_value;
-        STREAM_TO_UINT16(p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].ext_rpt_ref, pp);
+        STREAM_TO_UINT16(p_dev_cb->hid_srvc.ext_rpt_ref, pp);
 
 #if BTA_HH_DEBUG == TRUE
         APPL_TRACE_DEBUG("External Report Reference UUID 0x%04x",
-                    p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].ext_rpt_ref);
+                    p_dev_cb->hid_srvc.ext_rpt_ref);
 #endif
     }
     bta_hh_le_search_hid_chars(p_dev_cb);
@@ -805,7 +761,7 @@ void bta_hh_le_save_ext_rpt_ref(tBTA_HH_DEV_CB *p_dev_cb,
 void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 srvc_inst,
                                     UINT8 proto_mode, BOOLEAN register_ba)
 {
-    tBTA_HH_LE_RPT  *p_rpt = &p_dev_cb->hid_srvc[srvc_inst].report[0];
+    tBTA_HH_LE_RPT  *p_rpt = &p_dev_cb->hid_srvc.report[0];
     tBTA_GATTC_CHAR_ID  char_id;
     UINT8   i;
     UINT16  srvc_uuid;
@@ -823,8 +779,8 @@ void bta_hh_le_register_input_notif(tBTA_HH_DEV_CB *p_dev_cb, UINT8 srvc_inst,
             else
                 srvc_uuid = UUID_SERVCLASS_LE_HID;
 
-            bta_hh_le_fill_16bits_srvc_id(TRUE, BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt->inst_id), srvc_uuid, &char_id.srvc_id);
-            bta_hh_le_fill_16bits_char_id(BTA_HH_LE_RPT_GET_RPT_INST_ID(p_rpt->inst_id), p_rpt->uuid, &char_id.char_id);
+            bta_hh_le_fill_16bits_srvc_id(TRUE, p_rpt->srvc_inst_id, srvc_uuid, &char_id.srvc_id);
+            bta_hh_le_fill_16bits_char_id(p_rpt->char_inst_id, p_rpt->uuid, &char_id.char_id);
 
             if (register_ba && p_rpt->uuid == GATT_UUID_BATTERY_LEVEL)
             {
@@ -963,7 +919,7 @@ BOOLEAN bta_hh_le_write_char_clt_cfg(tBTA_HH_DEV_CB *p_cb,
 BOOLEAN bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst_id)
 {
     UINT8           i;
-    tBTA_HH_LE_RPT  *p_rpt = &p_cb->hid_srvc[srvc_inst_id].report[p_cb->clt_cfg_idx];
+    tBTA_HH_LE_RPT  *p_rpt = &p_cb->hid_srvc.report[p_cb->clt_cfg_idx];
     UINT16          srvc_uuid;
 
     for (i = p_cb->clt_cfg_idx; i < BTA_HH_LE_RPT_MAX && p_rpt->in_use; i ++, p_rpt ++)
@@ -978,9 +934,9 @@ BOOLEAN bta_hh_le_write_rpt_clt_cfg(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst_id)
                 srvc_uuid = UUID_SERVCLASS_LE_HID;
 
             if (bta_hh_le_write_char_clt_cfg(p_cb,
-                                             BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt->inst_id),
+                                             p_rpt->srvc_inst_id,
                                              srvc_uuid,
-                                             BTA_HH_LE_RPT_GET_RPT_INST_ID(p_rpt->inst_id),
+                                             p_rpt->char_inst_id,
                                              p_rpt->uuid,
                                              BTA_GATT_CLT_CONFIG_NOTIFICATION))
             {
@@ -1021,7 +977,7 @@ BOOLEAN bta_hh_le_set_protocol_mode(tBTA_HH_DEV_CB *p_cb, tBTA_HH_PROTO_MODE mod
 
     cback_data.handle  = p_cb->hid_handle;
     /* boot mode is not supported in the remote device */
-    if ((p_cb->hid_srvc[BTA_HH_LE_SRVC_DEF].option_char & BTA_HH_LE_PROTO_MODE_BIT) == 0)
+    if ((p_cb->hid_srvc.option_char & BTA_HH_LE_PROTO_MODE_BIT) == 0)
     {
         p_cb->mode  = BTA_HH_PROTO_RPT_MODE;
 
@@ -1074,34 +1030,27 @@ void bta_hh_le_get_protocol_mode(tBTA_HH_DEV_CB *p_cb)
 {
     tBTA_GATTC_CHAR_ID  char_id;
     tBTA_HH_HSDATA    hs_data;
-    UINT8 i;
 
     p_cb->w4_evt = BTA_HH_GET_PROTO_EVT;
 
-    for (i = 0; i< BTA_HH_LE_HID_SRVC_MAX; i ++)
+    if (p_cb->hid_srvc.in_use &&
+        p_cb->hid_srvc.option_char & BTA_HH_LE_PROTO_MODE_BIT)
     {
-        if (p_cb->hid_srvc[i].in_use &&
-            p_cb->hid_srvc[i].option_char & BTA_HH_LE_PROTO_MODE_BIT)
-        {
-            bta_hh_le_fill_16bits_srvc_id(TRUE, 0, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
-            bta_hh_le_fill_16bits_char_id(0, GATT_UUID_HID_PROTO_MODE, &char_id.char_id);
+        bta_hh_le_fill_16bits_srvc_id(TRUE, 0, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
+        bta_hh_le_fill_16bits_char_id(0, GATT_UUID_HID_PROTO_MODE, &char_id.char_id);
 
-            BTA_GATTC_ReadCharacteristic(p_cb->conn_id,
-                                        &char_id,
-                                        BTA_GATT_AUTH_REQ_NONE);
-            break;
-        }
-    }
-    /* no service support protocol_mode, by default report mode */
-    if (i == BTA_HH_LE_HID_SRVC_MAX)
-    {
-        hs_data.status  = BTA_HH_OK;
-        hs_data.handle  = p_cb->hid_handle;
-        hs_data.rsp_data.proto_mode = BTA_HH_PROTO_RPT_MODE;
-        p_cb->w4_evt = 0;
-        (* bta_hh_cb.p_cback)(BTA_HH_GET_PROTO_EVT, (tBTA_HH *)&hs_data);
+        BTA_GATTC_ReadCharacteristic(p_cb->conn_id,
+                                    &char_id,
+                                    BTA_GATT_AUTH_REQ_NONE);
+        return;
     }
 
+    /* no service support protocol_mode, by default report mode */
+    hs_data.status  = BTA_HH_OK;
+    hs_data.handle  = p_cb->hid_handle;
+    hs_data.rsp_data.proto_mode = BTA_HH_PROTO_RPT_MODE;
+    p_cb->w4_evt = 0;
+    (* bta_hh_cb.p_cback)(BTA_HH_GET_PROTO_EVT, (tBTA_HH *)&hs_data);
 }
 
 /*******************************************************************************
@@ -1121,7 +1070,7 @@ void bta_hh_le_expl_rpt(tBTA_HH_DEV_CB *p_dev_cb,
     do
     {
         if (bta_hh_le_find_alloc_report_entry(p_dev_cb,
-                                          p_dev_cb->cur_srvc_index,
+                                          p_dev_cb->hid_srvc.srvc_inst_id,
                                           GATT_UUID_HID_REPORT,
                                           p_char_id->char_id.inst_id,
                                           prop) == NULL)
@@ -1145,7 +1094,7 @@ void bta_hh_le_expl_rpt(tBTA_HH_DEV_CB *p_dev_cb,
 
     LOG_INFO(LOG_TAG, "%s all BLE reports searched", __func__);
     bta_hh_le_read_rpt_ref_descr(p_dev_cb,
-                                 &p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].report[0]);
+                                 &p_dev_cb->hid_srvc.report[0]);
 
 
     return ;
@@ -1162,7 +1111,7 @@ void bta_hh_le_expl_boot_rpt(tBTA_HH_DEV_CB *p_dev_cb, UINT16 char_uuid,
                                 tBTA_GATT_CHAR_PROP prop)
 {
     if (bta_hh_le_find_alloc_report_entry(p_dev_cb,
-                                      p_dev_cb->cur_srvc_index,
+                                      p_dev_cb->hid_srvc.srvc_inst_id,
                                       char_uuid,
                                       0,
                                       prop) == NULL)
@@ -1293,7 +1242,7 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf)
     if (p_cb->status == BTA_HH_OK)
     {
         APPL_TRACE_DEBUG("bta_hh_security_cmpl OK");
-        if (!p_cb->hid_srvc[BTA_HH_LE_SRVC_DEF].in_use)
+        if (!p_cb->hid_srvc.in_use)
         {
             APPL_TRACE_DEBUG("bta_hh_security_cmpl no reports loaded, try to load");
             /* start loading the cache if not in stack */
@@ -1303,7 +1252,7 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf)
             }
         }
         /*  discovery has been done for HID service */
-        if (p_cb->app_id != 0 && p_cb->hid_srvc[BTA_HH_LE_SRVC_DEF].in_use)
+        if (p_cb->app_id != 0 && p_cb->hid_srvc.in_use)
         {
             /* configure protocol mode */
             if (bta_hh_le_set_protocol_mode(p_cb, p_cb->mode) == FALSE)
@@ -1359,17 +1308,13 @@ void bta_hh_le_notify_enc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_buf)
 *******************************************************************************/
 void bta_hh_clear_service_cache(tBTA_HH_DEV_CB *p_cb)
 {
-    UINT8 i;
-    tBTA_HH_LE_HID_SRVC     *p_hid_srvc = &p_cb->hid_srvc[0];
+    tBTA_HH_LE_HID_SRVC     *p_hid_srvc = &p_cb->hid_srvc;
 
     p_cb->app_id = 0;
-    p_cb->total_srvc = 0;
     p_cb->dscp_info.descriptor.dsc_list = NULL;
 
-    for (i = 0; i < BTA_HH_LE_HID_SRVC_MAX; i++, p_hid_srvc++) {
-        osi_free_and_reset((void **)&p_hid_srvc->rpt_map);
-        memset(p_hid_srvc, 0, sizeof(tBTA_HH_LE_HID_SRVC));
-    }
+    osi_free_and_reset((void **)&p_hid_srvc->rpt_map);
+    memset(p_hid_srvc, 0, sizeof(tBTA_HH_LE_HID_SRVC));
 }
 
 /*******************************************************************************
@@ -1530,9 +1475,11 @@ void bta_hh_le_search_result(tBTA_GATTC_SRVC_RES *p_srvc_result)
             {
                 /* found HID primamry service */
                 /* TODO: proceed to find battery and device info */
-                if (bta_hh_le_add_hid_srvc_entry(p_dev_cb, p_dev_cb->total_srvc))
-                    p_dev_cb->total_srvc ++;
-                APPL_TRACE_DEBUG("num of hid service: %d", p_dev_cb->total_srvc);
+
+                p_dev_cb->hid_srvc.in_use = TRUE;
+                p_dev_cb->hid_srvc.srvc_inst_id = p_srvc_result->service_uuid.id.inst_id;
+
+                APPL_TRACE_DEBUG("%s: have HID service inst_id=", __func__, p_dev_cb->hid_srvc.srvc_inst_id);
             }
             break;
 
@@ -1567,7 +1514,7 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status)
 
         /* set report notification configuration */
         p_cb->clt_cfg_idx = 0;
-        bta_hh_le_write_rpt_clt_cfg(p_cb, BTA_HH_LE_SRVC_DEF);
+        bta_hh_le_write_rpt_clt_cfg(p_cb, p_cb->hid_srvc.srvc_inst_id);
     }
     else /* error, close the GATT connection */
     {
@@ -1588,21 +1535,20 @@ void bta_hh_le_gatt_disc_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_STATUS status)
 void bta_hh_le_srvc_expl_srvc(tBTA_HH_DEV_CB *p_dev_cb)
 {
 #if BTA_HH_DEBUG == TRUE
-    APPL_TRACE_DEBUG("bta_hh_le_srvc_expl_srvc cur_srvc_index = %d in_use = %d",
-                    p_dev_cb->cur_srvc_index,
-                    p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].in_use);
+    APPL_TRACE_DEBUG("%s: srvc_inst_id = %d in_use = %d", __func__,
+                    p_dev_cb->hid_srvc.srvc_inst_id,
+                    p_dev_cb->hid_srvc.in_use);
 #endif
 
-    if (p_dev_cb->cur_srvc_index < BTA_HH_LE_HID_SRVC_MAX &&
-        p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].in_use)
+    if (p_dev_cb->hid_srvc.in_use)
     {
-        if (!p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].expl_incl_srvc)
+        if (!p_dev_cb->hid_srvc.expl_incl_srvc)
             /* explore included service first */
             bta_hh_le_search_hid_included(p_dev_cb);
         else
         {
             /* explore characterisc */
-            p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].cur_expl_char_idx = 0;
+            p_dev_cb->hid_srvc.cur_expl_char_idx = 0;
             bta_hh_le_search_hid_chars(p_dev_cb);
         }
     }
@@ -1629,7 +1575,7 @@ void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL *p_data)
     if (p_dev_cb == NULL)
         return;
 
-    if(p_data->status != BTA_GATT_OK || p_dev_cb->total_srvc == 0)
+    if(p_data->status != BTA_GATT_OK)
     {
         p_dev_cb->status = BTA_HH_ERR_SDP;
         /* close the connection and report service discovery complete with error */
@@ -1645,7 +1591,6 @@ void bta_hh_le_srvc_search_cmpl(tBTA_GATTC_SEARCH_CMPL *p_data)
         }
         else /* discover HID service */
         {
-        p_dev_cb->cur_srvc_index = 0;
         bta_hh_le_srvc_expl_srvc(p_dev_cb);
     }
 }
@@ -1668,7 +1613,7 @@ static void bta_hh_le_search_hid_included(tBTA_HH_DEV_CB *p_dev_cb)
     tBTA_GATTC_CHAR_ID  char_result;
     tBTA_GATT_CHAR_PROP prop = 0;
 
-    bta_hh_le_fill_16bits_srvc_id(TRUE, p_dev_cb->cur_srvc_index, UUID_SERVCLASS_LE_HID, &srvc_id);
+    bta_hh_le_fill_16bits_srvc_id(TRUE, p_dev_cb->hid_srvc.srvc_inst_id, UUID_SERVCLASS_LE_HID, &srvc_id);
 
     srvc_cond.len = LEN_UUID_16;
     srvc_cond.uu.uuid16 = UUID_SERVCLASS_BATTERY;
@@ -1679,7 +1624,7 @@ static void bta_hh_le_search_hid_included(tBTA_HH_DEV_CB *p_dev_cb)
                             &inc_srvc_result) == BTA_GATT_OK)
     {
         /* read include service UUID */
-        p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].incl_srvc_inst = inc_srvc_result.incl_svc_id.id.inst_id;
+        p_dev_cb->hid_srvc.incl_srvc_inst = inc_srvc_result.incl_svc_id.id.inst_id;
 
         char_cond.len = LEN_UUID_16;
         char_cond.uu.uuid16 = GATT_UUID_BATTERY_LEVEL;
@@ -1715,7 +1660,7 @@ static void bta_hh_le_search_hid_included(tBTA_HH_DEV_CB *p_dev_cb)
         }
     }
 
-    p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].expl_incl_srvc = TRUE;
+    p_dev_cb->hid_srvc.expl_incl_srvc = TRUE;
 
     bta_hh_le_srvc_expl_srvc(p_dev_cb);
 
@@ -1735,7 +1680,7 @@ void bta_hh_read_battery_level_cmpl(UINT8 status, tBTA_HH_DEV_CB *p_dev_cb, tBTA
     UNUSED(status);
     UNUSED(p_data);
 
-    p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].expl_incl_srvc = TRUE;
+    p_dev_cb->hid_srvc.expl_incl_srvc = TRUE;
     bta_hh_le_srvc_expl_srvc(p_dev_cb);
 }
 /*******************************************************************************
@@ -1757,23 +1702,22 @@ static void bta_hh_le_search_hid_chars(tBTA_HH_DEV_CB *p_dev_cb)
     UINT16      char_uuid = 0;
     tBTA_GATT_SRVC_ID srvc_id;
 
-    if (p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].cur_expl_char_idx == BTA_HH_LE_DISC_CHAR_NUM ||
+    if (p_dev_cb->hid_srvc.cur_expl_char_idx == BTA_HH_LE_DISC_CHAR_NUM ||
         (p_dev_cb->status != BTA_HH_OK && p_dev_cb->status != BTA_HH_ERR_PROTO))
     {
-        p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].cur_expl_char_idx = 0;
+        p_dev_cb->hid_srvc.cur_expl_char_idx = 0;
         /* explore next service */
-        p_dev_cb->cur_srvc_index ++;
-        bta_hh_le_srvc_expl_srvc(p_dev_cb);
+        bta_hh_le_gatt_disc_cmpl(p_dev_cb, p_dev_cb->status);
         return;
     }
 
-    p_dev_cb->hid_srvc[ p_dev_cb->cur_srvc_index].cur_expl_char_idx ++;
-    char_uuid = bta_hh_le_disc_char_uuid[p_dev_cb->hid_srvc[p_dev_cb->cur_srvc_index].cur_expl_char_idx - 1];
+    p_dev_cb->hid_srvc.cur_expl_char_idx ++;
+    char_uuid = bta_hh_le_disc_char_uuid[p_dev_cb->hid_srvc.cur_expl_char_idx - 1];
 
     char_cond.len = LEN_UUID_16;
     char_cond.uu.uuid16 = char_uuid;
 
-    bta_hh_le_fill_16bits_srvc_id(TRUE, p_dev_cb->cur_srvc_index, UUID_SERVCLASS_LE_HID, &srvc_id);
+    bta_hh_le_fill_16bits_srvc_id(TRUE, 0, UUID_SERVCLASS_LE_HID, &srvc_id);
 
 #if BTA_HH_DEBUG == TRUE
     APPL_TRACE_DEBUG("bta_hh_le_search_hid_chars: looking for %s(0x%04x)",
@@ -1789,7 +1733,7 @@ static void bta_hh_le_search_hid_chars(tBTA_HH_DEV_CB *p_dev_cb)
         switch (char_uuid)
         {
         case GATT_UUID_HID_CONTROL_POINT:
-            p_dev_cb->hid_srvc[char_result.srvc_id.id.inst_id].option_char |= BTA_HH_LE_CP_BIT;
+            p_dev_cb->hid_srvc.option_char |= BTA_HH_LE_CP_BIT;
             next = TRUE;
             break;
         case GATT_UUID_HID_INFORMATION:
@@ -1802,7 +1746,7 @@ static void bta_hh_le_search_hid_chars(tBTA_HH_DEV_CB *p_dev_cb)
             break;
 
         case GATT_UUID_HID_PROTO_MODE:
-            p_dev_cb->hid_srvc[char_result.srvc_id.id.inst_id].option_char |= BTA_HH_LE_PROTO_MODE_BIT;
+            p_dev_cb->hid_srvc.option_char |= BTA_HH_LE_PROTO_MODE_BIT;
             next = !bta_hh_le_set_protocol_mode(p_dev_cb, p_dev_cb->mode);
             break;
 
@@ -1844,7 +1788,7 @@ static void bta_hh_le_search_hid_chars(tBTA_HH_DEV_CB *p_dev_cb)
 void bta_hh_le_save_rpt_map(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_data)
 {
     UINT8           *pp ;
-    tBTA_HH_LE_HID_SRVC *p_srvc = &p_dev_cb->hid_srvc[p_data->srvc_id.id.inst_id];
+    tBTA_HH_LE_HID_SRVC *p_srvc = &p_dev_cb->hid_srvc;
 
     pp = p_data->p_value->unformat.p_value;
 
@@ -1857,7 +1801,7 @@ void bta_hh_le_save_rpt_map(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_data)
     {
         STREAM_TO_ARRAY(p_srvc->rpt_map, pp, p_data->p_value->unformat.len);
         p_srvc->descriptor.dl_len = p_data->p_value->unformat.len;
-        p_srvc->descriptor.dsc_list = p_dev_cb->hid_srvc[p_data->srvc_id.id.inst_id].rpt_map;
+        p_srvc->descriptor.dsc_list = p_dev_cb->hid_srvc.rpt_map;
     }
 
     if (bta_hh_le_read_char_dscrpt(p_dev_cb,
@@ -1901,7 +1845,7 @@ void bta_hh_le_proc_get_rpt_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_GATTC_READ *p_da
     if (p_data->status == BTA_GATT_OK)
     {
         p_rpt = bta_hh_le_find_report_entry(p_dev_cb,
-                                            p_data->srvc_id.id.inst_id,//BTA_HH_LE_SRVC_DEF,
+                                            p_data->srvc_id.id.inst_id,
                                             p_data->char_id.uuid.uu.uuid16,
                                             p_data->char_id.inst_id);
 
@@ -2083,7 +2027,7 @@ void bta_hh_le_read_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_buf)
     if (p_data->descr_type.uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG)
     {
         if ((p_rpt = bta_hh_le_find_report_entry(p_dev_cb,
-                                                 BTA_HH_LE_SRVC_DEF,
+                                                 p_data->srvc_id.id.inst_id,
                                                  p_data->char_id.uuid.uu.uuid16,
                                                  p_data->char_id.inst_id)) != NULL)
         {
@@ -2295,7 +2239,7 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
         case GATT_UUID_HID_BT_MOUSE_INPUT:
         case GATT_UUID_HID_REPORT:
             if (p_data->status == BTA_GATT_OK)
-                p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
+                p_dev_cb->hid_srvc.report[p_dev_cb->clt_cfg_idx].client_cfg_value =
                         BTA_GATT_CLT_CONFIG_NOTIFICATION;
             p_dev_cb->clt_cfg_idx ++;
             bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id);
@@ -2348,7 +2292,7 @@ void bta_hh_le_input_rpt_notify(tBTA_GATTC_NOTIFY *p_data)
     app_id= p_dev_cb->app_id;
 
     p_rpt = bta_hh_le_find_report_entry(p_dev_cb,
-                                        BTA_HH_LE_SRVC_DEF,
+                                        p_dev_cb->hid_srvc.srvc_inst_id,
                                         p_data->char_id.char_id.uuid.uu.uuid16,
                                         p_data->char_id.char_id.inst_id);
     if (p_rpt == NULL)
@@ -2496,9 +2440,9 @@ void bta_hh_le_api_disc_act(tBTA_HH_DEV_CB *p_cb)
 ** Returns          void
 **
 *******************************************************************************/
-void bta_hh_le_get_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst, tBTA_HH_RPT_TYPE r_type, UINT8 rpt_id)
+void bta_hh_le_get_rpt(tBTA_HH_DEV_CB *p_cb, tBTA_HH_RPT_TYPE r_type, UINT8 rpt_id)
 {
-    tBTA_HH_LE_RPT  *p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc[srvc_inst].report, p_cb->mode, r_type, rpt_id);
+    tBTA_HH_LE_RPT  *p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc.report, p_cb->mode, r_type, rpt_id);
     tBTA_GATTC_CHAR_ID  char_id;
     UINT16  srvc_uuid = UUID_SERVCLASS_LE_HID;
 
@@ -2512,8 +2456,8 @@ void bta_hh_le_get_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst, tBTA_HH_RPT_TYPE r
 
     p_cb->w4_evt = BTA_HH_GET_RPT_EVT;
 
-    bta_hh_le_fill_16bits_srvc_id(TRUE, srvc_inst, srvc_uuid, &char_id.srvc_id);
-    bta_hh_le_fill_16bits_char_id(p_rpt->inst_id, p_rpt->uuid, &char_id.char_id);
+    bta_hh_le_fill_16bits_srvc_id(TRUE, p_rpt->srvc_inst_id, srvc_uuid, &char_id.srvc_id);
+    bta_hh_le_fill_16bits_char_id(p_rpt->char_inst_id, p_rpt->uuid, &char_id.char_id);
 
     BTA_GATTC_ReadCharacteristic(p_cb->conn_id,
                                  &char_id,
@@ -2529,7 +2473,7 @@ void bta_hh_le_get_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst, tBTA_HH_RPT_TYPE r
 ** Returns          void
 **
 *******************************************************************************/
-void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
+void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb,
                          tBTA_GATTC_WRITE_TYPE   write_type,
                          tBTA_HH_RPT_TYPE r_type,
                          BT_HDR *p_buf, UINT16 w4_evt )
@@ -2549,7 +2493,7 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
     STREAM_TO_UINT8(rpt_id, p_value);
     p_buf->len -= 1;
 
-    p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc[srvc_inst].report, p_cb->mode, r_type, rpt_id);
+    p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc.report, p_cb->mode, r_type, rpt_id);
 
     if (p_rpt == NULL)
     {
@@ -2562,8 +2506,8 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
 
     p_cb->w4_evt = w4_evt;
 
-    bta_hh_le_fill_16bits_srvc_id(TRUE, srvc_inst, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
-    bta_hh_le_fill_16bits_char_id(p_rpt->inst_id, p_rpt->uuid, &char_id.char_id);
+    bta_hh_le_fill_16bits_srvc_id(TRUE, p_rpt->srvc_inst_id, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
+    bta_hh_le_fill_16bits_char_id(p_rpt->char_inst_id, p_rpt->uuid, &char_id.char_id);
 
     BTA_GATTC_WriteCharValue(p_cb->conn_id,
                              &char_id,
@@ -2585,23 +2529,19 @@ void bta_hh_le_write_rpt(tBTA_HH_DEV_CB *p_cb, UINT8 srvc_inst,
 *******************************************************************************/
 void bta_hh_le_suspend(tBTA_HH_DEV_CB *p_cb, tBTA_HH_TRANS_CTRL_TYPE ctrl_type)
 {
-    UINT8 i;
     tBTA_GATTC_CHAR_ID  char_id;
 
     ctrl_type -= BTA_HH_CTRL_SUSPEND;
 
-    for (i = 0; i < BTA_HH_LE_HID_SRVC_MAX; i ++)
-    {
-        bta_hh_le_fill_16bits_srvc_id(TRUE, i, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
-        bta_hh_le_fill_16bits_char_id(0, GATT_UUID_HID_CONTROL_POINT, &char_id.char_id);
+    bta_hh_le_fill_16bits_srvc_id(TRUE, 0, UUID_SERVCLASS_LE_HID, &char_id.srvc_id);
+    bta_hh_le_fill_16bits_char_id(0, GATT_UUID_HID_CONTROL_POINT, &char_id.char_id);
 
-        BTA_GATTC_WriteCharValue(p_cb->conn_id,
-                                 &char_id,
-                                 BTA_GATTC_TYPE_WRITE_NO_RSP, /* default to use write request */
-                                 1,
-                                 &ctrl_type,
-                                 BTA_GATT_AUTH_REQ_NONE);
-    }
+    BTA_GATTC_WriteCharValue(p_cb->conn_id,
+                             &char_id,
+                             BTA_GATTC_TYPE_WRITE_NO_RSP, /* default to use write request */
+                             1,
+                             &ctrl_type,
+                             BTA_GATT_AUTH_REQ_NONE);
 }
 
 /*******************************************************************************
@@ -2628,14 +2568,12 @@ void bta_hh_le_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
 
         case HID_TRANS_GET_REPORT:
             bta_hh_le_get_rpt(p_cb,
-                              BTA_HH_LE_SRVC_DEF,
                               p_data->api_sndcmd.param,
                               p_data->api_sndcmd.rpt_id);
             break;
 
         case HID_TRANS_SET_REPORT:
             bta_hh_le_write_rpt(p_cb,
-                                BTA_HH_LE_SRVC_DEF,
                                 BTA_GATTC_TYPE_WRITE,
                                 p_data->api_sndcmd.param,
                                 p_data->api_sndcmd.p_data,
@@ -2645,7 +2583,6 @@ void bta_hh_le_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
         case HID_TRANS_DATA:  /* output report */
 
             bta_hh_le_write_rpt(p_cb,
-                                BTA_HH_LE_SRVC_DEF,
                                 BTA_GATTC_TYPE_WRITE_NO_RSP,
                                 p_data->api_sndcmd.param,
                                 p_data->api_sndcmd.p_data,
@@ -2680,19 +2617,12 @@ void bta_hh_le_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
 *******************************************************************************/
 void bta_hh_le_get_dscp_act(tBTA_HH_DEV_CB *p_cb)
 {
-    UINT8 i;
-
-    for (i = 0 ;i < BTA_HH_LE_HID_SRVC_MAX; i ++)
+    if (p_cb->hid_srvc.in_use)
     {
-        if (p_cb->hid_srvc[i].in_use)
-        {
-            p_cb->dscp_info.descriptor.dl_len = p_cb->hid_srvc[i].descriptor.dl_len;
-            p_cb->dscp_info.descriptor.dsc_list = p_cb->hid_srvc[i].descriptor.dsc_list;
+        p_cb->dscp_info.descriptor.dl_len = p_cb->hid_srvc.descriptor.dl_len;
+        p_cb->dscp_info.descriptor.dsc_list = p_cb->hid_srvc.descriptor.dsc_list;
 
-            (*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
-        }
-        else
-            break;
+        (*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
     }
 }
 
@@ -2946,7 +2876,7 @@ void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id)
 
     p_cb = &bta_hh_cb.kdev[index];
 
-    p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc[BTA_HH_LE_SRVC_DEF].report, p_cb->mode, BTA_HH_RPTT_INPUT, rpt_id);
+    p_rpt = bta_hh_le_find_rpt_by_idtype(p_cb->hid_srvc.report, p_cb->mode, BTA_HH_RPTT_INPUT, rpt_id);
 
     if (p_rpt == NULL)
     {
@@ -2956,9 +2886,9 @@ void bta_hh_le_hid_read_rpt_clt_cfg(BD_ADDR bd_addr, UINT8 rpt_id)
 
     bta_hh_le_read_char_dscrpt(p_cb,
                                UUID_SERVCLASS_LE_HID,
-                               BTA_HH_LE_SRVC_DEF,
+                               p_rpt->srvc_inst_id,
                                p_rpt->uuid,
-                               p_rpt->inst_id,
+                               p_rpt->char_inst_id,
                                GATT_UUID_CHAR_CLIENT_CONFIG);
 
 
@@ -3117,20 +3047,20 @@ static void bta_hh_process_cache_rpt (tBTA_HH_DEV_CB *p_cb,
 
     if (num_rpt != 0)  /* no cache is found */
     {
-        p_cb->hid_srvc[BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt_cache->inst_id)].in_use = TRUE;
+        p_cb->hid_srvc.in_use = TRUE;
 
         /* set the descriptor info */
-        p_cb->hid_srvc[BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt_cache->inst_id)].descriptor.dl_len =
+        p_cb->hid_srvc.descriptor.dl_len =
                 p_cb->dscp_info.descriptor.dl_len;
-        p_cb->hid_srvc[BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt_cache->inst_id)].descriptor.dsc_list =
+        p_cb->hid_srvc.descriptor.dsc_list =
                     p_cb->dscp_info.descriptor.dsc_list;
 
         for (; i <num_rpt; i ++, p_rpt_cache ++)
         {
             if ((p_rpt = bta_hh_le_find_alloc_report_entry (p_cb,
-                                               BTA_HH_LE_RPT_GET_SRVC_INST_ID(p_rpt_cache->inst_id),
+                                               p_rpt_cache->srvc_inst_id,
                                                p_rpt_cache->rpt_uuid,
-                                               BTA_HH_LE_RPT_GET_RPT_INST_ID(p_rpt_cache->inst_id),
+                                               p_rpt_cache->char_inst_id,
                                                p_rpt_cache->prop))  == NULL)
             {
                 APPL_TRACE_ERROR("bta_hh_process_cache_rpt: allocation report entry failure");
index 09cb565..427e230 100755 (executable)
@@ -31,7 +31,8 @@ typedef struct
     UINT16              rpt_uuid;
     UINT8               rpt_id;
     tBTA_HH_RPT_TYPE    rpt_type;
-    UINT8               inst_id;
+    UINT8               srvc_inst_id;
+    UINT8               char_inst_id;
     UINT8               prop;
 }tBTA_HH_RPT_CACHE_ENTRY;