livoxProto1: connectReq: Add 5ms delay before Sample enable msg
This commit is contained in:
@@ -134,16 +134,30 @@ class Device::ConnectReq
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Device& device;
|
Device& device;
|
||||||
|
boost::asio::deadline_timer delayTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConnectReq(Device& dev, smo::Callback<Device::connectReqCbFn> cb)
|
ConnectReq(Device& dev, smo::Callback<Device::connectReqCbFn> cb)
|
||||||
: smo::NonPostedAsynchronousContinuation<Device::connectReqCbFn>(
|
: smo::NonPostedAsynchronousContinuation<Device::connectReqCbFn>(
|
||||||
std::move(cb)), device(dev)
|
std::move(cb)), device(dev),
|
||||||
|
delayTimer(dev.componentThread->getIoService())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/** FIXME:
|
/** FIXME:
|
||||||
* WE need to assign the ipAddr to the Device being connected up.
|
* 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
|
// Callback methods for the connection sequence
|
||||||
void connectReq1(
|
void connectReq1(
|
||||||
std::shared_ptr<ConnectReq> context,
|
std::shared_ptr<ConnectReq> context,
|
||||||
@@ -172,9 +186,8 @@ public:
|
|||||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||||
context->device.startHeartbeat();
|
context->device.startHeartbeat();
|
||||||
|
|
||||||
context->device.enablePcloudDataReq(
|
// Use async delay before enabling point cloud data
|
||||||
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
|
delayedEnablePcloudData(context);
|
||||||
std::placeholders::_1)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void connectReq2(
|
void connectReq2(
|
||||||
@@ -193,12 +206,29 @@ public:
|
|||||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||||
context->device.startHeartbeat();
|
context->device.startHeartbeat();
|
||||||
|
|
||||||
context->device.enablePcloudDataReq(
|
// Use async delay before enabling point cloud data
|
||||||
{context, std::bind(&ConnectReq::connectReq3, context.get(), context,
|
delayedEnablePcloudData(context);
|
||||||
std::placeholders::_1)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void connectReq3(
|
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,
|
std::shared_ptr<ConnectReq> context,
|
||||||
bool success
|
bool success
|
||||||
)
|
)
|
||||||
@@ -1588,8 +1618,6 @@ void Device::enablePcloudDataReq(
|
|||||||
smo::Callback<Device::enablePcloudDataReqCbFn> callback
|
smo::Callback<Device::enablePcloudDataReqCbFn> callback
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(105));
|
|
||||||
|
|
||||||
auto request = std::make_shared<EnablePcloudDataReq>(
|
auto request = std::make_shared<EnablePcloudDataReq>(
|
||||||
*this, std::move(callback));
|
*this, std::move(callback));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user