diff --git a/examples/peripherals/usb/host/uvc/main/Kconfig.projbuild b/examples/peripherals/usb/host/uvc/main/Kconfig.projbuild index 89e0ddbfc5..2414d0f3bc 100644 --- a/examples/peripherals/usb/host/uvc/main/Kconfig.projbuild +++ b/examples/peripherals/usb/host/uvc/main/Kconfig.projbuild @@ -12,7 +12,7 @@ menu "Example Configuration" config EXAMPLE_UVC_PROTOCOL_MODE_AUTO bool "Auto" help - When protocol mode set to Auto, the example tries to make three attempts to negotiatiate + When protocol mode set to Auto, the example tries to make three attempts to negotiate the protocol with following parameters: 1 Attempt: 640x480, 15 FPS, MJPEG 2 Attempt: 320x240, 30 FPS, MJPEG @@ -24,8 +24,8 @@ menu "Example Configuration" bool "Custom" help When protocol mode set to Custom, the example tries to negotiate protocol with - configured parameters: Attempts, Width, Heighs, FPS, Frame Coding format. - After all attemts result in an error, the example displays the error message and + configured parameters: Attempts, Width, Height, FPS, Frame Coding format. + After all attempts result in an error, the example displays the error message and suggests to try another USB UVC Device. endchoice @@ -45,7 +45,7 @@ menu "Example Configuration" help Configure the negotiation width parameter during UVC device stream getting. config EXAMPLE_HEIGHT_PARAM - int "Heigth resolution in pixels" + int "Height resolution in pixels" default 240 help Configure the negotiation height parameter during UVC device stream getting. diff --git a/examples/peripherals/usb/host/uvc/main/idf_component.yml b/examples/peripherals/usb/host/uvc/main/idf_component.yml index 7165e510cd..1246daeab5 100644 --- a/examples/peripherals/usb/host/uvc/main/idf_component.yml +++ b/examples/peripherals/usb/host/uvc/main/idf_component.yml @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: idf: ">=5.0" - usb_host_uvc: "^1.0.0" - mdns: "^1.2.0" + usb_host_uvc: "^1.0.3" + mdns: "^1.2.5" protocol_examples_common: path: ${IDF_PATH}/examples/common_components/protocol_examples_common diff --git a/examples/peripherals/usb/host/uvc/main/main.c b/examples/peripherals/usb/host/uvc/main/main.c index cc996727c5..86a7b95f80 100644 --- a/examples/peripherals/usb/host/uvc/main/main.c +++ b/examples/peripherals/usb/host/uvc/main/main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -170,9 +170,9 @@ static uvc_error_t uvc_negotiate_stream_profile(uvc_device_handle_t *devh, uvc_stream_ctrl_t *ctrl) { uvc_error_t res; - int attempt = CONFIG_EXAMPLE_NEGOTIATION_ATTEMPTS; #if (CONFIG_EXAMPLE_UVC_PROTOCOL_MODE_AUTO) for (int idx = 0; idx < EXAMPLE_UVC_PROTOCOL_AUTO_COUNT; idx++) { + int attempt = CONFIG_EXAMPLE_NEGOTIATION_ATTEMPTS; do { /* The uvc_get_stream_ctrl_format_size() function will attempt to set the desired format size. @@ -191,9 +191,9 @@ static uvc_error_t uvc_negotiate_stream_profile(uvc_device_handle_t *devh, break; } } -#endif // CONFIG_EXAMPLE_UVC_PROTOCOL_MODE_AUTO -#if (CONFIG_EXAMPLE_UVC_PROTOCOL_MODE_CUSTOM) +#elif (CONFIG_EXAMPLE_UVC_PROTOCOL_MODE_CUSTOM) + int attempt = CONFIG_EXAMPLE_NEGOTIATION_ATTEMPTS; while (attempt--) { ESP_LOGI(TAG, "Negotiate streaming profile %dx%d, %d fps ...", WIDTH, HEIGHT, FPS); res = uvc_get_stream_ctrl_format_size(devh, ctrl, FORMAT, WIDTH, HEIGHT, FPS); @@ -251,8 +251,11 @@ int app_main(int argc, char **argv) ESP_LOGI(TAG, "Waiting for USB UVC device connection ..."); wait_for_event(UVC_DEVICE_CONNECTED); - UVC_CHECK(uvc_find_device(ctx, &dev, PID, VID, SERIAL_NUMBER)); - ESP_LOGI(TAG, "Device found"); + if (uvc_find_device(ctx, &dev, PID, VID, SERIAL_NUMBER) != UVC_SUCCESS) { + ESP_LOGW(TAG, "UVC device not found"); + continue; // Continue waiting for UVC device + } + ESP_LOGI(TAG, "UVC device found"); // UVC Device open UVC_CHECK(uvc_open(dev, &devh)); diff --git a/examples/peripherals/usb/host/uvc/sdkconfig.ci b/examples/peripherals/usb/host/uvc/sdkconfig.ci new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/peripherals/usb/host/uvc/sdkconfig.ci.custom_format b/examples/peripherals/usb/host/uvc/sdkconfig.ci.custom_format new file mode 100644 index 0000000000..29a564174d --- /dev/null +++ b/examples/peripherals/usb/host/uvc/sdkconfig.ci.custom_format @@ -0,0 +1 @@ +CONFIG_EXAMPLE_UVC_PROTOCOL_MODE_CUSTOM=y diff --git a/examples/peripherals/usb/host/uvc/sdkconfig.ci.stream b/examples/peripherals/usb/host/uvc/sdkconfig.ci.stream new file mode 100644 index 0000000000..5a2909cc95 --- /dev/null +++ b/examples/peripherals/usb/host/uvc/sdkconfig.ci.stream @@ -0,0 +1 @@ +CONFIG_EXAMPLE_ENABLE_STREAMING=y