From 1b9692bdb4bfdbc1b19cf0744cc615b97b03895a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 20 Feb 2018 15:47:00 +0100 Subject: [PATCH] example/le_streamer: provide two test characteristics to support test with separate tx/rx --- example/le_streamer.c | 15 ++++++++++++++- example/le_streamer.gatt | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/example/le_streamer.c b/example/le_streamer.c index b22c4c5c9..3e85b36cb 100644 --- a/example/le_streamer.c +++ b/example/le_streamer.c @@ -84,6 +84,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration; typedef struct { char name; int le_notification_enabled; + uint16_t value_handle; hci_con_handle_t connection_handle; int counter; char test_data[200]; @@ -292,7 +293,7 @@ static void streamer(void){ memset(context->test_data, context->counter, context->test_data_len); // send - att_server_notify(context->connection_handle, ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE, (uint8_t*) context->test_data, context->test_data_len); + att_server_notify(context->connection_handle, context->value_handle, (uint8_t*) context->test_data, context->test_data_len); // track test_track_sent(context, context->test_data_len); @@ -322,14 +323,26 @@ static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, le_streamer_connection_t * context = connection_for_conn_handle(con_handle); switch(att_handle){ case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE: + case ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE: context->le_notification_enabled = little_endian_read_16(buffer, 0) == GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION; printf("%c: Notifications enabled %u\n", context->name, context->le_notification_enabled); if (context->le_notification_enabled){ + switch (att_handle){ + case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE: + context->value_handle = ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE; + break; + case ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE: + context->value_handle = ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE; + break; + default: + break; + } att_server_request_can_send_now_event(context->connection_handle); } test_reset(context); break; case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE: + case ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE: test_track_sent(context, buffer_size); break; default: diff --git a/example/le_streamer.gatt b/example/le_streamer.gatt index 507b34ede..5fe3dfef3 100644 --- a/example/le_streamer.gatt +++ b/example/le_streamer.gatt @@ -6,7 +6,9 @@ CHARACTERISTIC, GATT_SERVICE_CHANGED, READ, // Test Service PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB -// Test Characteristic, both write_without_response as well as notify +// Test Characteristic A, write_without_response as well as notify CHARACTERISTIC, 0000FF11-0000-1000-8000-00805F9B34FB, WRITE_WITHOUT_RESPONSE | NOTIFY | DYNAMIC, +// Test Characteristic B, write_without_response as well as notify +CHARACTERISTIC, 0000FF12-0000-1000-8000-00805F9B34FB, WRITE_WITHOUT_RESPONSE | NOTIFY | DYNAMIC,