From 3b0bbe0269dd4f6c27256cc4e6a0ecf557802858 Mon Sep 17 00:00:00 2001 From: "c.dragomir" Date: Thu, 26 Oct 2023 11:40:05 +0300 Subject: [PATCH] fixed connection callback triggering when device not connected --- src/USBHost/USBHost.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/USBHost/USBHost.cpp b/src/USBHost/USBHost.cpp index 77ff9e0..a434ae7 100644 --- a/src/USBHost/USBHost.cpp +++ b/src/USBHost/USBHost.cpp @@ -180,6 +180,12 @@ void USBHost::usb_process() res = getDeviceDescriptor(&devices[i], buf, 8); if (res == USB_TYPE_OK) { + + + if (nullptr != mount_fnc) { + mount_fnc(); + } + break; } @@ -189,9 +195,7 @@ void USBHost::usb_process() USB_INFO("New device connected: %p [hub: %d - port: %d]", &devices[i], usb_msg->hub, usb_msg->port); // Call the device connected callback if registered - if (nullptr != mount_fnc) { - mount_fnc(); - } + #if MAX_HUB_NB if (buf[4] == HUB_CLASS) {