fixed test compile

This commit is contained in:
mila@ringwald.ch 2014-11-28 16:08:08 +00:00
parent 3f831cdeba
commit e00e1ae87e
3 changed files with 58 additions and 57 deletions

View File

@ -26,5 +26,5 @@
#define MAX_NO_DB_MEM_DEVICE_LINK_KEYS 2 #define MAX_NO_DB_MEM_DEVICE_LINK_KEYS 2
#define MAX_NO_DB_MEM_DEVICE_NAMES 10 #define MAX_NO_DB_MEM_DEVICE_NAMES 10
#define MAX_NO_DB_MEM_SERVICES 1 #define MAX_NO_DB_MEM_SERVICES 1
#define HAVE_MALLOC

View File

@ -5,7 +5,7 @@ CC = g++
BTSTACK_ROOT = ../.. BTSTACK_ROOT = ../..
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
CFLAGS = -DUNIT_TEST -x c++ -g -Wall -I. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include CFLAGS = -DUNIT_TEST -x c++ -g -Wall -I. -I../ -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
LDFLAGS += -L$(CPPUTEST_HOME) -lCppUTest -lCppUTestExt LDFLAGS += -L$(CPPUTEST_HOME) -lCppUTest -lCppUTestExt
COMMON = \ COMMON = \

View File

@ -25,6 +25,7 @@
#include "expected_results.h" #include "expected_results.h"
static uint16_t gatt_client_handle = 0x40; static uint16_t gatt_client_handle = 0x40;
static uint16_t gatt_client_id;
typedef enum { typedef enum {
IDLE, IDLE,
@ -286,7 +287,7 @@ TEST_GROUP(GATTClient){
TEST(GATTClient, TestDiscoverPrimaryServices){ TEST(GATTClient, TestDiscoverPrimaryServices){
test = DISCOVER_PRIMARY_SERVICES; test = DISCOVER_PRIMARY_SERVICES;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services(gatt_client_handle); gatt_client_discover_primary_services(gatt_client_id, gatt_client_handle);
verify_primary_services(); verify_primary_services();
} }
@ -294,14 +295,14 @@ TEST(GATTClient, TestDiscoverPrimaryServices){
TEST(GATTClient, TestDiscoverPrimaryServicesByUUID16){ TEST(GATTClient, TestDiscoverPrimaryServicesByUUID16){
test = DISCOVER_PRIMARY_SERVICE_WITH_UUID16; test = DISCOVER_PRIMARY_SERVICE_WITH_UUID16;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
verify_primary_services_with_uuid16(); verify_primary_services_with_uuid16();
} }
TEST(GATTClient, TestDiscoverPrimaryServicesByUUID128){ TEST(GATTClient, TestDiscoverPrimaryServicesByUUID128){
test = DISCOVER_PRIMARY_SERVICE_WITH_UUID128; test = DISCOVER_PRIMARY_SERVICE_WITH_UUID128;
gatt_client_discover_primary_services_by_uuid128(gatt_client_handle, primary_service_uuid128); gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
verify_primary_services_with_uuid128(); verify_primary_services_with_uuid128();
} }
@ -310,20 +311,20 @@ TEST(GATTClient, TestDiscoverPrimaryServicesByUUID128){
TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID16){ TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID16){
test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID16; test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID16;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
reset_query_state(); reset_query_state();
gatt_client_find_included_services_for_service(gatt_client_handle, &services[0]); gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
verify_included_services_uuid16(); verify_included_services_uuid16();
} }
TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){ TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){
test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID128; test = DISCOVER_INCLUDED_SERVICE_FOR_SERVICE_WITH_UUID128;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid128(gatt_client_handle, primary_service_uuid128); gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
reset_query_state(); reset_query_state();
gatt_client_find_included_services_for_service(gatt_client_handle, &services[0]); gatt_client_find_included_services_for_service(gatt_client_id, gatt_client_handle, &services[0]);
verify_included_services_uuid128(); verify_included_services_uuid128();
} }
@ -332,10 +333,10 @@ TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){
TEST(GATTClient, TestDiscoverCharacteristicsForService){ TEST(GATTClient, TestDiscoverCharacteristicsForService){
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16; test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service(gatt_client_handle, &services[0]); gatt_client_discover_characteristics_for_service(gatt_client_id, gatt_client_handle, &services[0]);
verify_charasteristics(); verify_charasteristics();
} }
@ -343,7 +344,7 @@ TEST(GATTClient, TestDiscoverCharacteristicsForService){
TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){ TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){
test = DISCOVER_CHARACTERISTICS_BY_UUID16; test = DISCOVER_CHARACTERISTICS_BY_UUID16;
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_handle_range_by_uuid16(gatt_client_handle, 0x30, 0x32, 0xF102); gatt_client_discover_characteristics_for_handle_range_by_uuid16(gatt_client_id, gatt_client_handle, 0x30, 0x32, 0xF102);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -351,7 +352,7 @@ TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){
TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){ TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){
test = DISCOVER_CHARACTERISTICS_BY_UUID128; test = DISCOVER_CHARACTERISTICS_BY_UUID128;
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_handle_range_by_uuid128(gatt_client_handle, characteristic_handles[1][0], characteristic_handles[1][1], characteristic_uuids[1]); 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(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -359,16 +360,16 @@ TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){
TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID; test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid128(gatt_client_handle, primary_service_uuid128); gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
uint8_t characteristic_uuid[] = {0x00, 0x00, 0xF2, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 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_handle, &services[0], characteristic_uuid); gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF200); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -376,16 +377,16 @@ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){
TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){
test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID; test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
uint8_t characteristic_uuid[]= { 0x00, 0x00, 0xF1, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; 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_handle, &services[0], characteristic_uuid); gatt_client_discover_characteristics_for_service_by_uuid128(gatt_client_id, gatt_client_handle, &services[0], characteristic_uuid);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -393,15 +394,15 @@ TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){
TEST(GATTClient, TestDiscoverCharacteristicDescriptor){ TEST(GATTClient, TestDiscoverCharacteristicDescriptor){
test = DISCOVER_CHARACTERISTIC_DESCRIPTORS; test = DISCOVER_CHARACTERISTIC_DESCRIPTORS;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristic_descriptors(gatt_client_handle, &characteristics[0]); gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK(result_counter); CHECK(result_counter);
CHECK_EQUAL(3, result_index); CHECK_EQUAL(3, result_index);
CHECK_EQUAL(0x2902, descriptors[0].uuid16); CHECK_EQUAL(0x2902, descriptors[0].uuid16);
@ -412,19 +413,19 @@ TEST(GATTClient, TestDiscoverCharacteristicDescriptor){
TEST(GATTClient, TestReadCharacteristicDescriptor){ TEST(GATTClient, TestReadCharacteristicDescriptor){
test = READ_CHARACTERISTIC_DESCRIPTOR; test = READ_CHARACTERISTIC_DESCRIPTOR;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristic_descriptors(gatt_client_handle, &characteristics[0]); gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
reset_query_state(); reset_query_state();
gatt_client_read_characteristic_descriptor(gatt_client_handle, &descriptors[0]); gatt_client_read_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
} }
@ -433,19 +434,19 @@ TEST(GATTClient, TestReadCharacteristicDescriptor){
TEST(GATTClient, TestWriteCharacteristicDescriptor){ TEST(GATTClient, TestWriteCharacteristicDescriptor){
test = WRITE_CHARACTERISTIC_DESCRIPTOR; test = WRITE_CHARACTERISTIC_DESCRIPTOR;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristic_descriptors(gatt_client_handle, &characteristics[0]); gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
reset_query_state(); reset_query_state();
gatt_client_write_characteristic_descriptor(gatt_client_handle, &descriptors[0], sizeof(indication), indication); gatt_client_write_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(indication), indication);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -454,15 +455,15 @@ TEST(GATTClient, TestWriteCharacteristicDescriptor){
TEST(GATTClient, TestWriteClientCharacteristicConfiguration){ TEST(GATTClient, TestWriteClientCharacteristicConfiguration){
test = WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION; test = WRITE_CLIENT_CHARACTERISTIC_CONFIGURATION;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_write_client_characteristic_configuration(gatt_client_handle, &characteristics[0], GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION); gatt_client_write_client_characteristic_configuration(gatt_client_id, gatt_client_handle, &characteristics[0], GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -470,19 +471,19 @@ TEST(GATTClient, TestWriteClientCharacteristicConfiguration){
TEST(GATTClient, TestReadLongCharacteristicDescriptor){ TEST(GATTClient, TestReadLongCharacteristicDescriptor){
test = READ_LONG_CHARACTERISTIC_DESCRIPTOR; test = READ_LONG_CHARACTERISTIC_DESCRIPTOR;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid128(gatt_client_handle, primary_service_uuid128); gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF200); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristic_descriptors(gatt_client_handle, &characteristics[0]); gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
result_counter = 0; result_counter = 0;
gatt_client_read_long_characteristic_descriptor(gatt_client_handle, &descriptors[0]); gatt_client_read_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0]);
CHECK_EQUAL(result_counter, 7); CHECK_EQUAL(result_counter, 7);
} }
@ -490,19 +491,19 @@ TEST(GATTClient, TestReadLongCharacteristicDescriptor){
TEST(GATTClient, TestWriteLongCharacteristicDescriptor){ TEST(GATTClient, TestWriteLongCharacteristicDescriptor){
test = WRITE_LONG_CHARACTERISTIC_DESCRIPTOR; test = WRITE_LONG_CHARACTERISTIC_DESCRIPTOR;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid128(gatt_client_handle, primary_service_uuid128); gatt_client_discover_primary_services_by_uuid128(gatt_client_id, gatt_client_handle, primary_service_uuid128);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF200); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF200);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristic_descriptors(gatt_client_handle, &characteristics[0]); gatt_client_discover_characteristic_descriptors(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
result_counter = 0; result_counter = 0;
gatt_client_write_long_characteristic_descriptor(gatt_client_handle, &descriptors[0], sizeof(long_value), (uint8_t *)long_value); gatt_client_write_long_characteristic_descriptor(gatt_client_id, gatt_client_handle, &descriptors[0], sizeof(long_value), (uint8_t *)long_value);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -510,15 +511,15 @@ TEST(GATTClient, TestWriteLongCharacteristicDescriptor){
TEST(GATTClient, TestReadCharacteristicValue){ TEST(GATTClient, TestReadCharacteristicValue){
test = READ_CHARACTERISTIC_VALUE; test = READ_CHARACTERISTIC_VALUE;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_read_value_of_characteristic(gatt_client_handle, &characteristics[0]); gatt_client_read_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 3); CHECK_EQUAL(result_counter, 3);
} }
@ -526,15 +527,15 @@ TEST(GATTClient, TestReadCharacteristicValue){
TEST(GATTClient, TestReadLongCharacteristicValue){ TEST(GATTClient, TestReadLongCharacteristicValue){
test = READ_LONG_CHARACTERISTIC_VALUE; test = READ_LONG_CHARACTERISTIC_VALUE;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_read_long_value_of_characteristic(gatt_client_handle, &characteristics[0]); gatt_client_read_long_value_of_characteristic(gatt_client_id, gatt_client_handle, &characteristics[0]);
CHECK_EQUAL(result_counter, 7); CHECK_EQUAL(result_counter, 7);
} }
@ -542,16 +543,16 @@ TEST(GATTClient, TestReadLongCharacteristicValue){
TEST(GATTClient, TestWriteCharacteristicValue){ TEST(GATTClient, TestWriteCharacteristicValue){
test = WRITE_CHARACTERISTIC_VALUE; test = WRITE_CHARACTERISTIC_VALUE;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_write_value_of_characteristic(gatt_client_handle, characteristics[0].value_handle, short_value_length, (uint8_t*)short_value); 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(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
@ -560,31 +561,31 @@ TEST(GATTClient, TestWriteCharacteristicValue){
TEST(GATTClient, TestWriteLongCharacteristicValue){ TEST(GATTClient, TestWriteLongCharacteristicValue){
test = WRITE_LONG_CHARACTERISTIC_VALUE; test = WRITE_LONG_CHARACTERISTIC_VALUE;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_write_long_value_of_characteristic(gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value); 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(result_counter, 1); CHECK_EQUAL(result_counter, 1);
} }
TEST(GATTClient, TestWriteReliableLongCharacteristicValue){ TEST(GATTClient, TestWriteReliableLongCharacteristicValue){
test = WRITE_RELIABLE_LONG_CHARACTERISTIC_VALUE; test = WRITE_RELIABLE_LONG_CHARACTERISTIC_VALUE;
reset_query_state(); reset_query_state();
gatt_client_discover_primary_services_by_uuid16(gatt_client_handle, service_uuid16); gatt_client_discover_primary_services_by_uuid16(gatt_client_id, gatt_client_handle, service_uuid16);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_handle, &services[0], 0xF100); gatt_client_discover_characteristics_for_service_by_uuid16(gatt_client_id, gatt_client_handle, &services[0], 0xF100);
CHECK_EQUAL(result_counter, 1); CHECK_EQUAL(result_counter, 1);
reset_query_state(); reset_query_state();
gatt_client_reliable_write_long_value_of_characteristic(gatt_client_handle, characteristics[0].value_handle, long_value_length, (uint8_t*)long_value); 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(result_counter); CHECK(result_counter);
} }
@ -599,7 +600,7 @@ int main (int argc, const char * argv[]){
att_set_read_callback(&att_read_callback); att_set_read_callback(&att_read_callback);
gatt_client_init(); gatt_client_init();
gatt_client_register_packet_handler(handle_ble_client_event); gatt_client_id = gatt_client_register_packet_handler(handle_ble_client_event);
return CommandLineTestRunner::RunAllTests(argc, argv); return CommandLineTestRunner::RunAllTests(argc, argv);
} }