Connect ESP32 to bluetooth classic keyboard
Posted: Mon Dec 06, 2021 5:06 pm
For a proof of concept I need to connect to a Bluetooth classic keyboard and mouse and read the input. The ESP32 needs to connect to the mouse and the keyboard at the same time (not a priority right now). I can connect to the mouse and if I print the bytes coming from this mouse I can easily decode them (for a proof of concept this is good enough for now). The ESP can see the keyboard, but the authentication fails. So I would like some help with this keyboard.
I use the esp_hid_host example from esp idf. I disabled BLE, only BT classic is used.
The mouse is off and no other BT devices are present.
The keyboard is an Apple Wireless Keyboard. Model A1314.
I use the latest version of IDF and use a an ESP32 Wroom.
The keyboard pairs with my laptop just fine. You need to type a code and press enter.
Do I need to an HCI driver? If so, where can I find one or how do I create one?
I use the esp_hid_host example from esp idf. I disabled BLE, only BT classic is used.
The mouse is off and no other BT devices are present.
The keyboard is an Apple Wireless Keyboard. Model A1314.
I use the latest version of IDF and use a an ESP32 Wroom.
The keyboard pairs with my laptop just fine. You need to type a code and press enter.
After pressing enter on the keyboard:I (2528) ESP_HIDH_DEMO: SCAN...
D (2538) event: running post ESP_HIDH_EVENTS:5 with handler 0x400d782c and context 0x3ffb7358 on loop 0x3ffca68c
0x400d782c: hidh_callback at build/../main/esp_hid_host_main.c:33
V (2538) ESP_HID_GAP: BT GAP DISC_STATE START
I (2548) ESP_HIDH_DEMO: EVENT: 5
BT : 78:ca:39:49:c4:2a, COD: major: PERIPHERAL, minor: 16, service: 0x001, RSSI: -60
BT : 78:ca:39:49:c4:2a, BDNAME: Apple Wireless Keyboard
V (6518) ESP_HID_GAP: BT GAP DISC_STATE STOP
I (6518) ESP_HIDH_DEMO: SCAN: 1 result
BT : 78:ca:39:49:c4:2a, RSSI: -60, USAGE: GENERIC, COD: PERIPHERAL[KEYBOARD] srv 0x001, UUID16: 0x0000, NAME: Apple Wireless Keyboard
W (7118) BT_SDP: process_service_attr_rsp
W (7408) BT_SDP: process_service_attr_rsp
How do I get the authentication to pass? A hardcoded pin or no pin is fine for the proof of concept.D (18098) nvs: nvs_open_from_partition bt_config.conf 1
D (18098) nvs: nvs_set_blob bt_cfg_key0 784
W (18108) BT_BTM: btm_sec_clr_temp_auth_service() - no dev CB
D (18118) nvs: nvs_close 4
E (18118) BT_BTC: btc_dm_auth_cmpl_evt() Authentication fail reason 5
V (18118) ESP_HID_GAP: BT GAP EVENT AUTH_CMPL
E (18118) BT_HIDH: OPEN ERROR: ERR_AUTH_FAILED
D (18128) event: running post ESP_HIDH_EVENTS:0 with handler 0x400d898c and context 0x3ffb7318 on loop 0x3ffca68c
0x400d898c: esp_hidh_process_event_data_handler at esp-idf/components/esp_hid/src/esp_hidh.c:817
D (18138) event: running post ESP_HIDH_EVENTS:0 with handler 0x400d782c and context 0x3ffb7358 on loop 0x3ffca68c
0x400d782c: hidh_callback at build/../main/esp_hid_host_main.c:33
E (18148) ESP_HIDH_DEMO: OPEN failed!
Do I need to an HCI driver? If so, where can I find one or how do I create one?