File tree Expand file tree Collapse file tree 2 files changed +26
-7
lines changed
include/bluetooth/services
subsys/bluetooth/services Expand file tree Collapse file tree 2 files changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -170,6 +170,13 @@ struct bt_hids_rep {
170170 */
171171typedef void (* bt_hids_notify_handler_t ) (enum bt_hids_notify_evt evt );
172172
173+ /** @brief HID notification event handler, with report identification.
174+ *
175+ * @param report_id Report ID defined in the HIDS Report Map.
176+ * @param evt Notification event.
177+ */
178+ typedef void (* bt_hids_notify_ext_handler_t ) (uint8_t report_id , enum bt_hids_notify_evt evt );
179+
173180/** @brief HID Report event handler.
174181 *
175182 * @param rep Pointer to the report descriptor.
@@ -228,8 +235,15 @@ struct bt_hids_inp_rep {
228235 */
229236 const uint8_t * rep_mask ;
230237
231- /** Callback with the notification event. */
238+ /** Callback with the notification event.
239+ * Used if set and extended callback is not set.
240+ */
232241 bt_hids_notify_handler_t handler ;
242+
243+ /** Extended callback with the notification event.
244+ * Has preference over the normal callback.
245+ */
246+ bt_hids_notify_ext_handler_t handler_ext ;
233247};
234248
235249
Original file line number Diff line number Diff line change @@ -477,16 +477,21 @@ static void hids_input_report_ccc_changed(struct bt_gatt_attr const *attr,
477477 CONTAINER_OF ((struct _bt_gatt_ccc * )attr -> user_data ,
478478 struct bt_hids_inp_rep , ccc );
479479
480+ uint8_t report_id = inp_rep -> id ;
481+ enum bt_hids_notify_evt evt ;
482+
480483 if (value == BT_GATT_CCC_NOTIFY ) {
481484 LOG_DBG ("Notification has been turned on" );
482- if (inp_rep -> handler != NULL ) {
483- inp_rep -> handler (BT_HIDS_CCCD_EVT_NOTIFY_ENABLED );
484- }
485+ evt = BT_HIDS_CCCD_EVT_NOTIFY_ENABLED ;
485486 } else {
486487 LOG_DBG ("Notification has been turned off" );
487- if (inp_rep -> handler != NULL ) {
488- inp_rep -> handler (BT_HIDS_CCCD_EVT_NOTIFY_DISABLED );
489- }
488+ evt = BT_HIDS_CCCD_EVT_NOTIFY_DISABLED ;
489+ }
490+
491+ if (inp_rep -> handler_ext != NULL ) {
492+ inp_rep -> handler_ext (report_id , evt );
493+ } else if (inp_rep -> handler != NULL ) {
494+ inp_rep -> handler (evt );
490495 }
491496}
492497
You can’t perform that action at this time.
0 commit comments