|
Zephyr Project API 4.4.99
A Scalable Open Source RTOS
|
Bluetooth HID Host. More...
Data Structures | |
| struct | bt_hid_host_cb |
| Callbacks supplied by the HID Host application. More... | |
Functions | |
| int | bt_hid_host_register (const struct bt_hid_host_cb *cb) |
| Register HID Host callbacks. | |
| int | bt_hid_host_unregister (void) |
| Unregister HID Host callbacks. | |
| int | bt_hid_host_connect (struct bt_conn *conn, struct bt_hid_host **hid) |
| Initiate an HID connection to a remote HID Device. | |
| struct bt_conn * | bt_hid_host_get_conn (struct bt_hid_host *hid) |
| Get the ACL connection of an HID association. | |
| int | bt_hid_host_disconnect (struct bt_hid_host *hid) |
| Disconnect an HID association. | |
| int | bt_hid_host_get_report (struct bt_hid_host *hid, uint8_t type, uint8_t report_id, uint16_t buffer_size) |
| Send a GET_REPORT request to the HID Device. | |
| int | bt_hid_host_set_report (struct bt_hid_host *hid, uint8_t type, struct net_buf *buf) |
| Send a SET_REPORT request to the HID Device. | |
| int | bt_hid_host_get_protocol (struct bt_hid_host *hid) |
| Send a GET_PROTOCOL request to the HID Device. | |
| int | bt_hid_host_set_protocol (struct bt_hid_host *hid, uint8_t protocol) |
| Send a SET_PROTOCOL request to the HID Device. | |
| int | bt_hid_host_output_report (struct bt_hid_host *hid, struct net_buf *buf) |
| Send an output report on the interrupt channel. | |
| int | bt_hid_host_suspend (struct bt_hid_host *hid) |
| Send SUSPEND control to the HID Device. | |
| int | bt_hid_host_exit_suspend (struct bt_hid_host *hid) |
| Send EXIT_SUSPEND control to the HID Device. | |
| int | bt_hid_host_virtual_cable_unplug (struct bt_hid_host *hid) |
| Send Virtual Cable Unplug to the HID Device. | |
| struct net_buf * | bt_hid_host_create_pdu (struct net_buf_pool *pool) |
| Allocate a PDU buffer for HID Host transmissions. | |
Bluetooth HID Host.
| int bt_hid_host_connect | ( | struct bt_conn * | conn, |
| struct bt_hid_host ** | hid ) |
#include <hid_host.h>
Initiate an HID connection to a remote HID Device.
Opens the L2CAP control channel and, once it is up, the interrupt channel.
The HID service record is not read here. Applications that need the report descriptor or the device attributes discover them over SDP themselves, which also leaves them free to decide whether to do so on every connection.
| conn | ACL connection to the remote device. |
| hid | Pointer to store the HID Host instance on success. |
| struct net_buf * bt_hid_host_create_pdu | ( | struct net_buf_pool * | pool | ) |
#include <hid_host.h>
Allocate a PDU buffer for HID Host transmissions.
The returned buffer already reserves headroom for the HID header, so the profile can prepend it without copying. Callers only append the report payload with net_buf_add_*() and must not consume the headroom themselves.
| pool | Buffer pool to allocate from, or NULL for default. |
| int bt_hid_host_disconnect | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Disconnect an HID association.
Tears down the interrupt channel first, then the control channel per HID spec v1.1.2 Section 5.2.2.
| hid | HID Host instance. |
| int bt_hid_host_exit_suspend | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Send EXIT_SUSPEND control to the HID Device.
Informs the device that the host is exiting low-power state.
| hid | HID Host instance. |
| struct bt_conn * bt_hid_host_get_conn | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Get the ACL connection of an HID association.
Needed by applications that have to act on the peer identity, for example to destroy the bonding after a Virtual Cable Unplug (HID spec v1.1.2 Section 3.1.2.2.3), which the stack leaves to the application.
| hid | HID Host instance. |
| int bt_hid_host_get_protocol | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Send a GET_PROTOCOL request to the HID Device.
The response arrives via the get_protocol callback.
| hid | HID Host instance. |
| int bt_hid_host_get_report | ( | struct bt_hid_host * | hid, |
| uint8_t | type, | ||
| uint8_t | report_id, | ||
| uint16_t | buffer_size ) |
#include <hid_host.h>
Send a GET_REPORT request to the HID Device.
The response arrives asynchronously via the get_report callback, or the association is torn down if the device never answers.
The ReportID field is required as soon as the report descriptor declares Report IDs, and in Boot Protocol Mode it is always required (HID spec v1.1.2 Section 3.1.2.3 and Section 3.3.1). Only the application knows the descriptor, so it decides whether the field is sent.
| hid | HID Host instance. |
| type | Report type (BT_HID_REPORT_TYPE_INPUT/OUTPUT/FEATURE). |
| report_id | Report ID to request, or 0 to omit the field. Report ID 0 is reserved by the USB HID specification, so it cannot identify a report. |
| buffer_size | Maximum response payload size (0 = no limit). Must not exceed what the control channel can receive. |
| int bt_hid_host_output_report | ( | struct bt_hid_host * | hid, |
| struct net_buf * | buf ) |
#include <hid_host.h>
Send an output report on the interrupt channel.
This is an asynchronous transfer with no acknowledgment: HID spec v1.1.2 Section 3.1.2.9 leaves interrupt channel transfers unanswered. The buffer must start with the Report ID when the report descriptor declares Report IDs or the device is in Boot Protocol Mode.
| hid | HID Host instance. |
| buf | Buffer containing output report, allocated with bt_hid_host_create_pdu() so the HIDP header fits (consumed on success). |
| int bt_hid_host_register | ( | const struct bt_hid_host_cb * | cb | ) |
#include <hid_host.h>
Register HID Host callbacks.
Registers the application callbacks and sets up L2CAP servers to accept incoming Device-initiated reconnections on PSM 0x0011/0x0013.
| cb | Callback structure. Must remain valid for the lifetime of the HID Host subsystem. |
| int bt_hid_host_set_protocol | ( | struct bt_hid_host * | hid, |
| uint8_t | protocol ) |
#include <hid_host.h>
Send a SET_PROTOCOL request to the HID Device.
The response arrives via the set_protocol callback.
| hid | HID Host instance. |
| protocol | Target protocol (BT_HID_PROTOCOL_BOOT_MODE or BT_HID_PROTOCOL_REPORT_MODE). |
#include <hid_host.h>
Send a SET_REPORT request to the HID Device.
The response arrives via the set_report callback. The buffer must start with the Report ID when the report descriptor declares Report IDs or the device is in Boot Protocol Mode.
| hid | HID Host instance. |
| type | Report type (BT_HID_REPORT_TYPE_INPUT/OUTPUT/FEATURE). |
| buf | Buffer containing report payload, allocated with bt_hid_host_create_pdu(). Retained by the caller on failure. |
| int bt_hid_host_suspend | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Send SUSPEND control to the HID Device.
Informs the device that the host is entering a low-power state.
| hid | HID Host instance. |
| int bt_hid_host_unregister | ( | void | ) |
#include <hid_host.h>
Unregister HID Host callbacks.
Unregisters the L2CAP servers so incoming Device-initiated reconnections are no longer accepted. All HID associations must be disconnected first.
| -EBUSY | if an HID association is still active. |
| -EALREADY | if the HID Host callbacks are not registered. |
| int bt_hid_host_virtual_cable_unplug | ( | struct bt_hid_host * | hid | ) |
#include <hid_host.h>
Send Virtual Cable Unplug to the HID Device.
Sends a VCU control message and waits for the HID Device to acknowledge it by disconnecting the association, per HID spec v1.1.2 Section 3.1.2.2.3. If the peer does not disconnect, the host starts a fallback teardown after the transaction timeout. Destroying the bonding is left to the application, see the vc_unplug callback.
| hid | HID Host instance. |