Component/bt: fix include service start handle error

This commit is contained in:
zhiweijian 2018-06-07 15:19:20 +08:00
parent 34401afe39
commit 85e88cd0eb
2 changed files with 35 additions and 12 deletions

View file

@ -346,6 +346,7 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
tBT_UUID *p_uuid, tBT_UUID *p_uuid,
UINT8 property, UINT8 property,
UINT16 incl_srvc_s_handle, UINT16 incl_srvc_s_handle,
UINT16 incl_srvc_e_handle,
tBTA_GATTC_ATTR_TYPE type) tBTA_GATTC_ATTR_TYPE type)
{ {
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE) #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; isvc->handle = handle;
memcpy(&isvc->uuid, p_uuid, sizeof(tBT_UUID)); memcpy(&isvc->uuid, p_uuid, sizeof(tBT_UUID));
isvc->incl_srvc_s_handle = incl_srvc_s_handle; isvc->incl_srvc_s_handle = incl_srvc_s_handle;
isvc->incl_srvc_e_handle = incl_srvc_e_handle;
isvc->owning_service = service; isvc->owning_service = service;
isvc->included_service = bta_gattc_find_matching_service( isvc->included_service = bta_gattc_find_matching_service(
p_srvc_cb->p_srvc_cache, incl_srvc_s_handle); 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, &p_data->value.incl_service.service_type,
pri_srvc, pri_srvc,
p_data->value.incl_service.s_handle, p_data->value.incl_service.s_handle,
p_data->value.incl_service.e_handle,
BTA_GATTC_ATTR_TYPE_INCL_SRVC); BTA_GATTC_ATTR_TYPE_INCL_SRVC);
break; break;
@ -1009,10 +1012,14 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
break; break;
case GATT_DISC_CHAR_DSCPT: case GATT_DISC_CHAR_DSCPT:
bta_gattc_add_attr_to_cache(p_srvc_cb, p_data->handle, &p_data->type, 0, bta_gattc_add_attr_to_cache(p_srvc_cb,
0 /* incl_srvc_handle */, p_data->handle,
&p_data->type,
0,
0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
BTA_GATTC_ATTR_TYPE_CHAR_DESCR); 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, BTGATT_DB_INCLUDED_SERVICE,
p_isvc->handle, p_isvc->handle,
p_isvc->incl_srvc_s_handle /* s_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->handle,
p_isvc->uuid, p_isvc->uuid,
0 /* property */); 0 /* property */);
@ -1920,12 +1927,21 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
break; break;
case BTA_GATTC_ATTR_TYPE_CHAR_DESCR: 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: case BTA_GATTC_ATTR_TYPE_INCL_SRVC:
bta_gattc_add_attr_to_cache(p_srvc_cb, bta_gattc_add_attr_to_cache(p_srvc_cb,
p_attr->s_handle, p_attr->s_handle,
&p_attr->uuid, &p_attr->uuid,
p_attr->prop, p_attr->prop,
p_attr->incl_srvc_handle, p_attr->incl_srvc_s_handle,
p_attr->incl_srvc_e_handle,
p_attr->attr_type); p_attr->attr_type);
break; 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, 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, UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_s_handle,
BOOLEAN is_primary) UINT16 incl_srvc_e_handle, BOOLEAN is_primary)
{ {
p_attr->s_handle = s_handle; p_attr->s_handle = s_handle;
p_attr->e_handle = e_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->is_primary = is_primary;
p_attr->id = 0; p_attr->id = 0;
p_attr->prop = prop; 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)); 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->e_handle,
p_cur_srvc->uuid, p_cur_srvc->uuid,
0 /* properties */, 0 /* properties */,
0 /* incl_srvc_handle */, 0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
p_cur_srvc->is_primary); p_cur_srvc->is_primary);
} }
@ -2014,7 +2032,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
0, 0,
p_char->uuid, p_char->uuid,
p_char->properties, p_char->properties,
0 /* incl_srvc_handle */, 0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
FALSE); FALSE);
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) 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, 0,
p_desc->uuid, p_desc->uuid,
0 /* properties */, 0 /* properties */,
0 /* incl_srvc_handle */, 0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
FALSE); FALSE);
} }
} }
@ -2049,6 +2069,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
p_isvc->uuid, p_isvc->uuid,
0 /* properties */, 0 /* properties */,
p_isvc->included_service->s_handle, p_isvc->included_service->s_handle,
p_isvc->included_service->e_handle,
FALSE); FALSE);
} }
} }

View file

@ -282,7 +282,8 @@ typedef struct {
UINT8 id; UINT8 id;
UINT8 prop; /* used when attribute type is characteristic */ UINT8 prop; /* used when attribute type is characteristic */
BOOLEAN is_primary; /* used when attribute type is service */ 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; }tBTA_GATTC_NV_ATTR;
/* callback data structure */ /* callback data structure */
@ -691,6 +692,7 @@ typedef struct
tBT_UUID uuid; tBT_UUID uuid;
UINT16 handle; UINT16 handle;
UINT16 incl_srvc_s_handle; UINT16 incl_srvc_s_handle;
UINT16 incl_srvc_e_handle;
tBTA_GATTC_SERVICE *owning_service; /* owning service*/ tBTA_GATTC_SERVICE *owning_service; /* owning service*/
tBTA_GATTC_SERVICE *included_service; tBTA_GATTC_SERVICE *included_service;
} __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC; } __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC;