Skip to content

Commit d13d849

Browse files
committed
feat(usbh_cdc): skip open usb hub device
1 parent 84c851b commit d13d849

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

components/usb/iot_usbh_cdc/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v1.1.0 - 2025-05-13
4+
5+
### Features:
6+
7+
* Skip open usb hub device.
8+
39
## v1.1.0 - 2025-04-21
410

511
### Features:

components/usb/iot_usbh_cdc/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.1.0"
1+
version: "1.1.1"
22
targets:
33
- esp32s2
44
- esp32s3

components/usb/iot_usbh_cdc/iot_usbh_cdc.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,22 @@ static void usb_event_cb(const usb_host_client_event_msg_t *event_msg, void *arg
233233
}
234234
assert(current_device);
235235

236+
const usb_device_desc_t *device_desc;
237+
ESP_ERROR_CHECK(usb_host_get_device_descriptor(current_device, &device_desc));
238+
239+
if (device_desc->bDeviceClass == USB_CLASS_HUB) {
240+
ESP_LOGI(TAG, "Detect hub device, skip");
241+
usb_host_device_close(p_usbh_cdc_obj->cdc_client_hdl, current_device);
242+
return;
243+
}
244+
236245
new_dev_cb_t *new_dev_cb;
237246
SLIST_FOREACH(new_dev_cb, &p_usbh_cdc_obj->new_dev_cb_list, list_entry) {
238247
if (new_dev_cb->cb) {
239248
new_dev_cb->cb(current_device, new_dev_cb->user_data);
240249
}
241250
}
242251

243-
const usb_device_desc_t *device_desc;
244-
ESP_ERROR_CHECK(usb_host_get_device_descriptor(current_device, &device_desc));
245-
246252
usbh_cdc_t *cdc;
247253
bool if_opened = false;
248254
SLIST_FOREACH(cdc, &p_usbh_cdc_obj->cdc_devices_list, list_entry) {
@@ -707,6 +713,12 @@ static esp_err_t _cdc_find_and_open_usb_device(usbh_cdc_t *cdc)
707713
const usb_device_desc_t *device_desc;
708714
ESP_ERROR_CHECK(usb_host_get_device_descriptor(current_device, &device_desc));
709715

716+
if (device_desc->bDeviceClass == USB_CLASS_HUB) {
717+
ESP_LOGD(TAG, "Detect hub device, skip");
718+
usb_host_device_close(p_usbh_cdc_obj->cdc_client_hdl, current_device);
719+
continue;
720+
}
721+
710722
if ((cdc->vid == device_desc->idVendor || cdc->vid == CDC_HOST_ANY_VID) &&
711723
(cdc->pid == device_desc->idProduct || cdc->pid == CDC_HOST_ANY_PID)) {
712724
// Return path 2:

0 commit comments

Comments
 (0)