I'm new to the mailgroup. I searched the history, but couldn't find a solution to my problem.
I'm trying to use a Wiimote (HID device) in combination with an ESP32 and BTstack.
I succeed in discovering the Wiimote with the ESP32, connecting to it, pair and get HID reports.
When turning off the Wiimote, that also gets reported in the ESP32.
When turning the Wiimote back on, it will send a connection request to the ESP32. The ESP32 accepts and asks for a role switch to become master. That fails however. The connection is made, but the role switch fails. After that the Wiimote turns itself back off.
The procedure works fine when done on a MacBook (with the standard OS functions to discover and connect Bluetooth devices). Wiimote requests a connection, the mac accepts with a request to switch roles and gets the master role.
The same seems to happen when I use a Dell mouse instead of the Wiimote.
I have searched many places, but couldn't find a solution. I also have no clue how to debug further. Can you give advice on what to look for?
[00:00:44.296] EVT <= 04 0A 9C 28 91 1D 19 00 04 25 00 01 --> incoming connection request
[00:00:44.296] LOG -- hci.c.2093: Connection_incoming: 00:19:1D:91:28:9C, type 1
[00:00:44.297] LOG -- hci.c.187: create_connection_for_addr 00:19:1D:91:28:9C, type ff
[00:00:44.305] LOG -- hci.c.3510: sending hci_accept_connection_request, remote eSCO 0
[00:00:44.313] CMD => 09 04 07 9C 28 91 1D 19 00 00 --> MacBook sends same reply AND reports later that it became master.
Connection request from: 00:19:1D:91:28:9C
[00:00:44.321] EVT <= 0F 04 00 05 09 04
** Unhandled HCI event: 0x0f : 0F 04 00 05 09 04
[00:00:44.329] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.337] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 4294967295
[00:00:44.344] EVT <= 6E 00
** Unhandled HCI event: 0x6e : 6E 00
[00:00:44.350] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.358] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 4294967295
[00:00:44.590] EVT <= 12 08 35 9C 28 91 1D 19 00 01 --> ESP reports the role switch failed and it stays slave.
role change 12 08 35 9C 28 91 1D 19 00 01
-- status: 0x35, role: 0x1
[00:00:44.591] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.597] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 4294967295
[00:00:44.630] EVT <= 03 0B 00 80 00 9C 28 91 1D 19 00 01 00 --> connection OK
[00:00:44.630] LOG -- hci.c.2117: Connection_complete (status=0) 00:19:1D:91:28:9C
[00:00:44.632] LOG -- hci.c.2130: New connection: handle 128, 00:19:1D:91:28:9C
[00:00:44.639] LOG -- hci.c.4204: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1
[00:00:44.645] EVT <= 61 01 01
** Unhandled HCI event: 0x61 : 61 01 01
HCI: Connected: 00:19:1D:91:28:9C
discovered device connecting back
can send: asking role switch
[00:00:44.660] CMD => 0B 08 07 9C 28 91 1D 19 00 00 --> Second attempt to ask for a role switch, but no effect
[00:00:44.665] EVT <= 0F 04 0C 05 0B 08
** Unhandled HCI event: 0x0f : 0F 04 0C 05 0B 08
[00:00:44.673] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.680] LOG -- btstack_run_loop_freertos.c.218: RL: now 44680, expires 54633
[00:00:44.688] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 9953
[00:00:44.695] EVT <= 6E 00
** Unhandled HCI event: 0x6e : 6E 00
[00:00:44.701] CMD => 1B 04 02 80 00
[00:00:44.705] EVT <= 0F 04 00 05 1B 04
** Unhandled HCI event: 0x0f : 0F 04 00 05 1B 04
[00:00:44.712] EVT <= 0B 0B 00 80 00 BC 02 04 38 08 00 00 00
[00:00:44.718] LOG -- hci.c.2183: HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE, bonding flags 2, eSCO 0
read remote supported features done
[00:00:44.731] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.738] LOG -- btstack_run_loop_freertos.c.218: RL: now 44738, expires 54633
[00:00:44.745] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 9895
[00:00:44.753] EVT <= 6E 00
** Unhandled HCI event: 0x6e : 6E 00
[00:00:44.759] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:44.766] LOG -- btstack_run_loop_freertos.c.218: RL: now 44766, expires 54633
[00:00:44.773] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 9867
[00:00:46.763] EVT <= 05 04 00 80 00 16
** Unhandled HCI event: 0x05 : 05 04 00 80 00 16
[00:00:46.763] LOG -- hci.c.929: Connection closed: handle 0x80, 00:19:1D:91:28:9C
[00:00:46.767] LOG -- hci.c.4204: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 0
[00:00:46.774] EVT <= 61 01 00
** Unhandled HCI event: 0x61 : 61 01 00
[00:00:46.780] LOG -- btstack_run_loop_freertos.c.214: RL: portMAX_DELAY 4294967295
[00:00:46.787] LOG -- btstack_run_loop_freertos.c.230: RL: wait with timeout 4294967295