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.
This commit is contained in:
2025-10-22 01:59:04 -04:00
parent d9042c6510
commit 66a9db13c3
2 changed files with 62 additions and 26 deletions
+35 -20
View File
@@ -155,17 +155,9 @@ public:
bool success, const std::string& ipAddr, int fd 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);
return;
}
if (OptionParser::getOptions().verbose) if (OptionParser::getOptions().verbose)
{ {
std::cout << __func__ << ": Trying to connect to device by " std::cout << __func__ << ": Trying to connect to device by "
@@ -174,9 +166,22 @@ public:
// Try direct connect by device identifier // Try direct connect by device identifier
context->device.connectByDeviceIdentifierReq( context->device.connectByDeviceIdentifierReq(
{context, std::bind(&ConnectReq::connectReq2, context.get(), context, {context, std::bind(&ConnectReq::connectReq2,
context.get(), context,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3)}); std::placeholders::_3)});
return;
}
// 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 connectReq2( void connectReq2(
@@ -184,19 +189,29 @@ public:
bool success, const std::string& ipAddr, int fd 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->callOriginalCb(false);
context->device.discoveredDevice.ipAddr = ipAddr;
// Store the handshake FD for heartbeats
context->device.heartbeatFd = fd;
context->device.startHeartbeat();
context->callOriginalCb(true);
return; return;
} }
// All connection attempts failed // Success - store connection info and proceed to next step
context->callOriginalCb(false); 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<ConnectReq> context,
bool success
)
{
context->callOriginalCb(success);
} }
}; };
+21
View File
@@ -33,6 +33,27 @@ void Director::intrinEventInd(void)
void Director::postrinEventInd(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; std::cout << __func__ << ": Handling postrin event." << std::endl;
} }