mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-06 07:00:59 +00:00
example/le_streamer: provide two test characteristics to support test with separate tx/rx
This commit is contained in:
parent
531729b170
commit
1b9692bdb4
@ -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:
|
||||
|
@ -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,
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user