Merge branch 'bugfix/btdm_add_sequential_check_when_add_include_service' into 'master'

component/bt: add sequential check when add include service

See merge request idf/esp-idf!3277
This commit is contained in:
Jiang Jiang Jian 2018-09-30 14:19:54 +08:00
commit a662002924
2 changed files with 36 additions and 6 deletions

View file

@ -450,6 +450,26 @@ UINT16 gatts_add_included_service (tGATT_SVC_DB *p_db, UINT16 s_handle, UINT16 e
return 0;
}
BOOLEAN is_include_service_allowed = TRUE;
// service declaration
tGATT_ATTR16 *first_attr = (tGATT_ATTR16 *)p_db->p_attr_list;
if (p_db->p_attr_list != NULL) {
tGATT_ATTR16 *next_attr = (tGATT_ATTR16 *)first_attr->p_next;
/* This service already has other attributes */
while (next_attr != NULL) {
if (!(next_attr->uuid_type == GATT_ATTR_UUID_TYPE_16 && next_attr->uuid == GATT_UUID_INCLUDE_SERVICE)) {
is_include_service_allowed = FALSE;
break;
}
next_attr = (tGATT_ATTR16 *)next_attr->p_next;
}
}
if (!is_include_service_allowed) {
GATT_TRACE_ERROR("%s error, The include service should be added before adding the characteristics", __func__);
return 0;
}
if ((p_attr = (tGATT_ATTR16 *) allocate_attr_in_db(p_db, &uuid, GATT_PERM_READ)) != NULL) {
if (copy_extra_byte_in_db(p_db, (void **)&p_attr->p_value, sizeof(tGATT_INCL_SRVC))) {
p_attr->p_value->incl_handle.s_handle = s_handle;

View file

@ -22,9 +22,11 @@
.included_service_connection: &included_primary_service_connection
LIST_MERGE:
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:LoadProfile,OK,A001", "R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA0"
- ["R SSC2 C +GATTS:AddIncludedService,OK"]
- - "SSC SSC2 gatts -S -z add -p 0xA1"
- ["R SSC2 C +GATTS:StartService,OK,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- - "SSC SSC1 bleconn -C -p 0x10 -a <dut2_bt_mac>"
@ -35,7 +37,9 @@
- - "SSC SSC2 gatts -S -z load -p 0xA4"
- ["R SSC2 C +GATTS:StartService,OK,A004"]
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:LoadProfile,OK,A001", "R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - "SSC SSC1 gatts -S -z add -p 0xA1"
- ["R SSC1 C +GATTS:StartService,OK,A001"]
- - "SSC SSC2 gatts -S -z include -p 0xA1 -i 0xA4"
- ["R SSC2 C +GATTS:AddIncludedService,OK"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
@ -102,6 +106,8 @@ test cases:
- - "SSC SSC1 gatts -S -z load -p 0xA0"
- ["R SSC1 C +GATTS:StartService,OK,A000"]
- - "SSC SSC1 gatts -S -z load -p 0xA1"
- ["R SSC1 C +GATTS:CreateService,OK,A001"]
- - "SSC SSC1 gatts -S -z add -p 0xA1"
- ["R SSC1 C +GATTS:StartService,OK,A001"]
- ID: BTSTK_GATT_20001
<<: *GATT_CASE
@ -123,6 +129,8 @@ test cases:
- *included_primary_service_connection
- - "SSC SSC1 gattc -D -z primaryService -p 0x10"
- ["R SSC1 C +GATTC:DiscoverService,A000 C +GATTC:DiscoverService,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- ID: BTSTK_GATT_20002
<<: *GATT_CASE
test point 2: BLE GATT client service / char discovery
@ -147,6 +155,8 @@ test cases:
- ["R SSC1 C +GATTC:DiscoverService,A000 A <handle_range>:GATTC:DiscoverService,A001,(\\d+-\\d+)"]
- - "SSC SSC1 gattc -D -z includedService -p 0x10 -s 0xA001 -i 0xA000 -q <handle_range> -k 1"
- ["R SSC1 C +GATTC:IncludedService,0010,A001,A000"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- ID: BTSTK_GATT_20003
<<: *GATT_CASE
test point 2: BLE GATT client service / char discovery
@ -713,7 +723,7 @@ test cases:
cmd set:
- ""
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- - "SSC SSC1 bleconn -C -p 0x10 -a <dut2_bt_mac>"
@ -742,7 +752,7 @@ test cases:
cmd set:
- ""
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- - "SSC SSC1 bleconn -C -p 0x10 -a <dut2_bt_mac>"
@ -1008,7 +1018,7 @@ test cases:
cmd set:
- ""
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- - "SSC SSC1 bleconn -C -p 0x10 -a <dut2_bt_mac>"
@ -1036,7 +1046,7 @@ test cases:
cmd set:
- ""
- - "SSC SSC2 gatts -S -z load -p 0xA1"
- ["R SSC2 C +GATTS:StartService,OK,A001"]
- ["R SSC2 C +GATTS:CreateService,OK,A001"]
- - SSC SSC1 gattc -F -r <dut2_bt_mac>
- ['R SSC1 C +GATTC:OK']
- - "SSC SSC1 bleconn -C -p 0x10 -a <dut2_bt_mac>"