Bluetooth esp32 esp idf

Bluetooth HID Device API

A Bluetooth HID device is a device providing the service of human or other data input and output to and from a Bluetooth HID Host. Users can use the Bluetooth HID Device APIs to make devices like keyboards, mice, joysticks and so on.

Application Example

Check bluetooth/bluedroid/classic_bt folder in ESP-IDF examples, which contains the following application:

  • This is an example of Bluetooth HID mouse device. The device running this example can be discovered and connected by a Bluetooth HID Host device such as a PC, and the pointer will move left and right after HID connection is established — bluetooth/bluedroid/classic_bt/bt_hid_mouse_device

API Reference

Header File

Functions

This function is called to init callbacks with HID device module.

callback[in] pointer to the init callback function.

Initializes HIDD interface. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_register_callback. When the operation is complete, the callback function will be called with ESP_HIDD_INIT_EVT.

De-initializes HIDD interface. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_DEINIT_EVT.

Registers HIDD parameters with SDP and sets l2cap Quality of Service. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_REGISTER_APP_EVT.

Removes HIDD parameters from SDP and resets l2cap Quality of Service. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_UNREGISTER_APP_EVT.

Читайте также:  Bluetooth partybox 1000 jbl

Connects to the peer HID Host with virtual cable. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_OPEN_EVT.

bd_addr[in] Remote host bluetooth device address.

Disconnects from the currently connected HID Host. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_CLOSE_EVT.

The disconnect operation will not remove the virtually cabled device. If the connect request from the different HID Host, it will reject the request.

esp_err_t esp_bt_hid_device_send_report ( esp_hidd_report_type_t type , uint8_t id , uint16_t len , uint8_t * data ) 

Sends HID report to the currently connected HID Host. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_SEND_REPORT_EVT.

Sends HID Handshake with error info for invalid set_report to the currently connected HID Host. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_REPORT_ERR_EVT.

error[in] type of error

Remove the virtually cabled device. This function should be called after esp_bluedroid_init() and esp_bluedroid_enable() success, and should be called after esp_bt_hid_device_init(). When the operation is complete, the callback function will be called with ESP_HIDD_VC_UNPLUG_EVT.

If the connection exists, then HID Device will send a VIRTUAL_CABLE_UNPLUG control command to the peer HID Host, and the connection will be destroyed. If the connection does not exist, then HID Device will only unplug on it’s single side. Once the unplug operation is success, the related pairing and bonding information will be removed, then the HID Device can accept connection request from the different HID Host,

Читайте также:  Hi res плееры bluetooth

Unions

HID device callback parameters union.

HIDD callback param of ESP_HIDD_INIT_EVT

HIDD callback param of ESP_HIDD_DEINIT_EVT

HIDD callback param of ESP_HIDD_REGISTER_APP_EVT

HIDD callback param of ESP_HIDD_UNREGISTER_APP_EVT

HIDD callback param of ESP_HIDD_OPEN_EVT

HIDD callback param of ESP_HIDD_CLOSE_EVT

HIDD callback param of ESP_HIDD_SEND_REPORT_EVT

HIDD callback param of ESP_HIDD_REPORT_ERR_EVT

HIDD callback param of ESP_HIDD_GET_REPORT_EVT

HIDD callback param of ESP_HIDD_SET_REPORT_EVT

HIDD callback param of ESP_HIDD_SET_PROTOCOL_EVT

HIDD callback param of ESP_HIDD_INTR_DATA_EVT

HIDD callback param of ESP_HIDD_VC_UNPLUG_EVT

Источник

Оцените статью
Adblock
detector