From c966fe607e3beddaa6939030fada35486a6b32f5 Mon Sep 17 00:00:00 2001 From: Jaroslav Burian Date: Mon, 4 Nov 2024 12:26:11 +0100 Subject: [PATCH] fix: Callback when USB port is disconnected Callback function was not being called when USB port was disconnected. The deinit function removed the callback function from the USB driver, deinit function is now after the callback function is called. --- port/esp32_usb_cdc_acm_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/port/esp32_usb_cdc_acm_port.c b/port/esp32_usb_cdc_acm_port.c index 2a3e62a..5af0ab8 100644 --- a/port/esp32_usb_cdc_acm_port.c +++ b/port/esp32_usb_cdc_acm_port.c @@ -64,11 +64,11 @@ static void handle_usb_event(const cdc_acm_host_dev_event_data_t *event, void *u case CDC_ACM_HOST_DEVICE_DISCONNECTED: ESP_LOGI(TAG, "Device disconnected"); - esp_loader_error_t deinit_status = loader_port_esp32_usb_cdc_acm_deinit(); - assert(deinit_status == ESP_LOADER_SUCCESS); if (s_device_disconnected_callback != NULL) { s_device_disconnected_callback(); } + esp_loader_error_t deinit_status = loader_port_esp32_usb_cdc_acm_deinit(); + assert(deinit_status == ESP_LOADER_SUCCESS); break; case CDC_ACM_HOST_SERIAL_STATE: