22#include <zephyr/bluetooth/gatt.h>
25#ifndef CONFIG_BT_HIDS_INPUT_REP_MAX
26#define CONFIG_BT_HIDS_INPUT_REP_MAX 0
29#ifndef CONFIG_BT_HIDS_OUTPUT_REP_MAX
30#define CONFIG_BT_HIDS_OUTPUT_REP_MAX 0
33#ifndef CONFIG_BT_HIDS_FEATURE_REP_MAX
34#define CONFIG_BT_HIDS_FEATURE_REP_MAX 0
38#define BT_HIDS_BOOT_MOUSE_REP_LEN 3
40#define BT_HIDS_BOOT_KB_INPUT_REP_LEN 8
42#define BT_HIDS_BOOT_KB_OUTPUT_REP_LEN 1
45#define BT_HIDS_INFORMATION_LEN 4
48#define BT_HIDS_SCI_INFORMATION_MAX_GROUPS BT_CONN_LE_MAX_CONN_INTERVAL_GROUPS
54#define BT_HIDS_SCI_INFORMATION_MAX_LEN (1 + 1 + BT_HIDS_SCI_INFORMATION_MAX_GROUPS * (2 + 2 + 2))
55#define BT_HIDS_SCI_INFORMATION_MIN_LEN 2
60#define BT_HIDS_MAX_MINIMAL_TRANSPORT_INTERVAL_US 1250
68#define BT_HIDS_DEF(_name, ...) \
69 BT_CONN_CTX_DEF(_name, \
70 CONFIG_BT_HIDS_MAX_CLIENT_COUNT, \
71 _BT_HIDS_CONN_CTX_SIZE_CALC(__VA_ARGS__)); \
72 static struct bt_hids _name = \
74 .gp = BT_GATT_POOL_INIT(CONFIG_BT_HIDS_ATTR_MAX), \
75 .conn_ctx = &_CONCAT(_name, _ctx_lib), \
82#define _BT_HIDS_CONN_CTX_SIZE_CALC(...) \
83 (FOR_EACH(_BT_HIDS_GET_ARG1, (+), __VA_ARGS__) + \
84 sizeof(struct bt_hids_conn_data))
85#define _BT_HIDS_GET_ARG1(...) GET_ARG_N(1, __VA_ARGS__)
232 struct bt_conn *conn,
239 struct bt_gatt_ccc_managed_user_data
ccc;
336 struct bt_gatt_ccc_managed_user_data
ccc;
349 struct bt_gatt_ccc_managed_user_data
ccc;
414 struct bt_conn *conn);
454#if defined(CONFIG_BT_HIDS_SCI)
457struct bt_hids_sci_mode_data {
459 struct bt_gatt_ccc_managed_user_data ccc;
545#if defined(CONFIG_BT_HIDS_SCI)
547 struct bt_hids_sci_mode_data sci_mode_data;
586#if defined(CONFIG_BT_HIDS_SCI)
654 uint8_t rep_index, uint8_t
const *rep, uint8_t len,
655 bt_gatt_complete_func_t cb,
void *userdata);
673 uint8_t rep_index, uint8_t
const *rep, uint8_t len,
674 bt_gatt_complete_func_t cb)
696 struct bt_conn *conn,
697 const uint8_t *buttons,
698 int8_t x_delta, int8_t y_delta,
699 bt_gatt_complete_func_t cb);
716 uint8_t
const *rep, uint16_t len,
717 bt_gatt_complete_func_t cb);
756 const struct bt_conn_le_conn_rate_changed *params);
int bt_hids_uninit(struct bt_hids *hids_obj)
Uninitialize a HIDS instance.
bt_hids_control_point
HID Control Point settings.
Definition hids.h:145
@ BT_HIDS_CONTROL_POINT_EXIT_SUSPEND
Definition hids.h:150
@ BT_HIDS_CONTROL_POINT_SUSPEND
Definition hids.h:147
#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:99
@ BT_HIDS_REPORT_TYPE_RESERVED
Definition hids.h:101
@ BT_HIDS_REPORT_TYPE_INPUT
Definition hids.h:104
@ BT_HIDS_REPORT_TYPE_FEATURE
Definition hids.h:110
@ BT_HIDS_REPORT_TYPE_OUTPUT
Definition hids.h:107
bt_hids_pm_evt
Definition hids.h:168
@ BT_HIDS_PM_EVT_BOOT_MODE_ENTERED
Definition hids.h:170
@ BT_HIDS_PM_EVT_REPORT_MODE_ENTERED
Definition hids.h:172
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:413
bool bt_hids_sci_mode_validate(enum bt_hids_sci_mode_value mode, const struct bt_conn_le_conn_rate_changed *params)
Validate the new connection parameters against their allowed values for the given SCI mode....
int bt_hids_inp_rep_send_userdata(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, void *userdata)
Send Input Report, operation complete callback has user data as argument.
#define BT_HIDS_BOOT_KB_OUTPUT_REP_LEN
Definition hids.h:42
void(* bt_hids_notify_ext_handler_t)(uint8_t report_id, enum bt_hids_notify_evt evt)
HID notification event handler, with report identification.
Definition hids.h:223
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:89
@ BT_HIDS_PM_BOOT
Definition hids.h:91
@ BT_HIDS_PM_REPORT
Definition hids.h:93
bt_hids_sci_mode_value
HID SCI Mode values.
Definition hids.h:154
@ BT_HIDS_SCI_MODE_DEFAULT
Definition hids.h:158
@ BT_HIDS_SCI_MODE_FULL_RANGE
Definition hids.h:164
@ BT_HIDS_SCI_MODE_NONE
Definition hids.h:156
@ BT_HIDS_SCI_MODE_LOW_POWER
Definition hids.h:162
@ BT_HIDS_SCI_MODE_FAST
Definition hids.h:160
bt_hids_notify_evt
Definition hids.h:192
@ BT_HIDS_CCCD_EVT_NOTIFY_DISABLED
Definition hids.h:196
@ BT_HIDS_CCCD_EVT_NOTIFY_ENABLED
Definition hids.h:194
static 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.
Definition hids.h:672
int bt_hids_sci_mode_get(struct bt_conn *conn, enum bt_hids_sci_mode_value *mode)
Get the current SCI mode.
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:176
@ BT_HIDS_CP_EVT_HOST_EXIT_SUSP
Definition hids.h:180
@ BT_HIDS_CP_EVT_HOST_SCI_FAST_REQ
Definition hids.h:184
@ BT_HIDS_CP_EVT_HOST_SCI_DEFAULT_REQ
Definition hids.h:182
@ BT_HIDS_CP_EVT_HOST_SCI_FULL_RANGE_REQ
Definition hids.h:188
@ BT_HIDS_CP_EVT_HOST_SCI_LOW_POWER_REQ
Definition hids.h:186
@ BT_HIDS_CP_EVT_HOST_SUSP
Definition hids.h:178
void(* bt_hids_cp_evt_handler_t)(enum bt_hids_cp_evt evt)
HID Control Point event handler.
Definition hids.h:431
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:231
void(* bt_hids_conn_cp_evt_handler_t)(enum bt_hids_cp_evt evt, struct bt_conn *conn)
HID Control Point event handler.
Definition hids.h:439
int bt_hids_sci_mode_change_request(struct bt_conn *conn, enum bt_hids_sci_mode_value mode)
Request a new HID SCI mode. This function will request connection parameters for the mode....
void(* bt_hids_notify_handler_t)(enum bt_hids_notify_evt evt)
HID notification event handler.
Definition hids.h:216
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
#define BT_HIDS_BOOT_MOUSE_REP_LEN
Definition hids.h:38
int bt_hids_sci_mode_updated(struct bt_conn *conn, enum bt_hids_sci_mode_value mode)
Update the SCI mode.
bt_hids_flags
HID Service information flags.
Definition hids.h:129
@ BT_HIDS_REMOTE_WAKE
Definition hids.h:131
@ BT_HIDS_SCI_LOW_POWER_MODE_SUPPORTED
Definition hids.h:137
@ BT_HIDS_SCI_SUPPORTED
Definition hids.h:135
@ BT_HIDS_NORMALLY_CONNECTABLE
Definition hids.h:133
report_id
Identification numbers of HID reports.
Definition hid_report_desc.h:37
Bluetooth connection context library structure.
Definition conn_ctx.h:53
The GATT service object that uses dynamic attribute allocation.
Definition gatt_pool.h:128
struct bt_gatt_ccc_managed_user_data ccc
Definition hids.h:349
bt_hids_notify_handler_t handler
Definition hids.h:355
uint8_t att_ind
Definition hids.h:352
Boot Keyboard Input Report.
Definition hids.h:347
bt_hids_rep_handler_t handler
Definition hids.h:365
uint8_t att_ind
Definition hids.h:362
Boot Keyboard Output Report.
Definition hids.h:360
uint8_t att_ind
Definition hids.h:339
bt_hids_notify_handler_t handler
Definition hids.h:342
struct bt_gatt_ccc_managed_user_data ccc
Definition hids.h:336
Boot Mouse Input Report.
Definition hids.h:334
uint8_t * feat_rep_ctx
Definition hids.h:584
uint8_t hids_boot_kb_outp_rep_ctx[1]
Definition hids.h:575
uint8_t pm_ctx_value
Definition hids.h:566
uint8_t hids_boot_mouse_inp_rep_ctx[3]
Definition hids.h:569
uint8_t * inp_rep_ctx
Definition hids.h:578
uint8_t * outp_rep_ctx
Definition hids.h:581
uint8_t hids_boot_kb_inp_rep_ctx[8]
Definition hids.h:572
HID Connection context data structure.
Definition hids.h:564
bt_hids_cp_evt_handler_t evt_handler
Definition hids.h:448
bt_hids_conn_cp_evt_handler_t conn_evt_handler
Definition hids.h:451
uint8_t value
Definition hids.h:445
Control Point.
Definition hids.h:443
uint8_t cnt
Definition hids.h:395
struct bt_hids_outp_feat_rep reports[0]
Definition hids.h:392
Collection of all feature reports.
Definition hids.h:390
uint8_t b_country_code
Definition hids.h:122
uint8_t flags
Definition hids.h:125
uint16_t bcd_hid
Definition hids.h:117
HID Service information.
Definition hids.h:115
struct bt_hids_inp_rep_group inp_rep_group_init
Definition hids.h:473
struct bt_hids_info info
Definition hids.h:470
struct bt_hids_outp_rep_group outp_rep_group_init
Definition hids.h:476
bt_hids_notify_handler_t boot_kb_notif_handler
Definition hids.h:500
bt_hids_rep_handler_t boot_kb_outp_rep_handler
Definition hids.h:503
bool is_kb
Definition hids.h:509
bt_hids_pm_evt_handler_t pm_evt_handler
Definition hids.h:485
struct bt_hids_feat_rep_group feat_rep_group_init
Definition hids.h:479
bt_hids_conn_cp_evt_handler_t conn_cp_evt_handler
Definition hids.h:494
struct bt_hids_rep_map rep_map
Definition hids.h:482
bt_hids_cp_evt_handler_t cp_evt_handler
Definition hids.h:491
bool is_mouse
Definition hids.h:506
bt_hids_notify_handler_t boot_mouse_notif_handler
Definition hids.h:497
HID initialization.
Definition hids.h:468
struct bt_hids_inp_rep reports[0]
Definition hids.h:372
uint8_t cnt
Definition hids.h:375
Collection of all input reports.
Definition hids.h:370
uint8_t id
Definition hids.h:242
uint8_t att_ind
Definition hids.h:248
uint8_t idx
Definition hids.h:245
uint8_t offset
Definition hids.h:254
uint8_t perm
Definition hids.h:269
bt_hids_notify_ext_handler_t handler_ext
Definition hids.h:291
bt_hids_notify_handler_t handler
Definition hids.h:286
const uint8_t * rep_mask
Definition hids.h:281
uint8_t size
Definition hids.h:251
struct bt_gatt_ccc_managed_user_data ccc
Definition hids.h:239
Input Report.
Definition hids.h:237
uint8_t size
Definition hids.h:305
uint8_t att_ind
Definition hids.h:311
uint8_t perm
Definition hids.h:326
uint8_t offset
Definition hids.h:308
bt_hids_rep_handler_t handler
Definition hids.h:329
uint8_t idx
Definition hids.h:302
uint8_t id
Definition hids.h:299
Output or Feature Report.
Definition hids.h:297
struct bt_hids_outp_feat_rep reports[0]
Definition hids.h:382
uint8_t cnt
Definition hids.h:385
Collection of all output reports.
Definition hids.h:380
bt_hids_pm_evt_handler_t evt_handler
Definition hids.h:421
Protocol Mode.
Definition hids.h:419
uint16_t size
Definition hids.h:405
uint8_t const * data
Definition hids.h:402
Report Map.
Definition hids.h:400
uint8_t size
Definition hids.h:209
uint8_t id
Definition hids.h:203
uint8_t * data
Definition hids.h:206
Report data.
Definition hids.h:201
struct bt_hids_inp_rep_group inp_rep_group
Definition hids.h:519
struct bt_hids_feat_rep_group feat_rep_group
Definition hids.h:525
struct bt_hids_pm_data pm
Definition hids.h:540
struct bt_hids_outp_rep_group outp_rep_group
Definition hids.h:522
uint8_t info[4]
Definition hids.h:550
bool is_mouse
Definition hids.h:553
struct bt_hids_boot_kb_outp_rep boot_kb_outp_rep
Definition hids.h:534
struct bt_conn_ctx_lib * conn_ctx
Definition hids.h:559
struct bt_hids_boot_mouse_inp_rep boot_mouse_inp_rep
Definition hids.h:528
bool is_kb
Definition hids.h:556
struct bt_gatt_pool gp
Definition hids.h:516
struct bt_hids_cp cp
Definition hids.h:543
struct bt_hids_boot_kb_inp_rep boot_kb_inp_rep
Definition hids.h:531
struct bt_hids_rep_map rep_map
Definition hids.h:537
HID Service structure.
Definition hids.h:514