mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
example: le_streamer add write_without_response characteristic
This commit is contained in:
parent
f8d88472fc
commit
3f390fa98a
@ -229,9 +229,19 @@ static void streamer(void){
|
||||
|
||||
/* LISTING_START(attWrite): ATT Write */
|
||||
static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t 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;
|
||||
test_reset();
|
||||
// printf("att_write_callback att_handle %04x, transaction mode %u\n", att_handle, transaction_mode);
|
||||
if (transaction_mode != ATT_TRANSACTION_MODE_NONE) return 0;
|
||||
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;
|
||||
printf("Notifications enabled %u\n", le_notification_enabled);
|
||||
test_reset();
|
||||
break;
|
||||
case ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE:
|
||||
printf("Write to ...FF12...: ");
|
||||
printf_hexdump(buffer, buffer_size);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/* LISTING_END */
|
||||
|
@ -6,7 +6,9 @@ CHARACTERISTIC, GATT_SERVICE_CHANGED, READ,
|
||||
|
||||
// Test Service
|
||||
PRIMARY_SERVICE, 0000FF10-0000-1000-8000-00805F9B34FB
|
||||
// Test Characteristic, only with notify
|
||||
// Test Characteristic, only notify
|
||||
CHARACTERISTIC, 0000FF11-0000-1000-8000-00805F9B34FB, NOTIFY,
|
||||
// Test Characterisitic, only write_without_response
|
||||
CHARACTERISTIC, 0000FF12-0000-1000-8000-00805F9B34FB, WRITE_WITHOUT_RESPONSE | DYNAMIC,
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user