livoxProto1: connectReq: Add 5ms delay before Sample enable msg

This commit is contained in:
2025-10-23 01:27:35 -04:00
parent 44cfd7ab69
commit d39dfb5334
+37 -9
View File
@@ -134,16 +134,30 @@ class Device::ConnectReq
{
private:
Device& device;
boost::asio::deadline_timer delayTimer;
public:
ConnectReq(Device& dev, smo::Callback<Device::connectReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<Device::connectReqCbFn>(
std::move(cb)), device(dev)
std::move(cb)), device(dev),
delayTimer(dev.componentThread->getIoService())
{}
/** FIXME:
* WE need to assign the ipAddr to the Device being connected up.
*/
// Helper method to delay and then call enablePcloudDataReq
void delayedEnablePcloudData(std::shared_ptr<ConnectReq> context)
{
delayTimer.expires_from_now(boost::posix_time::milliseconds(5));
delayTimer.async_wait(
std::bind(
&ConnectReq::connectReq3,
context.get(), context,
std::placeholders::_1));
}
// Callback methods for the connection sequence
void connectReq1(
std::shared_ptr<ConnectReq> context,
@@ -172,9 +186,8 @@ public:
context->device.discoveredDevice.ipAddr = ipAddr;
context->device.startHeartbeat();
context->device.enablePcloudDataReq(
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
std::placeholders::_1)});
// Use async delay before enabling point cloud data
delayedEnablePcloudData(context);
}
void connectReq2(
@@ -193,12 +206,29 @@ public:
context->device.discoveredDevice.ipAddr = ipAddr;
context->device.startHeartbeat();
context->device.enablePcloudDataReq(
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
std::placeholders::_1)});
// Use async delay before enabling point cloud data
delayedEnablePcloudData(context);
}
void connectReq3(
std::shared_ptr<ConnectReq> context,
const boost::system::error_code& error
)
{
if (error)
{
// Timer was cancelled or error occurred
context->callOriginalCb(false);
return;
}
context->device.enablePcloudDataReq(
{context, std::bind(&ConnectReq::connectReq4,
context.get(), context,
std::placeholders::_1)});
}
void connectReq4(
std::shared_ptr<ConnectReq> context,
bool success
)
@@ -1588,8 +1618,6 @@ void Device::enablePcloudDataReq(
smo::Callback<Device::enablePcloudDataReqCbFn> callback
)
{
std::this_thread::sleep_for(std::chrono::milliseconds(105));
auto request = std::make_shared<EnablePcloudDataReq>(
*this, std::move(callback));