From 99aa407cf16ebcf200d9d42e13f607d08cbb720c Mon Sep 17 00:00:00 2001 From: "peter.marcisovsky" Date: Thu, 4 Dec 2025 16:32:01 +0100 Subject: [PATCH] fix(usb_host): Dont abort on unsupported client events - suspend and resume client events --- .../usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c | 3 +-- examples/peripherals/usb/host/hid/main/hid_host_example.c | 5 +++-- examples/peripherals/usb/host/msc/main/msc_example_main.c | 2 ++ .../peripherals/usb/host/usb_host_lib/main/class_driver.c | 6 +++--- examples/peripherals/usb/host/uvc/main/main.c | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/peripherals/usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c b/examples/peripherals/usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c index 22d9cce080..49fca0709f 100644 --- a/examples/peripherals/usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c +++ b/examples/peripherals/usb/host/cdc/cdc_acm_host/main/usb_cdc_example_main.c @@ -67,9 +67,8 @@ static void handle_event(const cdc_acm_host_dev_event_data_t *event, void *user_ case CDC_ACM_HOST_SERIAL_STATE: ESP_LOGI(TAG, "Serial state notif 0x%04X", event->data.serial_state.val); break; - case CDC_ACM_HOST_NETWORK_CONNECTION: default: - ESP_LOGW(TAG, "Unsupported CDC event: %i", event->type); + ESP_LOGW(TAG, "Unsupported CDC event: %d (possibly suspend/resume)", event->type); break; } } diff --git a/examples/peripherals/usb/host/hid/main/hid_host_example.c b/examples/peripherals/usb/host/hid/main/hid_host_example.c index eb3090a45c..f5b081ef48 100644 --- a/examples/peripherals/usb/host/hid/main/hid_host_example.c +++ b/examples/peripherals/usb/host/hid/main/hid_host_example.c @@ -502,8 +502,9 @@ void hid_host_interface_callback(hid_host_device_handle_t hid_device_handle, hid_proto_name_str[dev_params.proto]); break; default: - ESP_LOGE(TAG, "HID Device, protocol '%s' Unhandled event", - hid_proto_name_str[dev_params.proto]); + ESP_LOGW(TAG, "HID Device, protocol '%s' Unhandled event: %d (possibly suspend/resume)", + hid_proto_name_str[dev_params.proto], + event); break; } } diff --git a/examples/peripherals/usb/host/msc/main/msc_example_main.c b/examples/peripherals/usb/host/msc/main/msc_example_main.c index 4f66e12143..161b1aef62 100644 --- a/examples/peripherals/usb/host/msc/main/msc_example_main.c +++ b/examples/peripherals/usb/host/msc/main/msc_example_main.c @@ -264,6 +264,8 @@ static void msc_event_cb(const msc_host_event_t *event, void *arg) .data.device_handle = event->device.handle, }; xQueueSend(app_queue, &message, portMAX_DELAY); + } else { + ESP_LOGW(TAG, "Unsupported MSC event: %d (possibly suspend/resume)", event->event); } } diff --git a/examples/peripherals/usb/host/usb_host_lib/main/class_driver.c b/examples/peripherals/usb/host/usb_host_lib/main/class_driver.c index 5a89e40dea..a0b656b977 100644 --- a/examples/peripherals/usb/host/usb_host_lib/main/class_driver.c +++ b/examples/peripherals/usb/host/usb_host_lib/main/class_driver.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -80,8 +80,8 @@ static void client_event_cb(const usb_host_client_event_msg_t *event_msg, void * xSemaphoreGive(driver_obj->constant.mux_lock); break; default: - // Should never occur - abort(); + ESP_LOGW(TAG, "Unsupported client event: %d (possibly suspend/resume)", event_msg->event); + break; } } diff --git a/examples/peripherals/usb/host/uvc/main/main.c b/examples/peripherals/usb/host/uvc/main/main.c index d830a015f4..9769ab201f 100644 --- a/examples/peripherals/usb/host/uvc/main/main.c +++ b/examples/peripherals/usb/host/uvc/main/main.c @@ -114,7 +114,7 @@ static void stream_callback(const uvc_host_stream_event_data_t *event, void *use ESP_LOGW(TAG, "Frame buffer underflow"); break; default: - abort(); + ESP_LOGW(TAG, "Unsupported UVC event: %d (possibly suspend/resume)", event->type); break; } }