From 20d568a063134286e7105e9d5c80628fbe4f5a3c Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sun, 28 Sep 2025 23:26:44 -0400 Subject: [PATCH] DevMgr: Call attachAll*FromKnownListReq in DeviceReattacher Well, I guess now we have auto-reattaching devices. --- smocore/deviceManager/deviceManager.cpp | 3 ++- smocore/deviceManager/deviceReattacher.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/smocore/deviceManager/deviceManager.cpp b/smocore/deviceManager/deviceManager.cpp index 92c4530..3e8c58f 100644 --- a/smocore/deviceManager/deviceManager.cpp +++ b/smocore/deviceManager/deviceManager.cpp @@ -589,7 +589,8 @@ void DeviceManager::attachAllUnattachedDevicesFromKnownListReq( ) { // Create a vector to hold unattached device specs - auto unattachedSpecs = std::make_shared>(); + auto unattachedSpecs = std::make_shared< + std::vector>(); // Cycle through all DA specs in deviceAttachmentSpecs for (const auto& spec : deviceAttachmentSpecs) diff --git a/smocore/deviceManager/deviceReattacher.cpp b/smocore/deviceManager/deviceReattacher.cpp index 7c8f970..729476d 100644 --- a/smocore/deviceManager/deviceReattacher.cpp +++ b/smocore/deviceManager/deviceReattacher.cpp @@ -2,12 +2,22 @@ #include #include #include +#include #include #include namespace smo { namespace device { +static void reattachmentCb(AsynchronousLoop& results) +{ + if (results.nTotal == 0) { return; } + + std::cout << "DeviceReattacher: Successfully reattached " + << results.nSucceeded << " of " << results.nTotal << " devices" + << std::endl; +} + DeviceReattacher::DeviceReattacher( DeviceManager& parent, std::shared_ptr ioThread) : parent(parent), ioThread(ioThread), shouldContinue(false), @@ -60,6 +70,11 @@ void DeviceReattacher::onTimeout(const boost::system::error_code& error) return; } + // Attempt to reattach all unattached devices from the known list + parent.attachAllUnattachedDevicesFromKnownListReq( + Callback( + nullptr, reattachmentCb)); + // Schedule the next timeout scheduleNextTimeout(); }