mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-20 18:40:31 +00:00
mocked timer, removed run loop dependency, not all tests work
This commit is contained in:
parent
e00e1ae87e
commit
1bf0402bfe
@ -15,8 +15,6 @@ COMMON = \
|
||||
${BTSTACK_ROOT}/src/linked_list.c \
|
||||
${BTSTACK_ROOT}/src/sdp_util.c \
|
||||
${BTSTACK_ROOT}/src/remote_device_db_memory.c \
|
||||
${BTSTACK_ROOT}/src/run_loop.c \
|
||||
${BTSTACK_ROOT}/platforms/posix/src/run_loop_posix.c \
|
||||
${BTSTACK_ROOT}/src/hci_cmds.c \
|
||||
${BTSTACK_ROOT}/src/hci.c \
|
||||
${BTSTACK_ROOT}/src/hci_dump.c \
|
||||
|
@ -266,11 +266,24 @@ extern "C" uint16_t att_read_callback(uint16_t handle, uint16_t attribute_handle
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char * decode_status(le_command_status_t status){
|
||||
switch (status){
|
||||
case BLE_PERIPHERAL_OK: return "BLE_PERIPHERAL_OKmak";
|
||||
case BLE_PERIPHERAL_IN_WRONG_STATE: return "BLE_PERIPHERAL_IN_WRONG_STATE";
|
||||
case BLE_PERIPHERAL_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS: return "BLE_PERIPHERAL_DIFFERENT_CONTEXT_FOR_ADDRESS_ALREADY_EXISTS";
|
||||
case BLE_PERIPHERAL_NOT_CONNECTED: return "BLE_PERIPHERAL_NOT_CONNECTED";
|
||||
case BLE_VALUE_TOO_LONG: return "BLE_VALUE_TOO_LONG";
|
||||
case BLE_PERIPHERAL_BUSY: return "BLE_PERIPHERAL_BUSY";
|
||||
case BLE_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED: return "BLE_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED";
|
||||
case BLE_CHARACTERISTIC_INDICATION_NOT_SUPPORTED: return "BLE_CHARACTERISTIC_INDICATION_NOT_SUPPORTED";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_GROUP(GATTClient){
|
||||
int acl_buffer_size;
|
||||
uint8_t acl_buffer[27];
|
||||
|
||||
le_command_status_t status;
|
||||
|
||||
void setup(){
|
||||
result_counter = 0;
|
||||
result_index = 0;
|
||||
@ -287,7 +300,8 @@ TEST_GROUP(GATTClient){
|
||||
TEST(GATTClient, TestDiscoverPrimaryServices){
|
||||
test = DISCOVER_PRIMARY_SERVICES;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services(gatt_client_id, gatt_client_handle);
|
||||
status = gatt_client_discover_primary_services(gatt_client_id, gatt_client_handle);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
verify_primary_services();
|
||||
}
|
||||
|
||||
@ -295,14 +309,17 @@ TEST(GATTClient, TestDiscoverPrimaryServices){
|
||||
TEST(GATTClient, TestDiscoverPrimaryServicesByUUID16){
|
||||
test = DISCOVER_PRIMARY_SERVICE_WITH_UUID16;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
verify_primary_services_with_uuid16();
|
||||
}
|
||||
|
||||
|
||||
TEST(GATTClient, TestDiscoverPrimaryServicesByUUID128){
|
||||
test = DISCOVER_PRIMARY_SERVICE_WITH_UUID128;
|
||||
gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
status = gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
verify_primary_services_with_uuid128();
|
||||
}
|
||||
@ -311,20 +328,24 @@ TEST(GATTClient, TestDiscoverPrimaryServicesByUUID128){
|
||||
TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID16){
|
||||
test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID16;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
status = gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
verify_included_services_uuid16();
|
||||
}
|
||||
|
||||
TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){
|
||||
test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID128;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
|
||||
status = gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
status = gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
verify_included_services_uuid128();
|
||||
}
|
||||
|
||||
@ -333,10 +354,12 @@ TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){
|
||||
TEST(GATTClient, TestDiscoverCharacteristicsForService){
|
||||
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
status = gatt_client_discover_characteristics_for_service(gatt_client_id, gatt_client_handle, &services[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
verify_charasteristics();
|
||||
}
|
||||
|
||||
@ -344,7 +367,8 @@ TEST(GATTClient, TestDiscoverCharacteristicsForService){
|
||||
TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){
|
||||
test = DISCOVER_CHARACTERISTICS_BY_UUID16;
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_handle_range_by_uuid16(gatt_client_id, gatt_client_handle, 0x30, 0x32, 0xF102);
|
||||
status = gatt_client_discover_characteristics_for_handle_range_by_uuid16(gatt_client_id, gatt_client_handle, 0x30, 0x32, 0xF102);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
@ -352,7 +376,8 @@ TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){
|
||||
TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){
|
||||
test = DISCOVER_CHARACTERISTICS_BY_UUID128;
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_handle_range_by_uuid128(gatt_client_id, gatt_client_handle, characteristic_handles[1][0], characteristic_handles[1][1], characteristic_uuids[1]);
|
||||
status = gatt_client_discover_characteristics_for_handle_range_by_uuid128(gatt_client_id, gatt_client_handle, characteristic_handles[1][0], characteristic_handles[1][1], characteristic_uuids[1]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
@ -360,16 +385,19 @@ TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){
|
||||
TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){
|
||||
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
status = gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
uint8_t characteristic_uuid[] = {0x00, 0x00, 0xF2, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
@ -377,16 +405,19 @@ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){
|
||||
TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){
|
||||
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
uint8_t characteristic_uuid[]= { 0x00, 0x00, 0xF1, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
@ -394,15 +425,18 @@ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){
|
||||
TEST(GATTClient, TestDiscoverCharacteristicDescriptor){
|
||||
test = DISCOVER_CHARACTERISTIC_DESCRIPTORS;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK(result_counter);
|
||||
CHECK_EQUAL(3, result_index);
|
||||
CHECK_EQUAL(0x2902, descriptors[0].uuid16);
|
||||
@ -410,80 +444,96 @@ TEST(GATTClient, TestDiscoverCharacteristicDescriptor){
|
||||
CHECK_EQUAL(0x2901, descriptors[2].uuid16);
|
||||
}
|
||||
|
||||
|
||||
TEST(GATTClient, TestReadCharacteristicDescriptor){
|
||||
test = READ_CHARACTERISTIC_DESCRIPTOR;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_read_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
|
||||
status = gatt_client_read_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
TEST(GATTClient, TestWriteCharacteristicDescriptor){
|
||||
test = WRITE_CHARACTERISTIC_DESCRIPTOR;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_write_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(indication), indication);
|
||||
status = gatt_client_write_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(indication), indication);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
TEST(GATTClient, TestWriteClientCharacteristicConfiguration){
|
||||
test = WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_write_client_characteristic_configuration(gatt_client_id, gatt_client_handle, &characteristics[0], GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION);
|
||||
status = gatt_client_write_client_characteristic_configuration(gatt_client_id, gatt_client_handle, &characteristics[0], GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(GATTClient, TestReadLongCharacteristicDescriptor){
|
||||
test = READ_LONG_CHARACTERISTIC_DESCRIPTOR;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
status = gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
|
||||
result_counter = 0;
|
||||
gatt_client_read_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
|
||||
status = gatt_client_read_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 7);
|
||||
}
|
||||
|
||||
@ -491,51 +541,62 @@ TEST(GATTClient, TestReadLongCharacteristicDescriptor){
|
||||
TEST(GATTClient, TestWriteLongCharacteristicDescriptor){
|
||||
test = WRITE_LONG_CHARACTERISTIC_DESCRIPTOR;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
status = gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
|
||||
result_counter = 0;
|
||||
gatt_client_write_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(long_value), (uint8_t *)long_value);
|
||||
status = gatt_client_write_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(long_value), (uint8_t *)long_value);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
TEST(GATTClient, TestReadCharacteristicValue){
|
||||
test = READ_CHARACTERISTIC_VALUE;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_read_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_read_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 3);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TEST(GATTClient, TestReadLongCharacteristicValue){
|
||||
test = READ_LONG_CHARACTERISTIC_VALUE;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_read_long_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
status = gatt_client_read_long_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 7);
|
||||
}
|
||||
|
||||
@ -543,16 +604,19 @@ TEST(GATTClient, TestReadLongCharacteristicValue){
|
||||
TEST(GATTClient, TestWriteCharacteristicValue){
|
||||
test = WRITE_CHARACTERISTIC_VALUE;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_write_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, short_value_length, (uint8_t*)short_value);
|
||||
status = gatt_client_write_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, short_value_length, (uint8_t*)short_value);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
@ -561,46 +625,48 @@ TEST(GATTClient, TestWriteCharacteristicValue){
|
||||
TEST(GATTClient, TestWriteLongCharacteristicValue){
|
||||
test = WRITE_LONG_CHARACTERISTIC_VALUE;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_write_long_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value);
|
||||
status = gatt_client_write_long_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
}
|
||||
|
||||
TEST(GATTClient, TestWriteReliableLongCharacteristicValue){
|
||||
test = WRITE_RELIABLE_LONG_CHARACTERISTIC_VALUE;
|
||||
reset_query_state();
|
||||
gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
status = gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
status = gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK_EQUAL(result_counter, 1);
|
||||
|
||||
reset_query_state();
|
||||
gatt_client_reliable_write_long_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value);
|
||||
status = gatt_client_reliable_write_long_value_of_characteristic(gatt_client_id, gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value);
|
||||
CHECK_EQUAL(status, BLE_PERIPHERAL_OK);
|
||||
CHECK(result_counter);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
|
||||
run_loop_init(RUN_LOOP_POSIX);
|
||||
// hci_dump_open("/tmp/test.pklg", HCI_DUMP_STDOUT);
|
||||
|
||||
att_set_db(profile_data);
|
||||
att_set_write_callback(&att_write_callback);
|
||||
att_set_read_callback(&att_read_callback);
|
||||
|
||||
gatt_client_init();
|
||||
gatt_client_id = gatt_client_register_packet_handler(handle_ble_client_event);
|
||||
|
||||
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
}
|
||||
|
@ -106,6 +106,21 @@ void sm_cmac_start(sm_key_t k, uint16_t message_len, uint8_t * message, void (*d
|
||||
|
||||
}
|
||||
|
||||
void run_loop_set_timer(timer_source_t *a, uint32_t timeout_in_ms){
|
||||
}
|
||||
|
||||
// Set callback that will be executed when timer expires.
|
||||
void run_loop_set_timer_handler(timer_source_t *ts, void (*process)(timer_source_t *_ts)){
|
||||
}
|
||||
|
||||
// Add/Remove timer source.
|
||||
void run_loop_add_timer(timer_source_t *timer){
|
||||
}
|
||||
|
||||
int run_loop_remove_timer(timer_source_t *timer){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// int hci_send_cmd(const hci_cmd_t *cmd, ...){
|
||||
// // printf("hci_send_cmd opcode 0x%02x\n", cmd->opcode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user