Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

boernsen
Posts: 9
Joined: Tue Jul 19, 2022 7:43 pm

Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby boernsen » Wed Aug 31, 2022 8:53 pm

Hello everyone,

is it possible to pair an Apple Magic Trackpad (1. gen -> Bluetooth Classic 2.0) with the ESP32? How simple is that? Can I be sure it'll work?

I am asking as I had hard times finding any projects doing such things, even with Bluetooth keyboards.

Thank you in advance!

rodmcm
Posts: 65
Joined: Sat Sep 02, 2017 3:31 am

Re: Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby rodmcm » Sat Sep 10, 2022 11:11 pm

Try using a cell phone app like "Bluetooth Terminal HC-05"
If you can pair and receive data with this from the trackpad then you can do it with an ESP32.
Its my goto App for looking at data streams from BT

boernsen
Posts: 9
Joined: Tue Jul 19, 2022 7:43 pm

Re: Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby boernsen » Thu Sep 22, 2022 6:20 am

As far as I know, these apps only use Bluetooth SPP. Is that correct?

Anyway, the app didn't connect to the trackpad, although it did connect to the Android phone itself. I could even use it as mouse input for the Android device.

I feel it is very hard to find reliable information about the ESP32's Bluetooth capabilities and then in the second step understand what they mean in practice. How can we find out whether it it able to connect to peripheral HID Bluetooth devices such as a Bluetooth mouse?

boernsen
Posts: 9
Joined: Tue Jul 19, 2022 7:43 pm

Re: Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby boernsen » Fri Sep 30, 2022 5:33 pm

I started with the ESP-IDF BT/BLE HID Host Demo.

The trackpad is found, but it doesn't connect. It prints the error:

Code: Select all

BT_HIDH: OPEN ERROR: ERR_SDP
Do you have any idea what I can do or how I can debug it?

This is the full output (Addresses are removed, I double-checked the trackpad's address. It is correct.):

Code: Select all

configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:6660
load:0x40078000,len:14848
ho 0 tail 12 room 4
load:0x40080400,len:3792
0x40080400: _init at ??:?

entry 0x40080694
I (29) boot: ESP-IDF v4.4.2 2nd stage bootloader
I (29) boot: compile time 22:26:57
I (29) boot: chip revision: 3
I (32) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed      : 40MHz
I (44) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (62) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00100000
I (91) boot: End of partition table
I (96) boot_comm: chip revision: 3, min. application chip revision: 0
I (103) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=243f8h (148472) map
I (165) esp_image: segment 1: paddr=00034420 vaddr=3ffbdb60 size=04648h ( 17992) load
I (172) esp_image: segment 2: paddr=00038a70 vaddr=40080000 size=075a8h ( 30120) load
I (185) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=95474h (611444) map
I (406) esp_image: segment 4: paddr=000d549c vaddr=400875a8 size=0f9d4h ( 63956) load
I (433) esp_image: segment 5: paddr=000e4e78 vaddr=50000000 size=00010h (    16) load
I (445) boot: Loaded app from partition at offset 0x10000
I (445) boot: Disabling RNG early entropy source...
I (456) cpu_start: Pro cpu up.
I (457) cpu_start: Starting app cpu, entry point is 0x400811a8
0x400811a8: call_start_cpu1 at /home/ben/esp/esp-idf/components/esp_system/port/cpu_start.c:160

I (0) cpu_start: App cpu up.
I (473) cpu_start: Pro cpu start user code
I (473) cpu_start: cpu freq: 160000000
I (473) cpu_start: Application information:
I (477) cpu_start: Project name:     esp_hid_host
I (483) cpu_start: App version:      1
I (487) cpu_start: Compile time:     Sep 22 2022 22:26:46
I (493) cpu_start: ELF file SHA256:  be923f770e8a3160...
I (499) cpu_start: ESP-IDF:          v4.4.2
I (504) heap_init: Initializing. RAM available for dynamic allocation:
I (511) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (517) heap_init: At 3FFB6388 len 00001C78 (7 KiB): DRAM
I (523) heap_init: At 3FFB9A20 len 00004108 (16 KiB): DRAM
I (530) heap_init: At 3FFC7F70 len 00018090 (96 KiB): DRAM
I (536) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (542) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (549) heap_init: At 40096F7C len 00009084 (36 KiB): IRAM
I (556) spi_flash: detected chip: generic
I (559) spi_flash: flash io: dio
W (563) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (578) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (625) ESP_HIDH_DEMO: setting hid gap, mode:3
I (625) BTDM_INIT: BT controller compile version [bf9c077]
I (625) system_api: Base MAC address is not set
I (625) system_api: read default base MAC address from EFUSE
I (635) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1345) ESP_HIDH_DEMO: EVENT: 5
I (1355) ESP_HIDH_DEMO: SCAN...
< REMOVED >
BT : xx:xx:xx:xx:xx:xx, COD: major: PERIPHERAL, minor: 37, service: 0x001, RSSI: -26
I (15345) ESP_HIDH_DEMO: SCAN: 1 results
  BT : xx:xx:xx:xx:xx:xx, RSSI: -26, USAGE: GENERIC, COD: PERIPHERAL[MOUSE+TABLET] srv 0x001, UUID16: 0x0000, NAME:  
W (20475) BT_SDP: SDP - Rcvd conn cnf with error: 0x4  CID 0x40

W (20475) BT_HCI: hcif conn complete: hdl 0xfff, st 0x4
E (20485) BT_HIDH: OPEN ERROR: ERR_SDP
E (20485) ESP_HIDH_DEMO:  OPEN failed!

rodmcm
Posts: 65
Joined: Sat Sep 02, 2017 3:31 am

Re: Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby rodmcm » Sat Oct 15, 2022 12:37 am

Have a look at this. Ordinary SPP may not assist
https://learn.sparkfun.com/tutorials/bl ... h-profiles

Did you connect with the App I suggested? It is SPP.

boernsen
Posts: 9
Joined: Tue Jul 19, 2022 7:43 pm

Re: Pairing a Bluetooth Classic 2.0 trackpad with the ESP32. Possible? Simple?

Postby boernsen » Sat Oct 22, 2022 5:14 pm

Thanks for the link. That is a good overview over the different profiles.

The app did not connect to the trackpad, which I think is no surprise as the trackpad only supports the HID profiles whereas the app only supports the SPP profile. The trackpad connects to various devices having an OS (tested with Win/Mac/Linux computers and Android phones) and the app connects to my ESP32 when flashing an SPP demo. The trackpad did not yet connect to the ESP32 though.

I opened an issue here: https://github.com/espressif/esp-idf/issues/10005

Who is online

Users browsing this forum: No registered users and 71 guests