From 51b70b179cf28e1a03abea511d6c459db5fada82 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sun, 28 Sep 2025 01:15:36 -0400 Subject: [PATCH] DevMgr: call newDevAttSpecInd & not attDevReq in body:initReq This performs a more complete device initialization and attachment sequence. We'll do the corresponding teardown in the shutdown sequence later. We might probably do it as deviceRoleGoneAwayInd() --- smocore/deviceManager/deviceManager.cpp | 10 ++++++---- smocore/include/deviceManager/deviceRole.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/smocore/deviceManager/deviceManager.cpp b/smocore/deviceManager/deviceManager.cpp index bd741f6..97a87f4 100644 --- a/smocore/deviceManager/deviceManager.cpp +++ b/smocore/deviceManager/deviceManager.cpp @@ -106,7 +106,7 @@ public: } // Create DeviceRole and add it to both DeviceManager's and Device's collections - auto deviceRole = std::make_shared(spec); + auto deviceRole = std::make_shared(*device, spec); attachedDeviceRoles.push_back(deviceRole); device->deviceRoles.push_back(deviceRole); @@ -357,19 +357,21 @@ public: { for (const auto& spec : DeviceManager::deviceAttachmentSpecs) { - DeviceManager::getInstance().attachSenseDeviceReq( + DeviceManager::getInstance().newDeviceAttachmentSpecInd( spec, {context, std::bind( &AttachAllSenseDevicesFromSpecsReq::attachAllSenseDevicesFromSpecsReq2, context.get(), context, - std::placeholders::_1, std::placeholders::_2)}); + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)}); } } // Callback methods for the attachment sequence void attachAllSenseDevicesFromSpecsReq2( std::shared_ptr context, - bool success, std::shared_ptr spec + bool success, std::shared_ptr deviceRole, + std::shared_ptr spec ) { if (!success) diff --git a/smocore/include/deviceManager/deviceRole.h b/smocore/include/deviceManager/deviceRole.h index 046fd15..12c6b87 100644 --- a/smocore/include/deviceManager/deviceRole.h +++ b/smocore/include/deviceManager/deviceRole.h @@ -7,14 +7,19 @@ namespace smo { namespace device { +class Device; // Forward declaration + class DeviceRole { public: - DeviceRole(std::shared_ptr spec) - : deviceAttachmentSpec(spec) + DeviceRole( + Device& parentDevice, + std::shared_ptr& spec) + : parentDevice(parentDevice), deviceAttachmentSpec(spec) {} - std::shared_ptr deviceAttachmentSpec; + Device& parentDevice; + std::shared_ptr deviceAttachmentSpec; }; } // namespace device