diff --git a/example/embedded/spp_and_le_counter.c b/example/embedded/spp_and_le_counter.c index a331491b6..a7e726e5c 100644 --- a/example/embedded/spp_and_le_counter.c +++ b/example/embedded/spp_and_le_counter.c @@ -198,11 +198,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 = little_endian_read_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 = little_endian_read_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; + } } /* diff --git a/example/embedded/spp_and_le_counter.gatt b/example/embedded/spp_and_le_counter.gatt index fb0e8a549..8c89da81e 100644 --- a/example/embedded/spp_and_le_counter.gatt +++ b/example/embedded/spp_and_le_counter.gatt @@ -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,