From 66a9db13c32a54f5843b273d386bcc224f786ae5 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Wed, 22 Oct 2025 01:59:04 -0400 Subject: [PATCH] LivoxProto1: invoke enablePcloudDataReq Sadly we don't get to immediately see the results of our work because we have to do a unified dispatcher for the incoming UDP messages on the command channel. --- commonLibs/livoxProto1/device.cpp | 67 +++++++++++++++++++------------ smocore/director/director.cpp | 21 ++++++++++ 2 files changed, 62 insertions(+), 26 deletions(-) diff --git a/commonLibs/livoxProto1/device.cpp b/commonLibs/livoxProto1/device.cpp index e40c58d..2ee0d6e 100644 --- a/commonLibs/livoxProto1/device.cpp +++ b/commonLibs/livoxProto1/device.cpp @@ -155,28 +155,33 @@ public: bool success, const std::string& ipAddr, int fd ) { - if (success) + // Fail early - if handshake failed, try next method + if (!success) { - // Store the IP address in the device - context->device.discoveredDevice.ipAddr = ipAddr; - // Store the handshake FD for heartbeats - context->device.heartbeatFd = fd; - context->device.startHeartbeat(); - context->callOriginalCb(true); + if (OptionParser::getOptions().verbose) + { + std::cout << __func__ << ": Trying to connect to device by " + << "identifier" << "\n"; + } + + // Try direct connect by device identifier + context->device.connectByDeviceIdentifierReq( + {context, std::bind(&ConnectReq::connectReq2, + context.get(), context, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3)}); + return; } - if (OptionParser::getOptions().verbose) - { - std::cout << __func__ << ": Trying to connect to device by " - << "identifier" << "\n"; - } + // Success - store connection info and proceed to next step + context->device.discoveredDevice.ipAddr = ipAddr; + context->device.heartbeatFd = fd; + context->device.startHeartbeat(); - // Try direct connect by device identifier - context->device.connectByDeviceIdentifierReq( - {context, std::bind(&ConnectReq::connectReq2, context.get(), context, - std::placeholders::_1, std::placeholders::_2, - std::placeholders::_3)}); + context->device.enablePcloudDataReq( + {context, std::bind(&ConnectReq::connectReq3, context.get(), context, + std::placeholders::_1)}); } void connectReq2( @@ -184,19 +189,29 @@ public: bool success, const std::string& ipAddr, int fd ) { - if (success) + // Fail early - if this also failed, all connection attempts failed + if (!success) { - // Store the IP address in the device - context->device.discoveredDevice.ipAddr = ipAddr; - // Store the handshake FD for heartbeats - context->device.heartbeatFd = fd; - context->device.startHeartbeat(); - context->callOriginalCb(true); + context->callOriginalCb(false); return; } - // All connection attempts failed - context->callOriginalCb(false); + // Success - store connection info and proceed to next step + context->device.discoveredDevice.ipAddr = ipAddr; + context->device.heartbeatFd = fd; + context->device.startHeartbeat(); + + context->device.enablePcloudDataReq( + {context, std::bind(&ConnectReq::connectReq3, context.get(), context, + std::placeholders::_1)}); + } + + void connectReq3( + std::shared_ptr context, + bool success + ) + { + context->callOriginalCb(success); } }; diff --git a/smocore/director/director.cpp b/smocore/director/director.cpp index d95a3db..a1fda4a 100644 --- a/smocore/director/director.cpp +++ b/smocore/director/director.cpp @@ -33,6 +33,27 @@ void Director::intrinEventInd(void) void Director::postrinEventInd(void) { + /** EXPLANATION: + * When a postrin event occurs, a goal is auto-generated, but this goal is + * a bit different from the goals that are auto-generated for negtrins. + * + * A negtrin's goal is to either: get to 0; reduce the negtrin below its + * intolerable threshold; or reduce it somewhat even if not below the + * tolerable threshold. This is very easy to represent as a cologex. + * + * A postrin's goal is to: persist the postrin indefinitely; and increase + * its intensity if possible; and to store it away as something worth + * re-triggering if some external distractor/frustrator interrupts the + * persistent sampling of the postrin. + * + * I can think of how to encode the negtrin goal as a cologex, but I can't + * think of how to encode the postrin goal as a cologex. + * + * With respect to the "store away for future re-triggering" aspect of the + * postrin goal we can encode this by merely refusing to remove any postrin + * goal from the goal prioQ. I suppose negtrins differ in that we do remove + * them from the goal prioQ when they're resolved. + */ std::cout << __func__ << ": Handling postrin event." << std::endl; }