xref: /btstack/src/ble/gatt-service/hids_device.c (revision 160eac513706684ffbc50a2103cd175d3d1f8a53)
1 /*
2  * Copyright (C) 2014 BlueKitchen GmbH
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holders nor the names of
14  *    contributors may be used to endorse or promote products derived
15  *    from this software without specific prior written permission.
16  * 4. Any redistribution, use, or modification is done solely for
17  *    personal benefit and not for any commercial purpose or for
18  *    monetary gain.
19  *
20  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
24  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
30  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * Please inquire about commercial licensing options at
34  * [email protected]
35  *
36  */
37 
38 #define BTSTACK_FILE__ "hids_device.c"
39 
40 /**
41  * Implementation of the GATT HIDS Device
42  * To use with your application, add '#import <hids.gatt>' to your .gatt file
43  */
44 
45 #include "hids_device.h"
46 
47 #include "ble/att_db.h"
48 #include "ble/att_server.h"
49 #include "bluetooth_gatt.h"
50 #include "btstack_util.h"
51 #include "btstack_debug.h"
52 
53 #define HIDS_DEVICE_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS    0x80
54 
55 // storage for 'generic' HID Device with single Input, Output, and Feature Report
56 static hids_device_report_t hid_reports_generic_storage[3];
57 
58 typedef struct{
59     uint16_t        con_handle;
60 
61     uint8_t         hid_country_code;
62     const uint8_t * hid_descriptor;
63     uint16_t        hid_descriptor_size;
64 
65     uint16_t        hid_report_map_handle;
66     uint8_t         hid_protocol_mode;
67     uint16_t        hid_protocol_mode_value_handle;
68 
69     uint16_t        hid_boot_mouse_input_value_handle;
70     uint16_t        hid_boot_mouse_input_client_configuration_handle;
71     uint16_t        hid_boot_mouse_input_client_configuration_value;
72 
73     uint16_t        hid_boot_keyboard_input_value_handle;
74     uint16_t        hid_boot_keyboard_input_client_configuration_handle;
75     uint16_t        hid_boot_keyboard_input_client_configuration_value;
76 
77     hids_device_report_t * hid_reports;
78 
79     uint8_t         hid_input_reports_num;
80     uint8_t         hid_output_reports_num;
81     uint8_t         hid_feature_reports_num;
82 
83     uint16_t        hid_control_point_value_handle;
84     uint8_t         hid_control_point_suspend;
85 
86     btstack_context_callback_registration_t  battery_callback;
87 } hids_device_t;
88 
89 static hids_device_t hids_device;
90 
91 static btstack_packet_handler_t packet_handler;
92 static att_service_handler_t hid_service;
93 
94 // TODO: store hids device connection into list
95 static hids_device_t * hids_device_get_instance_for_con_handle(uint16_t con_handle){
96     UNUSED(con_handle);
97     return &hids_device;
98 }
99 
100 static hids_device_t * hids_device_create_instance(void){
101     memset(&hids_device, 0, sizeof(hids_device_t));
102     return &hids_device;
103 }
104 
105 static hids_device_report_t * hids_device_get_report_for_client_configuration_handle(hids_device_t * device, uint16_t client_configuration_handle){
106     uint8_t pos = 0;
107     while (pos < (device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num)){
108         if (device->hid_reports[pos].client_configuration_handle == client_configuration_handle){
109             return &device->hid_reports[pos];
110         }
111     }
112     return NULL;
113 }
114 
115 static hids_device_report_t * hids_device_get_report_for_id(hids_device_t * device, uint16_t report_id){
116     uint8_t pos = 0;
117     while (pos < (device->hid_input_reports_num + device->hid_output_reports_num + device->hid_feature_reports_num)){
118         if (device->hid_reports[pos].id == report_id){
119             return &device->hid_reports[pos];
120         }
121     }
122     return NULL;
123 }
124 
125 static void hids_device_emit_event_with_uint8(uint8_t event, hci_con_handle_t con_handle, uint8_t value){
126     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
127     if (!instance){
128         log_error("no instance for handle 0x%02x", con_handle);
129         return;
130     }
131 
132     if (!packet_handler) return;
133     uint8_t buffer[6];
134     buffer[0] = HCI_EVENT_HIDS_META;
135     buffer[1] = 4;
136     buffer[2] = event;
137     little_endian_store_16(buffer, 3, (uint16_t) con_handle);
138     buffer[5] = value;
139     (*packet_handler)(HCI_EVENT_PACKET, 0, buffer, sizeof(buffer));
140 }
141 
142 static void hids_device_emit_event(uint8_t event, hci_con_handle_t con_handle){
143     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
144     if (!instance){
145         log_error("no instance for handle 0x%02x", con_handle);
146         return;
147     }
148 
149     if (!packet_handler) return;
150     uint8_t buffer[5];
151     buffer[0] = HCI_EVENT_HIDS_META;
152     buffer[1] = 4;
153     buffer[2] = event;
154     little_endian_store_16(buffer, 3, (uint16_t) con_handle);
155     (*packet_handler)(HCI_EVENT_PACKET, 0, buffer, sizeof(buffer));
156 }
157 
158 static void hids_device_can_send_now(void * context){
159     hci_con_handle_t con_handle = (hci_con_handle_t) (uintptr_t) context;
160     // notify client
161     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
162     if (!instance){
163         log_error("no instance for handle 0x%02x", con_handle);
164         return;
165     }
166 
167     if (!packet_handler) return;
168     uint8_t buffer[5];
169     buffer[0] = HCI_EVENT_HIDS_META;
170     buffer[1] = 3;
171     buffer[2] = HIDS_SUBEVENT_CAN_SEND_NOW;
172     little_endian_store_16(buffer, 3, (uint16_t) con_handle);
173     (*packet_handler)(HCI_EVENT_PACKET, 0, buffer, sizeof(buffer));
174 }
175 
176 // ATT Client Read Callback for Dynamic Data
177 // - if buffer == NULL, don't copy data, just return size of value
178 // - if buffer != NULL, copy data and return number bytes copied
179 static uint16_t att_read_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){
180     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
181     if (!instance){
182         log_error("no instance for handle 0x%02x", con_handle);
183         return HIDS_DEVICE_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS;
184     }
185 
186     if (att_handle == instance->hid_protocol_mode_value_handle){
187         log_info("Read protocol mode");
188         return att_read_callback_handle_byte(instance->hid_protocol_mode, offset, buffer, buffer_size);
189     }
190 
191     if (att_handle == instance->hid_report_map_handle){
192         log_info("Read report map");
193         return att_read_callback_handle_blob(instance->hid_descriptor, instance->hid_descriptor_size, offset, buffer, buffer_size);
194     }
195 
196     if (att_handle == instance->hid_boot_mouse_input_client_configuration_handle){
197         return att_read_callback_handle_little_endian_16(instance->hid_boot_mouse_input_client_configuration_value, offset, buffer, buffer_size);
198     }
199 
200     if (att_handle == instance->hid_boot_keyboard_input_client_configuration_handle){
201         return att_read_callback_handle_little_endian_16(instance->hid_boot_keyboard_input_client_configuration_value, offset, buffer, buffer_size);
202     }
203 
204     if (att_handle == instance->hid_control_point_value_handle){
205         if (buffer && (buffer_size >= 1u)){
206             buffer[0] = instance->hid_control_point_suspend;
207         }
208         return 1;
209     }
210 
211     hids_device_report_t * report = hids_device_get_report_for_client_configuration_handle(instance, att_handle);
212     if (report != NULL){
213         return att_read_callback_handle_little_endian_16(report->client_configuration_value, offset, buffer, buffer_size);
214     }
215     return 0;
216 }
217 
218 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){
219     UNUSED(transaction_mode);
220     UNUSED(buffer_size);
221     UNUSED(offset);
222 
223     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
224     if (!instance){
225         log_error("no instance for handle 0x%02x", con_handle);
226         return HIDS_DEVICE_ERROR_CODE_INAPPROPRIATE_CONNECTION_PARAMETERS;
227     }
228 
229     if (att_handle == instance->hid_boot_mouse_input_client_configuration_handle){
230         uint16_t new_value = little_endian_read_16(buffer, 0);
231         instance->hid_boot_mouse_input_client_configuration_value = new_value;
232         hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_MOUSE_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value);
233     }
234     if (att_handle == instance->hid_boot_keyboard_input_client_configuration_handle){
235         uint16_t new_value = little_endian_read_16(buffer, 0);
236         instance->hid_boot_keyboard_input_client_configuration_value = new_value;
237         hids_device_emit_event_with_uint8(HIDS_SUBEVENT_BOOT_KEYBOARD_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value);
238     }
239 
240     if (att_handle == instance->hid_protocol_mode_value_handle){
241         instance->hid_protocol_mode = buffer[0];
242         log_info("Set protocol mode: %u", instance->hid_protocol_mode);
243         hids_device_emit_event_with_uint8(HIDS_SUBEVENT_PROTOCOL_MODE, con_handle, instance->hid_protocol_mode);
244     }
245 
246     if (att_handle == instance->hid_control_point_value_handle){
247         if (buffer_size < 1u){
248             return ATT_ERROR_INVALID_OFFSET;
249         }
250         instance->hid_control_point_suspend = buffer[0];
251         instance->con_handle = con_handle;
252         log_info("Set suspend tp: %u", instance->hid_control_point_suspend );
253         if (instance->hid_control_point_suspend == 0u){
254             hids_device_emit_event(HIDS_SUBEVENT_SUSPEND, con_handle);
255         } else if (instance->hid_control_point_suspend == 1u){
256             hids_device_emit_event(HIDS_SUBEVENT_EXIT_SUSPEND, con_handle);
257         }
258     }
259 
260     hids_device_report_t * report = hids_device_get_report_for_client_configuration_handle(instance, att_handle);
261     if (report != NULL){
262         uint16_t new_value = little_endian_read_16(buffer, 0);
263         report->client_configuration_value = new_value;
264         log_info("Enable Report (type %u) notifications: %x", (uint8_t) report->type, new_value);
265 
266         switch (report->type){
267             case HID_REPORT_TYPE_INPUT:
268                 hids_device_emit_event_with_uint8(HIDS_SUBEVENT_INPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value);
269                 break;
270             case HID_REPORT_TYPE_OUTPUT:
271                 hids_device_emit_event_with_uint8(HIDS_SUBEVENT_OUTPUT_REPORT_ENABLE, con_handle, (uint8_t) new_value);
272                 break;
273             case HID_REPORT_TYPE_FEATURE:
274                 hids_device_emit_event_with_uint8(HIDS_SUBEVENT_FEATURE_REPORT_ENABLE, con_handle, (uint8_t) new_value);
275                 break;
276             default:
277                 btstack_unreachable();
278                 break;
279         }
280     }
281     return 0;
282 }
283 
284 void hids_device_init_with_storage(uint8_t hid_country_code, const uint8_t * hid_descriptor, uint16_t hid_descriptor_size,
285     uint16_t num_reports, hids_device_report_t * report_storage){
286 
287     hids_device_t * instance = hids_device_create_instance();
288 
289     btstack_assert(num_reports > 0);
290     btstack_assert(report_storage != NULL);
291 
292     instance->hid_country_code    = hid_country_code;
293     instance->hid_descriptor      = hid_descriptor;
294     instance->hid_descriptor_size = hid_descriptor_size;
295 
296     // default
297     instance->hid_protocol_mode   = 1;
298 
299     // get service handle range
300     uint16_t start_handle = 0;
301     uint16_t end_handle   = 0xffff;
302     int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_HUMAN_INTERFACE_DEVICE, &start_handle, &end_handle);
303     btstack_assert(service_found != 0);
304     UNUSED(service_found);
305 
306     // get report map handle
307     instance->hid_report_map_handle                               = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_REPORT_MAP);
308 
309     // get report map handle
310     instance->hid_protocol_mode_value_handle                      = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_PROTOCOL_MODE);
311 
312     // get value and client configuration handles for boot mouse input, boot keyboard input and report input
313     instance->hid_boot_mouse_input_value_handle                   = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_BOOT_MOUSE_INPUT_REPORT);
314     instance->hid_boot_mouse_input_client_configuration_handle    = gatt_server_get_client_configuration_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_BOOT_MOUSE_INPUT_REPORT);
315 
316     instance->hid_boot_keyboard_input_value_handle                = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_BOOT_KEYBOARD_INPUT_REPORT);
317     instance->hid_boot_keyboard_input_client_configuration_handle = gatt_server_get_client_configuration_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_BOOT_KEYBOARD_INPUT_REPORT);
318 
319     instance->hid_control_point_value_handle = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_HID_CONTROL_POINT);
320 
321     log_info("hid_report_map_handle                               0x%02x", instance->hid_report_map_handle);
322     log_info("hid_protocol_mode_value_handle                      0x%02x", instance->hid_protocol_mode_value_handle);
323     log_info("hid_boot_mouse_input_value_handle                   0x%02x", instance->hid_boot_mouse_input_value_handle);
324     log_info("hid_boot_mouse_input_client_configuration_handle    0x%02x", instance->hid_boot_mouse_input_client_configuration_handle);
325     log_info("hid_boot_keyboard_input_value_handle                0x%02x", instance->hid_boot_keyboard_input_value_handle);
326     log_info("hid_boot_keyboard_input_client_configuration_handle 0x%02x", instance->hid_boot_keyboard_input_client_configuration_handle);
327     log_info("hid_control_point_value_handle                      0x%02x", instance->hid_control_point_value_handle);
328 
329     instance->hid_reports = report_storage;
330 
331     uint16_t hid_reports_num = num_reports;
332     uint16_t assigned_reports_num = 0;
333     uint16_t start_chr_handle = start_handle;
334 
335     while ( (start_chr_handle < end_handle) && (assigned_reports_num < hid_reports_num)) {
336         uint16_t chr_value_handle = gatt_server_get_value_handle_for_characteristic_with_uuid16(start_chr_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_REPORT);
337         if (chr_value_handle == 0){
338             break;
339         }
340 
341         uint16_t chr_client_configuration_handle = gatt_server_get_client_configuration_handle_for_characteristic_with_uuid16(start_chr_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_REPORT);
342         uint16_t report_reference_handle = gatt_server_get_descriptor_handle_for_characteristic_with_uuid16(start_chr_handle, end_handle, ORG_BLUETOOTH_CHARACTERISTIC_REPORT, ORG_BLUETOOTH_DESCRIPTOR_REPORT_REFERENCE);
343         uint16_t report_reference_value_len;
344         const uint8_t * report_reference_value = gatt_server_get_const_value_for_handle(report_reference_handle, &report_reference_value_len);
345 
346         if (report_reference_value == NULL){
347             break;
348         }
349         if (report_reference_value_len != 2){
350             break;
351         }
352 
353         hids_device_report_t * report = &report_storage[assigned_reports_num];
354         report->value_handle = chr_value_handle;
355         report->client_configuration_handle = chr_client_configuration_handle;
356         report->client_configuration_value = 0;
357 
358         report->id = report_reference_value[0];
359         report->type = (hid_report_type_t)report_reference_value[1];
360 
361         switch (report->type){
362             case HID_REPORT_TYPE_INPUT:
363                 instance->hid_input_reports_num++;
364                 break;
365             case HID_REPORT_TYPE_OUTPUT:
366                 instance->hid_output_reports_num++;
367                 break;
368             case HID_REPORT_TYPE_FEATURE:
369                 instance->hid_feature_reports_num++;
370                 break;
371             default:
372                 btstack_unreachable();
373                 return;
374         }
375         log_info("hid_report_value_handle                       0x%02x, id %u, type %u", report->value_handle, report->id, (uint8_t)report->type);
376         log_info("hid_report_client_configuration_handle        0x%02x", report->client_configuration_handle);
377 
378         assigned_reports_num++;
379         start_chr_handle = chr_client_configuration_handle + 1;
380     }
381 
382     // register service with ATT Server
383     hid_service.start_handle   = start_handle;
384     hid_service.end_handle     = end_handle;
385     hid_service.read_callback  = &att_read_callback;
386     hid_service.write_callback = &att_write_callback;
387     att_server_register_service_handler(&hid_service);
388 }
389 
390 /**
391  * @brief Set up HIDS Device
392  */
393 void hids_device_init(uint8_t country_code, const uint8_t * descriptor, uint16_t descriptor_size){
394     uint16_t hid_reports_num = sizeof(hid_reports_generic_storage) / sizeof(hids_device_report_t);
395     hids_device_init_with_storage(country_code, descriptor, descriptor_size, hid_reports_num, hid_reports_generic_storage);
396 }
397 
398 /**
399  * @brief Register callback for the HIDS Device client.
400  * @param callback
401  */
402 void hids_device_register_packet_handler(btstack_packet_handler_t callback){
403     packet_handler = callback;
404 }
405 
406 /**
407  * @brief Request can send now event to send HID Report
408  * Generates an HIDS_SUBEVENT_CAN_SEND_NOW subevent
409  * @param hid_cid
410  */
411 void hids_device_request_can_send_now_event(hci_con_handle_t con_handle){
412     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
413     if (!instance){
414         log_error("no instance for handle 0x%02x", con_handle);
415         return;
416     }
417 
418     instance->battery_callback.callback = &hids_device_can_send_now;
419     instance->battery_callback.context  = (void*) (uintptr_t) con_handle;
420     att_server_register_can_send_now_callback(&instance->battery_callback, con_handle);
421 }
422 
423 /**
424  * @brief Send HID Report: Input
425  */
426 
427 uint8_t hids_device_send_report_with_id(hci_con_handle_t con_handle, uint16_t report_id, const uint8_t * report, uint16_t report_len){
428     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
429     if (!instance){
430         log_error("no instance for handle 0x%02x", con_handle);
431         return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
432     }
433 
434     hids_device_report_t * report_storage = hids_device_get_report_for_id(instance, report_id);
435     if (report_storage == NULL){
436         return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
437     }
438 
439     return att_server_notify(con_handle, report_storage->value_handle, report, report_len);
440 }
441 
442 static uint8_t hids_device_send_report_with_type(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len, hid_report_type_t report_type){
443     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
444     if (!instance){
445         log_error("no instance for handle 0x%02x", con_handle);
446         return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
447     }
448 
449     uint8_t pos = 0;
450     while (pos < (instance->hid_input_reports_num + instance->hid_output_reports_num + instance->hid_feature_reports_num)){
451         hids_device_report_t * report_storage = &instance->hid_reports[pos];
452 
453         if (report_storage->type == report_type){
454             return att_server_notify(con_handle, report_storage->value_handle, report, report_len);
455         }
456     }
457     return ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
458 }
459 
460 void hids_device_send_input_report(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len){
461     (void)hids_device_send_report_with_type(con_handle, report, report_len, HID_REPORT_TYPE_INPUT);
462 }
463 
464 /**
465  * @brief Send HID Report: Output
466  */
467 void hids_device_send_output_report(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len){
468     (void)hids_device_send_report_with_type(con_handle, report, report_len, HID_REPORT_TYPE_OUTPUT);
469 }
470 
471 /**
472  * @brief Send HID Report: Feature
473  */
474 void hids_device_send_feature_report(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len){
475     (void)hids_device_send_report_with_type(con_handle, report, report_len, HID_REPORT_TYPE_FEATURE);
476 }
477 
478 /**
479  * @brief Send HID Boot Mouse Input Report
480  */
481 void hids_device_send_boot_mouse_input_report(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len){
482     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
483     if (!instance){
484         log_error("no instance for handle 0x%02x", con_handle);
485         return;
486     }
487     att_server_notify(con_handle, instance->hid_boot_mouse_input_value_handle, report, report_len);
488 }
489 
490 /**
491  * @brief Send HID Boot Mouse Input Report
492  */
493 void hids_device_send_boot_keyboard_input_report(hci_con_handle_t con_handle, const uint8_t * report, uint16_t report_len){
494     hids_device_t * instance = hids_device_get_instance_for_con_handle(con_handle);
495     if (!instance){
496         log_error("no instance for handle 0x%02x", con_handle);
497         return;
498     }
499     att_server_notify(con_handle, instance->hid_boot_keyboard_input_value_handle, report, report_len);
500 }
501