1| Supported Targets | ESP32 |
2| ----------------- | ----- |
3
4# ESP-IDF BT/BLE HID Host Demo
5
6
7# ESP-IDF BLE HID Host Demo
8
9This demo use APIs which esp_hid component provided to create a Bluetooth dual mode hid host. After the program is started, the HID host will scan the surrounding Bluetooth HID device and try to connect to the last device which has been scanned. When the connection is successfully established, the HID host will dump the HID device information and can receive the data sent by the HID device.
10
11This example works in companion with the [BLE HID Device Example](../esp_hid_device/README.md)
12
13## How to Use Example
14
15Before project configuration and build, be sure to set the correct chip target using:
16
17```bash
18idf.py set-target <chip_name>
19```
20
21### Hardware Required
22
23* A development board with ESP32 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
24* A USB cable for Power supply and programming
25
26See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
27
28### Configure the Project
29
30### Build and Flash
31
32Build the project and flash it to the board, then run monitor tool to view serial output.
33
34```
35idf.py -p PORT flash monitor
36```
37
38(To exit the serial monitor, type ``Ctrl-]``.)
39
40See the [Getting Started Guide](https://idf.espressif.com/) for full steps to configure and use ESP-IDF to build projects.
41
42## Example Output
43
44```
45I (0) cpu_start: Starting scheduler on APP CPU.
46I (602) BTDM_INIT: BT controller compile version [d03a5d3]
47I (612) system_api: Base MAC address is not set
48I (612) system_api: read default base MAC address from EFUSE
49I (612) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
50I (1332) ESP_HIDH_DEMO: SCAN...
51I (7212) ESP_HIDH_DEMO: SCAN: 1 results
52  BLE: fc:f5:c4:3c:62:92, RSSI: -29, USAGE: GENERIC, APPEARANCE: 0x03c0, ADDR_TYPE: 'PUBLIC', NAME: ESP BLE HID2
53I (7332) ESP_HID_GAP: BLE GAP SEC_REQ
54E (7702) BT_SMP: Value for numeric comparison = 125657
55I (7702) ESP_HID_GAP: BLE GAP NC_REQ passkey:125657
56W (7742) BT_SMP: FOR LE SC LTK IS USED INSTEAD OF STK
57I (7892) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_PID
58I (7892) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_LENC
59I (7892) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_PENC
60I (7892) ESP_HID_GAP: BLE GAP KEY type = ESP_LE_KEY_LID
61I (8142) ESP_HID_GAP: BLE GAP AUTH SUCCESS
62I (9332) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 OPEN: ESP BLE HID2
63BDA:fc:f5:c4:3c:62:92, Appearance: 0x03c0, Connection ID: 0
64Name: ESP BLE HID2, Manufacturer: Espressif, Serial Number: 1234567890
65PID: 0x05df, VID: 0x16c0, VERSION: 0x0100
66Battery: Handle: 42, CCC Handle: 43
67Report Maps: 2
68  Report Map Length: 38
69      VENDOR FEATURE REPORT, ID:  1, Length:   8, Permissions: 0x0a, Handle:  71, CCC Handle:   0
70      VENDOR  OUTPUT REPORT, ID:  1, Length:   8, Permissions: 0x0a, Handle:  68, CCC Handle:   0
71      VENDOR   INPUT REPORT, ID:  1, Length:   8, Permissions: 0x12, Handle:  64, CCC Handle:  65
72  Report Map Length: 111
73    CCONTROL   INPUT REPORT, ID:  3, Length:   2, Permissions: 0x12, Handle:  85, CCC Handle:  86
74I (9722) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
75I (9722) ESP_HIDH_DEMO: 40 00
76I (9812) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
77I (9812) ESP_HIDH_DEMO: 00 00
78I (11822) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
79I (11822) ESP_HIDH_DEMO: 80 00
80I (11912) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
81I (11912) ESP_HIDH_DEMO: 00 00
82I (13922) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
83I (13922) ESP_HIDH_DEMO: 40 00
84I (14012) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
85I (14012) ESP_HIDH_DEMO: 00 00
86I (16022) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
87I (16022) ESP_HIDH_DEMO: 80 00
88I (16112) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
89I (16112) ESP_HIDH_DEMO: 00 00
90I (18122) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
91I (18122) ESP_HIDH_DEMO: 40 00
92I (18212) ESP_HIDH_DEMO: fc:f5:c4:3c:62:92 INPUT: CCONTROL, MAP:  1, ID:   3, Len: 2, Data:
93I (18212) ESP_HIDH_DEMO: 00 00
94...
95```
96
97## Troubleshooting
98
99For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
100