Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
hid_device.h
Go to the documentation of this file.
1
4
5/*
6 * Copyright 2025 Xiaomi Corporation
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11#ifndef ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_HID_DEVICE_H_
12#define ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_HID_DEVICE_H_
13
20
21#include <stdbool.h>
22#include <stdint.h>
23
25#include <zephyr/net_buf.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
39#define BT_HID_PROTOCOL_BOOT_MODE 0x00
41#define BT_HID_PROTOCOL_REPORT_MODE 0x01
43
52#define BT_HID_REPORT_TYPE_INPUT 0x01
54#define BT_HID_REPORT_TYPE_OUTPUT 0x02
56#define BT_HID_REPORT_TYPE_FEATURE 0x03
58
59struct bt_hid_device;
60
77 void (*connected)(struct bt_hid_device *hid);
78
88 void (*disconnected)(struct bt_hid_device *hid);
89
107 int (*set_report)(struct bt_hid_device *hid, uint8_t type, struct net_buf *buf);
108
144 int (*get_report)(struct bt_hid_device *hid, uint8_t type, bool size_present,
145 struct net_buf *req, struct net_buf *rsp);
146
161 int (*set_protocol)(struct bt_hid_device *hid, uint8_t protocol);
162
173 void (*output_report)(struct bt_hid_device *hid, struct net_buf *buf);
174
198 void (*vc_unplug)(struct bt_hid_device *hid);
199
220 void (*suspend)(struct bt_hid_device *hid, bool suspended);
221};
222
238
249
260int bt_hid_device_connect(struct bt_conn *conn, struct bt_hid_device **hid);
261
271int bt_hid_device_disconnect(struct bt_hid_device *hid);
272
286
304int bt_hid_device_input_report(struct bt_hid_device *hid, struct net_buf *buf);
305
314int bt_hid_device_virtual_cable_unplug(struct bt_hid_device *hid);
315
329struct bt_conn *bt_hid_device_get_conn(struct bt_hid_device *hid);
330
331#ifdef __cplusplus
332}
333#endif
334
338
339#endif /* ZEPHYR_INCLUDE_BLUETOOTH_CLASSIC_HID_DEVICE_H_ */
Bluetooth connection handling.
int bt_hid_device_input_report(struct bt_hid_device *hid, struct net_buf *buf)
Send a HID interrupt input report to the HID host.
int bt_hid_device_register(const struct bt_hid_device_cb *cb)
Register HID device callbacks.
int bt_hid_device_unregister(void)
Unregister HID device callbacks and disable HID services.
struct bt_conn * bt_hid_device_get_conn(struct bt_hid_device *hid)
Obtain the ACL connection associated with a HID device.
int bt_hid_device_virtual_cable_unplug(struct bt_hid_device *hid)
Trigger a virtual cable unplug procedure for the given HID association.
struct net_buf * bt_hid_device_create_pdu(struct net_buf_pool *pool)
Allocate/create a PDU buffer suitable for HID over L2CAP.
int bt_hid_device_disconnect(struct bt_hid_device *hid)
Disconnect a previously connected HID association.
int bt_hid_device_connect(struct bt_conn *conn, struct bt_hid_device **hid)
Initiate an outgoing HID association on the given connection.
Buffer management.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Opaque type representing a connection to a remote device.
Callbacks supplied by the HID application.
Definition hid_device.h:68
int(* set_protocol)(struct bt_hid_device *hid, uint8_t protocol)
Set_Protocol request callback.
Definition hid_device.h:161
int(* get_report)(struct bt_hid_device *hid, uint8_t type, bool size_present, struct net_buf *req, struct net_buf *rsp)
Get_Report request callback.
Definition hid_device.h:144
int(* set_report)(struct bt_hid_device *hid, uint8_t type, struct net_buf *buf)
Set_Report request callback.
Definition hid_device.h:107
void(* suspend)(struct bt_hid_device *hid, bool suspended)
Suspend/Exit-Suspend notification callback.
Definition hid_device.h:220
void(* vc_unplug)(struct bt_hid_device *hid)
Virtual Cable Unplug notification callback.
Definition hid_device.h:198
void(* connected)(struct bt_hid_device *hid)
connected callback to application
Definition hid_device.h:77
void(* disconnected)(struct bt_hid_device *hid)
disconnected callback to application
Definition hid_device.h:88
void(* output_report)(struct bt_hid_device *hid, struct net_buf *buf)
Output report callback.
Definition hid_device.h:173
Network buffer pool representation.
Definition net_buf.h:1184
Network buffer representation.
Definition net_buf.h:1048