nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
hids.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_HIDS_H_
8#define BT_HIDS_H_
9
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <bluetooth/gatt_pool.h>
22#include <zephyr/bluetooth/gatt.h>
23#include <bluetooth/conn_ctx.h>
24
25#ifndef CONFIG_BT_HIDS_INPUT_REP_MAX
26#define CONFIG_BT_HIDS_INPUT_REP_MAX 0
27#endif
28
29#ifndef CONFIG_BT_HIDS_OUTPUT_REP_MAX
30#define CONFIG_BT_HIDS_OUTPUT_REP_MAX 0
31#endif
32
33#ifndef CONFIG_BT_HIDS_FEATURE_REP_MAX
34#define CONFIG_BT_HIDS_FEATURE_REP_MAX 0
35#endif
36
38#define BT_HIDS_BOOT_MOUSE_REP_LEN 8
40#define BT_HIDS_BOOT_KB_INPUT_REP_LEN 8
42#define BT_HIDS_BOOT_KB_OUTPUT_REP_LEN 1
43
45#define BT_HIDS_INFORMATION_LEN 4
46
53#define BT_HIDS_DEF(_name, ...) \
54 BT_CONN_CTX_DEF(_name, \
55 CONFIG_BT_HIDS_MAX_CLIENT_COUNT, \
56 _BT_HIDS_CONN_CTX_SIZE_CALC(__VA_ARGS__)); \
57 static struct bt_hids _name = \
58 { \
59 .gp = BT_GATT_POOL_INIT(CONFIG_BT_HIDS_ATTR_MAX), \
60 .conn_ctx = &_CONCAT(_name, _ctx_lib), \
61 }
62
63
67#define _BT_HIDS_CONN_CTX_SIZE_CALC(...) \
68 (FOR_EACH(_BT_HIDS_GET_ARG1, (+), __VA_ARGS__) + \
69 sizeof(struct bt_hids_conn_data))
70#define _BT_HIDS_GET_ARG1(...) GET_ARG_N(1, __VA_ARGS__)
71
79};
80
87
90
93
96};
97
102 uint16_t bcd_hid;
103
108
110 uint8_t flags;
111};
112
119};
120
125
129
136};
137
144};
145
152};
153
158 uint8_t *data;
159
161 uint8_t size;
162};
163
169
176typedef void (*bt_hids_rep_handler_t) (struct bt_hids_rep *rep,
177 struct bt_conn *conn,
178 bool write);
179
184 struct _bt_gatt_ccc ccc;
185
187 uint8_t id;
188
190 uint8_t idx;
191
193 uint8_t att_ind;
194
196 uint8_t size;
197
199 uint8_t offset;
200
214 uint8_t perm;
215
226 const uint8_t *rep_mask;
227
230};
231
232
237 uint8_t id;
238
240 uint8_t idx;
241
243 uint8_t size;
244
246 uint8_t offset;
247
249 uint8_t att_ind;
250
264 uint8_t perm;
265
268};
269
274 struct _bt_gatt_ccc ccc;
275
277 uint8_t att_ind;
278
281};
282
287 struct _bt_gatt_ccc ccc;
288
290 uint8_t att_ind;
291
294};
295
300 uint8_t att_ind;
301
304};
305
311
313 uint8_t cnt;
314};
315
321
323 uint8_t cnt;
324};
325
331
333 uint8_t cnt;
334};
335
340 uint8_t const *data;
341
343 uint16_t size;
344};
345
351typedef void (*bt_hids_pm_evt_handler_t) (enum bt_hids_pm_evt evt,
352 struct bt_conn *conn);
353
354
360};
361
367typedef void (*bt_hids_cp_evt_handler_t) (enum bt_hids_cp_evt evt);
368
373 uint8_t value;
374
377};
378
384
387
390
393
396
399
402
405
408
411
414
416 bool is_kb;
417};
418
421struct bt_hids {
424
427
430
433
436
439
442
445
448
451
454
457
459 bool is_kb;
460
463};
464
470
473
476
479
481 uint8_t *inp_rep_ctx;
482
484 uint8_t *outp_rep_ctx;
485
487 uint8_t *feat_rep_ctx;
488};
489
490
499int bt_hids_init(struct bt_hids *hids_obj,
500 const struct bt_hids_init_param *init_param);
501
509int bt_hids_uninit(struct bt_hids *hids_obj);
510
521int bt_hids_connected(struct bt_hids *hids_obj, struct bt_conn *conn);
522
533int bt_hids_disconnected(struct bt_hids *hids_obj, struct bt_conn *conn);
534
550int bt_hids_inp_rep_send(struct bt_hids *hids_obj, struct bt_conn *conn,
551 uint8_t rep_index, uint8_t const *rep, uint8_t len,
552 bt_gatt_complete_func_t cb);
553
571 struct bt_conn *conn,
572 const uint8_t *buttons,
573 int8_t x_delta, int8_t y_delta,
574 bt_gatt_complete_func_t cb);
575
590int bt_hids_boot_kb_inp_rep_send(struct bt_hids *hids_obj, struct bt_conn *conn,
591 uint8_t const *rep, uint16_t len,
592 bt_gatt_complete_func_t cb);
593
594
595#ifdef __cplusplus
596}
597#endif
598
603#endif /* BT_HIDS_H_ */
int bt_hids_uninit(struct bt_hids *hids_obj)
Uninitialize a HIDS instance.
bt_hids_control_point
HID Control Point settings.
Definition: hids.h:122
@ BT_HIDS_CONTROL_POINT_EXIT_SUSPEND
Definition: hids.h:127
@ BT_HIDS_CONTROL_POINT_SUSPEND
Definition: hids.h:124
#define CONFIG_BT_HIDS_INPUT_REP_MAX
Definition: hids.h:26
#define BT_HIDS_BOOT_KB_INPUT_REP_LEN
Definition: hids.h:40
bt_hids_report_type
Report types as defined in the Report Reference Characteristic descriptor.
Definition: hids.h:84
@ BT_HIDS_REPORT_TYPE_RESERVED
Definition: hids.h:86
@ BT_HIDS_REPORT_TYPE_INPUT
Definition: hids.h:89
@ BT_HIDS_REPORT_TYPE_FEATURE
Definition: hids.h:95
@ BT_HIDS_REPORT_TYPE_OUTPUT
Definition: hids.h:92
bt_hids_pm_evt
Definition: hids.h:131
@ BT_HIDS_PM_EVT_BOOT_MODE_ENTERED
Definition: hids.h:133
@ BT_HIDS_PM_EVT_REPORT_MODE_ENTERED
Definition: hids.h:135
void(* bt_hids_pm_evt_handler_t)(enum bt_hids_pm_evt evt, struct bt_conn *conn)
HID Protocol Mode event handler.
Definition: hids.h:351
#define BT_HIDS_BOOT_KB_OUTPUT_REP_LEN
Definition: hids.h:42
int bt_hids_connected(struct bt_hids *hids_obj, struct bt_conn *conn)
Function for informing the HID service about connection to the device This function should be used in...
bt_hids_pm
Possible values for the Protocol Mode Characteristic value.
Definition: hids.h:74
@ BT_HIDS_PM_BOOT
Definition: hids.h:76
@ BT_HIDS_PM_REPORT
Definition: hids.h:78
bt_hids_notify_evt
Definition: hids.h:147
@ BT_HIDS_CCCD_EVT_NOTIFY_DISABLED
Definition: hids.h:151
@ BT_HIDS_CCCD_EVT_NOTIFY_ENABLED
Definition: hids.h:149
int bt_hids_boot_mouse_inp_rep_send(struct bt_hids *hids_obj, struct bt_conn *conn, const uint8_t *buttons, int8_t x_delta, int8_t y_delta, bt_gatt_complete_func_t cb)
Send Boot Mouse Input Report.
bt_hids_cp_evt
Definition: hids.h:139
@ BT_HIDS_CP_EVT_HOST_EXIT_SUSP
Definition: hids.h:143
@ BT_HIDS_CP_EVT_HOST_SUSP
Definition: hids.h:141
void(* bt_hids_cp_evt_handler_t)(enum bt_hids_cp_evt evt)
HID Control Point event handler.
Definition: hids.h:367
int bt_hids_boot_kb_inp_rep_send(struct bt_hids *hids_obj, struct bt_conn *conn, uint8_t const *rep, uint16_t len, bt_gatt_complete_func_t cb)
Send Boot Keyboard Input Report.
int bt_hids_init(struct bt_hids *hids_obj, const struct bt_hids_init_param *init_param)
Initialize the HIDS instance.
void(* bt_hids_rep_handler_t)(struct bt_hids_rep *rep, struct bt_conn *conn, bool write)
HID Report event handler.
Definition: hids.h:176
void(* bt_hids_notify_handler_t)(enum bt_hids_notify_evt evt)
HID notification event handler.
Definition: hids.h:168
int bt_hids_disconnected(struct bt_hids *hids_obj, struct bt_conn *conn)
Function for informing the HID service about disconnection from the device. This function should be u...
#define BT_HIDS_INFORMATION_LEN
Definition: hids.h:45
#define CONFIG_BT_HIDS_FEATURE_REP_MAX
Definition: hids.h:34
#define CONFIG_BT_HIDS_OUTPUT_REP_MAX
Definition: hids.h:30
int bt_hids_inp_rep_send(struct bt_hids *hids_obj, struct bt_conn *conn, uint8_t rep_index, uint8_t const *rep, uint8_t len, bt_gatt_complete_func_t cb)
Send Input Report.
#define BT_HIDS_BOOT_MOUSE_REP_LEN
Definition: hids.h:38
bt_hids_flags
HID Service information flags.
Definition: hids.h:114
@ BT_HIDS_REMOTE_WAKE
Definition: hids.h:116
@ BT_HIDS_NORMALLY_CONNECTABLE
Definition: hids.h:118
Bluetooth connection context library structure.
Definition: conn_ctx.h:53
The GATT service object that uses dynamic attribute allocation.
Definition: gatt_pool.h:128
bt_hids_notify_handler_t handler
Definition: hids.h:293
struct _bt_gatt_ccc ccc
Definition: hids.h:287
uint8_t att_ind
Definition: hids.h:290
Boot Keyboard Input Report.
Definition: hids.h:285
bt_hids_rep_handler_t handler
Definition: hids.h:303
uint8_t att_ind
Definition: hids.h:300
Boot Keyboard Output Report.
Definition: hids.h:298
uint8_t att_ind
Definition: hids.h:277
bt_hids_notify_handler_t handler
Definition: hids.h:280
struct _bt_gatt_ccc ccc
Definition: hids.h:274
Boot Mouse Input Report.
Definition: hids.h:272
uint8_t * feat_rep_ctx
Definition: hids.h:487
uint8_t hids_boot_kb_outp_rep_ctx[1]
Definition: hids.h:478
uint8_t pm_ctx_value
Definition: hids.h:469
uint8_t hids_boot_mouse_inp_rep_ctx[8]
Definition: hids.h:472
uint8_t * inp_rep_ctx
Definition: hids.h:481
uint8_t * outp_rep_ctx
Definition: hids.h:484
uint8_t hids_boot_kb_inp_rep_ctx[8]
Definition: hids.h:475
HID Connection context data structure.
Definition: hids.h:467
bt_hids_cp_evt_handler_t evt_handler
Definition: hids.h:376
uint8_t value
Definition: hids.h:373
Control Point.
Definition: hids.h:371
uint8_t cnt
Definition: hids.h:333
struct bt_hids_outp_feat_rep reports[0]
Definition: hids.h:330
Collection of all feature reports.
Definition: hids.h:328
uint8_t b_country_code
Definition: hids.h:107
uint8_t flags
Definition: hids.h:110
uint16_t bcd_hid
Definition: hids.h:102
HID Service information.
Definition: hids.h:100
struct bt_hids_inp_rep_group inp_rep_group_init
Definition: hids.h:386
struct bt_hids_info info
Definition: hids.h:383
struct bt_hids_outp_rep_group outp_rep_group_init
Definition: hids.h:389
bt_hids_notify_handler_t boot_kb_notif_handler
Definition: hids.h:407
bt_hids_rep_handler_t boot_kb_outp_rep_handler
Definition: hids.h:410
bool is_kb
Definition: hids.h:416
bt_hids_pm_evt_handler_t pm_evt_handler
Definition: hids.h:398
struct bt_hids_feat_rep_group feat_rep_group_init
Definition: hids.h:392
struct bt_hids_rep_map rep_map
Definition: hids.h:395
bt_hids_cp_evt_handler_t cp_evt_handler
Definition: hids.h:401
bool is_mouse
Definition: hids.h:413
bt_hids_notify_handler_t boot_mouse_notif_handler
Definition: hids.h:404
HID initialization.
Definition: hids.h:381
struct bt_hids_inp_rep reports[0]
Definition: hids.h:310
uint8_t cnt
Definition: hids.h:313
Collection of all input reports.
Definition: hids.h:308
uint8_t id
Definition: hids.h:187
uint8_t att_ind
Definition: hids.h:193
uint8_t idx
Definition: hids.h:190
uint8_t offset
Definition: hids.h:199
uint8_t perm
Definition: hids.h:214
struct _bt_gatt_ccc ccc
Definition: hids.h:184
bt_hids_notify_handler_t handler
Definition: hids.h:229
const uint8_t * rep_mask
Definition: hids.h:226
uint8_t size
Definition: hids.h:196
Input Report.
Definition: hids.h:182
uint8_t size
Definition: hids.h:243
uint8_t att_ind
Definition: hids.h:249
uint8_t perm
Definition: hids.h:264
uint8_t offset
Definition: hids.h:246
bt_hids_rep_handler_t handler
Definition: hids.h:267
uint8_t idx
Definition: hids.h:240
uint8_t id
Definition: hids.h:237
Output or Feature Report.
Definition: hids.h:235
struct bt_hids_outp_feat_rep reports[0]
Definition: hids.h:320
uint8_t cnt
Definition: hids.h:323
Collection of all output reports.
Definition: hids.h:318
bt_hids_pm_evt_handler_t evt_handler
Definition: hids.h:359
Protocol Mode.
Definition: hids.h:357
uint16_t size
Definition: hids.h:343
uint8_t const * data
Definition: hids.h:340
Report Map.
Definition: hids.h:338
uint8_t size
Definition: hids.h:161
uint8_t * data
Definition: hids.h:158
Report data.
Definition: hids.h:156
struct bt_hids_inp_rep_group inp_rep_group
Definition: hids.h:426
struct bt_hids_feat_rep_group feat_rep_group
Definition: hids.h:432
struct bt_hids_pm_data pm
Definition: hids.h:447
struct bt_hids_outp_rep_group outp_rep_group
Definition: hids.h:429
uint8_t info[4]
Definition: hids.h:453
bool is_mouse
Definition: hids.h:456
struct bt_hids_boot_kb_outp_rep boot_kb_outp_rep
Definition: hids.h:441
struct bt_conn_ctx_lib * conn_ctx
Definition: hids.h:462
struct bt_hids_boot_mouse_inp_rep boot_mouse_inp_rep
Definition: hids.h:435
bool is_kb
Definition: hids.h:459
struct bt_gatt_pool gp
Definition: hids.h:423
struct bt_hids_cp cp
Definition: hids.h:450
struct bt_hids_boot_kb_inp_rep boot_kb_inp_rep
Definition: hids.h:438
struct bt_hids_rep_map rep_map
Definition: hids.h:444
HID Service structure.
Definition: hids.h:421