1| Supported Targets | ESP32 |
2| ----------------- | ----- |
3
4# ESP-IDF BT/BLE HID Device Demo
5
6This demo use APIs which esp_hid component provided to create a BT, BLE or Bluetooth dual mode hid device. Users can choose mode by setting `HID_DEV_MODE`.
7
8
9This example works in companion with the [BLE HID Host Example](../esp_hid_host/README.md)
10
11## How to Use Example
12
13Before project configuration and build, be sure to set the correct chip target using:
14
15```bash
16idf.py set-target <chip_name>
17```
18The BT hid device plays as a mouse. When the connection is successfully established, users can follow the usage below to operate the 'mouse'.
19
20```
21########################################################################
22BT hid mouse demo usage:
23You can input these value to simulate mouse: 'q', 'w', 'e', 'a', 's', 'd', 'h'
24q -- click the left key
25w -- move up
26e -- click the right key
27a -- move left
28s -- move down
29d -- move right
30h -- show the help
31########################################################################
32```
33
34The BLE hid device plays as a remote control. When the connection is successfully established, the remote control will set volume up and down periodically.
35This example implements a BLE HID device.
36
37### Hardware Required
38
39* A development board with ESP32 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
40* A USB cable for Power supply and programming
41
42See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
43
44### Configure the Project
45
46### Build and Flash
47
48Build the project and flash it to the board, then run monitor tool to view serial output.
49
50```
51idf.py -p PORT flash monitor
52```
53
54(To exit the serial monitor, type ``Ctrl-]``.)
55
56See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.
57
58## Example Output
59
60```
61I (0) cpu_start: Starting scheduler on APP CPU.
62I (607) BTDM_INIT: BT controller compile version [d03a5d3]
63I (607) system_api: Base MAC address is not set
64I (607) system_api: read default base MAC address from EFUSE
65I (617) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
66W (1337) BT_BTM: BTM_BleWriteAdvData, Partial data write into ADV
67I (1357) HID_DEV_DEMO: START
68I (25067) HID_DEV_DEMO: CONNECT
69I (25357) HID_DEV_DEMO: Send the volume
70E (25437) BT_SMP: Value for numeric comparison = 125657
71I (25437) ESP_HID_GAP: BLE GAP NC_REQ passkey:125657
72W (25517) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
73I (25587) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_LENC
74I (25587) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_PENC
75I (25587) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_LID
76I (25647) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_PID
77I (25757) ESP_HID_GAP: BLE GAP AUTH SUCCESS
78I (27457) HID_DEV_DEMO: Send the volume
79I (29557) HID_DEV_DEMO: Send the volume
80I (31657) HID_DEV_DEMO: Send the volume
81I (33757) HID_DEV_DEMO: Send the volume
82I (35857) HID_DEV_DEMO: Send the volume
83I (37957) HID_DEV_DEMO: Send the volume
84I (40057) HID_DEV_DEMO: Send the volume
85I (42157) HID_DEV_DEMO: Send the volume
86I (44257) HID_DEV_DEMO: Send the volume
87I (46357) HID_DEV_DEMO: Send the volume
88I (48457) HID_DEV_DEMO: Send the volume
89I (50557) HID_DEV_DEMO: Send the volume
90...
91```
92
93## Troubleshooting
94
95For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
96