diff --git a/example/libusb/ble_client.c b/example/libusb/ble_client.c index aba09e7a2..2c3628e79 100644 --- a/example/libusb/ble_client.c +++ b/example/libusb/ble_client.c @@ -706,10 +706,10 @@ le_command_status_t le_central_discover_characteristics_for_handle_range_by_uuid peripheral->end_group_handle = end_handle; peripheral->filter_with_uuid = 1; peripheral->uuid16 = uuid16; - sdp_normalize_uuid((uint8_t*) &(peripheral->uuid128), peripheral->uuid16); + sdp_normalize_uuid((uint8_t*) &(peripheral->uuid128), uuid16); peripheral->characteristic_start_handle = 0; peripheral->state = P_W2_SEND_CHARACTERISTIC_WITH_UUID_QUERY; - + gatt_client_run(); return BLE_PERIPHERAL_OK; } @@ -728,6 +728,7 @@ le_command_status_t le_central_discover_characteristics_for_handle_range_by_uuid return BLE_PERIPHERAL_OK; } + le_command_status_t le_central_discover_characteristics_for_service_by_uuid16 (le_peripheral_t *peripheral, le_service_t *service, uint16_t uuid16){ return le_central_discover_characteristics_for_handle_range_by_uuid16(peripheral, service->start_group_handle, service->end_group_handle, uuid16); } @@ -1100,7 +1101,7 @@ static void characteristic_start_found(le_peripheral_t * peripheral, uint16_t st uint16_t uuid16; if (uuid_length == 2){ uuid16 = READ_BT_16(uuid, 0); - sdp_normalize_uuid((uint8_t*) uuid128, peripheral->uuid16); + sdp_normalize_uuid((uint8_t*) uuid128, uuid16); } else { swap128(uuid, uuid128); } @@ -1348,7 +1349,6 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa trigger_next_characteristic_query(peripheral, get_last_result_handle(packet, size)); break; case P_W4_CHARACTERISTIC_WITH_UUID_QUERY_RESULT: - report_gatt_characteristics(peripheral, packet, size); trigger_next_characteristic_query(peripheral, get_last_result_handle(packet, size)); break; diff --git a/test/gatt_client/gatt_client.c b/test/gatt_client/gatt_client.c index 474401a92..2c49b6e52 100644 --- a/test/gatt_client/gatt_client.c +++ b/test/gatt_client/gatt_client.c @@ -38,7 +38,9 @@ typedef enum { DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16, DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID128, DISCOVER_CHARACTERISTICS_BY_UUID16, - DISCOVER_CHARACTERISTICS_BY_UUID128 + DISCOVER_CHARACTERISTICS_BY_UUID128, + + DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID } current_test_t; current_test_t test = IDLE; @@ -235,6 +237,9 @@ static void handle_le_central_event(le_central_event_t * event){ case DISCOVER_CHARACTERISTICS_BY_UUID128: CHECK_EQUAL(1, result_index); break; + case DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID: + CHECK_EQUAL(1, result_index); + break; default: break; } @@ -319,22 +324,22 @@ TEST(GATTClient, TestFindIncludedServicesForServiceWithUUID128){ CHECK(result_found); } -TEST(GATTClient, TestDiscoverCharacteristicsForService){ - test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16; - le_central_discover_primary_services_by_uuid16(&test_device, service_uuid16); - CHECK(result_found); +// TEST(GATTClient, TestDiscoverCharacteristicsForService){ +// test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_WITH_UUID16; +// le_central_discover_primary_services_by_uuid16(&test_device, service_uuid16); +// CHECK(result_found); - result_found = 0; - result_index = 0; - le_central_discover_characteristics_for_service(&test_device, &services[0]); - CHECK(result_found); -} +// result_found = 0; +// result_index = 0; +// le_central_discover_characteristics_for_service(&test_device, &services[0]); +// CHECK(result_found); +// } -TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){ - test = DISCOVER_CHARACTERISTICS_BY_UUID16; - le_central_discover_characteristics_for_handle_range_by_uuid16(&test_device, 0x30, 0x32, 0xFFFF); - CHECK(result_found); -} +// TEST(GATTClient, TestDiscoverCharacteristicsByUUID16){ +// test = DISCOVER_CHARACTERISTICS_BY_UUID16; +// le_central_discover_characteristics_for_handle_range_by_uuid16(&test_device, 0x30, 0x32, 0xFFFF); +// CHECK(result_found); +// } TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){ test = DISCOVER_CHARACTERISTICS_BY_UUID128; @@ -342,6 +347,46 @@ TEST(GATTClient, TestDiscoverCharacteristicsByUUID128){ CHECK(result_found); } +TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID128){ + test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID; + le_central_discover_primary_services_by_uuid128 + (&test_device, primary_service_uuid128); + CHECK_EQUAL(1, result_index); + CHECK(result_found); + + result_found = 0; + result_index = 0; + uint8_t characteristic_uuid[] = {0x00, 0x00, 0xF2, 0x01, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; + le_central_discover_characteristics_for_service_by_uuid128(&test_device, &services[0], characteristic_uuid); + CHECK(result_found); + + result_found = 0; + result_index = 0; + le_central_discover_characteristics_for_service_by_uuid16(&test_device, &services[0], 0xF200); + CHECK(result_found); + +} + +TEST(GATTClient, TestDiscoverCharacteristics4ServiceByUUID16){ + test = DISCOVER_CHARACTERISTICS_FOR_SERVICE_BY_UUID; + le_central_discover_primary_services_by_uuid16(&test_device, service_uuid16); + CHECK_EQUAL(1, result_index); + CHECK(result_found); + + result_found = 0; + result_index = 0; + uint8_t characteristic_uuid[]= { 0x00, 0x00, 0xF1, 0x05, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; + le_central_discover_characteristics_for_service_by_uuid128(&test_device, &services[0], characteristic_uuid); + CHECK(result_found); + + result_found = 0; + result_index = 0; + le_central_discover_characteristics_for_service_by_uuid16(&test_device, &services[0], 0xF100); + CHECK(result_found); +} + + + int main (int argc, const char * argv[]){ return CommandLineTestRunner::RunAllTests(argc, argv); }