From 85e88cd0ebd29497747681bf11e435fc9dabd289 Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Thu, 7 Jun 2018 15:19:20 +0800 Subject: [PATCH] Component/bt: fix include service start handle error --- .../bt/bluedroid/bta/gatt/bta_gattc_cache.c | 43 ++++++++++++++----- .../bluedroid/bta/include/bta/bta_gatt_api.h | 4 +- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c index 66d3bb8be..7c8ec58c6 100644 --- a/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c +++ b/components/bt/bluedroid/bta/gatt/bta_gattc_cache.c @@ -346,6 +346,7 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb, tBT_UUID *p_uuid, UINT8 property, UINT16 incl_srvc_s_handle, + UINT16 incl_srvc_e_handle, tBTA_GATTC_ATTR_TYPE type) { #if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE) @@ -370,6 +371,7 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb, isvc->handle = handle; memcpy(&isvc->uuid, p_uuid, sizeof(tBT_UUID)); isvc->incl_srvc_s_handle = incl_srvc_s_handle; + isvc->incl_srvc_e_handle = incl_srvc_e_handle; isvc->owning_service = service; isvc->included_service = bta_gattc_find_matching_service( p_srvc_cb->p_srvc_cache, incl_srvc_s_handle); @@ -996,6 +998,7 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_ &p_data->value.incl_service.service_type, pri_srvc, p_data->value.incl_service.s_handle, + p_data->value.incl_service.e_handle, BTA_GATTC_ATTR_TYPE_INCL_SRVC); break; @@ -1009,10 +1012,14 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_ break; case GATT_DISC_CHAR_DSCPT: - bta_gattc_add_attr_to_cache(p_srvc_cb, p_data->handle, &p_data->type, 0, - 0 /* incl_srvc_handle */, + bta_gattc_add_attr_to_cache(p_srvc_cb, + p_data->handle, + &p_data->type, + 0, + 0 /* incl_srvc_s_handle */, + 0 /* incl_srvc_e_handle */, BTA_GATTC_ATTR_TYPE_CHAR_DESCR); - break; + break; } } } @@ -1353,7 +1360,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id, BTGATT_DB_INCLUDED_SERVICE, p_isvc->handle, p_isvc->incl_srvc_s_handle /* s_handle */, - 0 /* e_handle */, + p_isvc->incl_srvc_e_handle /* e_handle */, p_isvc->handle, p_isvc->uuid, 0 /* property */); @@ -1920,12 +1927,21 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr, break; case BTA_GATTC_ATTR_TYPE_CHAR_DESCR: + bta_gattc_add_attr_to_cache(p_srvc_cb, + p_attr->s_handle, + &p_attr->uuid, + p_attr->prop, + p_attr->incl_srvc_s_handle, + p_attr->incl_srvc_e_handle, + p_attr->attr_type); + break; case BTA_GATTC_ATTR_TYPE_INCL_SRVC: bta_gattc_add_attr_to_cache(p_srvc_cb, p_attr->s_handle, &p_attr->uuid, p_attr->prop, - p_attr->incl_srvc_handle, + p_attr->incl_srvc_s_handle, + p_attr->incl_srvc_e_handle, p_attr->attr_type); break; } @@ -1944,8 +1960,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr, ** *******************************************************************************/ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_handle, - UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_handle, - BOOLEAN is_primary) + UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_s_handle, + UINT16 incl_srvc_e_handle, BOOLEAN is_primary) { p_attr->s_handle = s_handle; p_attr->e_handle = e_handle; @@ -1953,7 +1969,8 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han p_attr->is_primary = is_primary; p_attr->id = 0; p_attr->prop = prop; - p_attr->incl_srvc_handle = incl_srvc_handle; + p_attr->incl_srvc_s_handle = incl_srvc_s_handle; + p_attr->incl_srvc_e_handle = incl_srvc_e_handle; memcpy(&p_attr->uuid, &uuid, sizeof(tBT_UUID)); } @@ -1993,7 +2010,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id) p_cur_srvc->e_handle, p_cur_srvc->uuid, 0 /* properties */, - 0 /* incl_srvc_handle */, + 0 /* incl_srvc_s_handle */, + 0 /* incl_srvc_e_handle */, p_cur_srvc->is_primary); } @@ -2014,7 +2032,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id) 0, p_char->uuid, p_char->properties, - 0 /* incl_srvc_handle */, + 0 /* incl_srvc_s_handle */, + 0 /* incl_srvc_e_handle */, FALSE); if (!p_char->descriptors || list_is_empty(p_char->descriptors)) @@ -2030,7 +2049,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id) 0, p_desc->uuid, 0 /* properties */, - 0 /* incl_srvc_handle */, + 0 /* incl_srvc_s_handle */, + 0 /* incl_srvc_e_handle */, FALSE); } } @@ -2049,6 +2069,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id) p_isvc->uuid, 0 /* properties */, p_isvc->included_service->s_handle, + p_isvc->included_service->e_handle, FALSE); } } diff --git a/components/bt/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/bluedroid/bta/include/bta/bta_gatt_api.h index 723c7fe26..9e5991751 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_gatt_api.h @@ -282,7 +282,8 @@ typedef struct { UINT8 id; UINT8 prop; /* used when attribute type is characteristic */ BOOLEAN is_primary; /* used when attribute type is service */ - UINT16 incl_srvc_handle; /* used when attribute type is included service */ + UINT16 incl_srvc_s_handle; /* used when attribute type is included service */ + UINT16 incl_srvc_e_handle; /* used when attribute type is included service */ }tBTA_GATTC_NV_ATTR; /* callback data structure */ @@ -691,6 +692,7 @@ typedef struct tBT_UUID uuid; UINT16 handle; UINT16 incl_srvc_s_handle; + UINT16 incl_srvc_e_handle; tBTA_GATTC_SERVICE *owning_service; /* owning service*/ tBTA_GATTC_SERVICE *included_service; } __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC;