ESP32 Selfie/HID Volume Control

josh-gc
Posts: 3
Joined: Tue Oct 17, 2023 7:44 pm

ESP32 Selfie/HID Volume Control

Postby josh-gc » Tue Oct 17, 2023 7:57 pm

I am working on code to adjust the volume on a phone as a way of triggering the camera. I started with the esp_hid_device code in the esp-idf v4.4 branch but made a bunch of changes so that both a BT and a BLE connection launch the same demo script (run_example). This looks for a keyboard input and then will raise and lower the volume based on the input.

On an iPhone13 I get a BLE connection and this works well. On a PIxel7 it connects over BT and then I try to run this command:

Code: Select all

esp_hidd_dev_input_set(s_bt_hid_param.hid_dev, 1, HID_RPT_ID_CC_IN, buffer, HID_CC_IN_RPT_LEN);
I get these errors:

Code: Select all

I (16648) bt_hidd_event_callback: CONNECTED
W (21848) BT_HCI: hci cmd send: sniff: hdl 0x81, intv(10 18)
W (21868) BT_HCI: hcif mode change: hdl 0x81, mode 2, intv 18, status 0x0
I (21868) ESP_HID_GAP: BT GAP MODE_CHG_EVT mode:2
W (21928) BT_HCI: hcif ssr evt: st 0x0, hdl 0x81, tx_lat 360 rx_lat 720
I (22078) esp_hid_device_main: send_volume_up
E (22078) BT_HIDD: index out of range[0-0]
E (22078) BT_HIDD: HID device not connected!
E (22178) BT_HIDD: index out of range[0-0]
E (22178) BT_HIDD: HID device not connected!
Here is a link to my code. Please help explain what is going on in this command and how I can make it work for BT.
https://github.com/josh-gc/esp_selfie

ESP_Boblane
Posts: 5
Joined: Fri Jun 25, 2021 1:43 am

Re: ESP32 Selfie/HID Volume Control

Postby ESP_Boblane » Fri Oct 20, 2023 10:43 am

Hi @josh-gc,

For the original example, it acts as a media device for BLE transport and acts as a mouse device for BR/EDR transport.

If you just want to use the BLE part, you can just disable the ER/EDR HID functionality by setting menuconfig as following.

1. Component config → Bluetooth → Controller Options → Bluetooth controller mode (BR/EDR/BLE/DUALMODE) (BLE Only)
2. Component config → Bluetooth → Bluedroid Options → Classic Bluetooth(Disabled)

If you want to create a media device for each transport. Please modify your code like following.
  1.     ESP_GOTO_ON_ERROR( esp_hidd_dev_init(&ble_hid_config, ESP_HID_TRANSPORT_BT, bt_hidd_event_callback, &s_bt_hid_param.hid_dev), error, TAG, "esp_hidd_dev_init failed" );

josh-gc
Posts: 3
Joined: Tue Oct 17, 2023 7:44 pm

Re: ESP32 Selfie/HID Volume Control

Postby josh-gc » Tue Oct 24, 2023 4:23 pm

I applied the patches to the demo code as shown in this thread: https://github.com/espressif/esp-idf/issues/12397 and then updated the config as you suggested for BLE only and this works. I will cleanup when time allows and post an update then.

Thanks for your help.

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 189 guests