spp_and_le_counter: allow writes on test characteristic

This commit is contained in:
Matthias Ringwald 2016-02-11 10:35:30 +01:00
parent 0af43532f7
commit 07fdcd55d7
2 changed files with 18 additions and 8 deletions

View File

@ -197,11 +197,22 @@ static uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint
// write requests
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){
// printf("WRITE Callback, handle %04x, mode %u, offset %u, data: ", handle, transaction_mode, offset);
// printf_hexdump(buffer, buffer_size);
if (att_handle != ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE) return 0;
le_notification_enabled = READ_BT_16(buffer, 0) == GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION;
return 0;
// ignore cancel sent for new connections
if (transaction_mode == ATT_TRANSACTION_MODE_CANCEL) return 0;
// find characteristic for handle
switch (att_handle){
case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE:
le_notification_enabled = READ_BT_16(buffer, 0) == GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION;
return 0;
case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE:
printf("Write on test characteristic: ");
printf_hexdump(buffer, buffer_size);
return 0;
default:
printf("WRITE Callback, handle %04x, mode %u, offset %u, data: ", con_handle, transaction_mode, offset);
printf_hexdump(buffer, buffer_size);
return 0;
}
}
/*

View File

@ -6,7 +6,6 @@ CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
// Counter Service
PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB
// Counter Characteristic, with read and notify
CHARACTERISTIC, 0000FF11-0000-1000-8000-00805F9B34FB, READ | NOTIFY | DYNAMIC,
// Counter Characteristic, with read, write, write_without_response and notify
CHARACTERISTIC, 0000FF11-0000-1000-8000-00805F9B34FB, READ | NOTIFY | WRITE | WRITE_WITHOUT_RESPONSE | DYNAMIC,