Open wushifu32 opened 2 years ago
I experienced the same problem. I believe there are a couple of reasons:
1 - the amount of data received in hidh_callback() appears to cause a deadlock of some kind. To work around this I did the following: case ESP_HIDH_INPUT_EVENT: {
printf("!\n");
#else
const uint8_t *bda = esp_hidh_dev_bda_get(param->input.dev);
ESP_LOGI(TAG, ESP_BD_ADDR_STR " INPUT: %8s, MAP: %2u, ID: %3u, Len: %d, Data:", ESP_BD_ADDR_HEX(bda), esp_hid_usage_str(param->input.usage), param->input.map_index, param->input.report_id, param->input.length);
ESP_LOG_BUFFER_HEX(TAG, param->input.data, param->input.length);
#endif
break;
}
2 - hid_demo_task() exits. To work around this I did the following:
while (true)
{
vTaskDelay(1000);
printf(".\n");
}
#else
vTaskDelete(NULL);
#endif
With these changes, the esp_hid_host_demo example code maintains a connection to the PS4 controller.
Hi @wushifu32,
Is this issue still exist? It seems that @BillPlunkett have solve this issue.
@boblane1 I don't think this is solved yet. I'm having the same issue with a PS5 controller. Even with the changes suggested by @BillPlunkett.
The PS5 is a different story. I was also unable to get it to work.
@BillPlunkett @leonrinkel Can you provide some log with PS5?
@boblane1 Here you go. Output stops after a second or so, but esp & controller stay connected.
Hi @leonrinkel,
Thanks for your log. Since I don't have a PS5 on hand, I can only give my guess here.
queue_size
of event_task_args
in esp-idf/components/esp_hid/src/bt_hidh.ctask_priority
of event_task_args
in esp-idf/components/esp_hid/src/bt_hidh.c. For now, the value of task_priority
is same with the app_main
task, which is equal to 1.Please let me know if these changes take effect, thanks.
Hi @boblane1, one thing that I tried already is removing the event loop entirely and only calling a small, interrupt-like function instead of esp_event_post_to()
for the input event. This still has the same effect of receiving reports for like a second before hanging.
I managed to get it working with the PS5 controller by moving Bluedroid to core 1 (CONFIG_BT_BLUEDROID_PINNED_TO_CORE_1=y
) and keeping hidh_callback()
as slim as possible, i.e. no printing.
Great, I am glad you resolved this issue.
Answers checklist.
General issue report
I run the esp_hid_host example to connect to PS4 controller. From the uart.log, the controller is connected. But after that, the controller power led off, and lost the connection. It seems the controller send many input reporter before it power off:
I guess the PS4 controller need some reply form ESP32 to continue? Is there anybody also use esp-idf to connect PS4 controller and meet this issue?