LivoxGen/Proto1: Move en/disablePcloudData call to Gen1
We no longer try to enable pcloud data as part of the connectReq() sequence. Instead we separate them so that a device can be connected but not be issuing pcloud data.
This commit is contained in:
@@ -142,17 +142,6 @@ public:
|
||||
* 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,
|
||||
@@ -181,8 +170,7 @@ public:
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
context->device.startHeartbeat();
|
||||
|
||||
// Use async delay before enabling point cloud data
|
||||
delayedEnablePcloudData(context);
|
||||
context->connectReq3(context, success);
|
||||
}
|
||||
|
||||
void connectReq2(
|
||||
@@ -201,39 +189,18 @@ public:
|
||||
context->device.discoveredDevice.ipAddr = ipAddr;
|
||||
context->device.startHeartbeat();
|
||||
|
||||
// Use async delay before enabling point cloud data
|
||||
delayedEnablePcloudData(context);
|
||||
context->connectReq3(context, success);
|
||||
}
|
||||
|
||||
void connectReq3(
|
||||
std::shared_ptr<ConnectReq> context,
|
||||
const boost::system::error_code& error
|
||||
)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
// Timer was cancelled or error occurred
|
||||
context->callOriginalCallbackWithFailure();
|
||||
return;
|
||||
}
|
||||
|
||||
context->device.enablePcloudDataReq(
|
||||
{context, std::bind(&ConnectReq::connectReq4,
|
||||
context.get(), context,
|
||||
std::placeholders::_1)});
|
||||
}
|
||||
|
||||
void connectReq4(
|
||||
std::shared_ptr<ConnectReq> context,
|
||||
bool success
|
||||
std::shared_ptr<ConnectReq> context, bool success
|
||||
)
|
||||
{
|
||||
if (!success)
|
||||
{
|
||||
std::cerr << __func__ << ": Failed to enable point cloud data for "
|
||||
"device (" << context->device.discoveredDevice.deviceIdentifier
|
||||
std::cerr << __func__ << ": Failed to connect to device "
|
||||
"(" << context->device.discoveredDevice.deviceIdentifier
|
||||
<< ") @(" << context->device.discoveredDevice.ipAddr << ").\n";
|
||||
|
||||
context->callOriginalCallbackWithFailure();
|
||||
return;
|
||||
}
|
||||
@@ -1550,13 +1517,16 @@ protected:
|
||||
response->command.cmd_id == 0x04 &&
|
||||
response->ret_code == 0x00))
|
||||
{
|
||||
std::cerr << __func__ << ": Failed to enable pcloud data for dev "
|
||||
"(" << context->device.discoveredDevice.deviceIdentifier
|
||||
<< ") @(" << context->device.discoveredDevice.ipAddr << "). "
|
||||
<< "cmd_set: " << (int)response->command.cmd_set
|
||||
<< ", cmd_id: " << (int)response->command.cmd_id
|
||||
<< ", ret_code: " << (int)response->ret_code << "\n";
|
||||
|
||||
if (OptionParser::getOptions().verbose)
|
||||
{
|
||||
std::cout << __func__ << ": Failed to en/disable pcloud data "
|
||||
"for device "
|
||||
"(" << context->device.discoveredDevice.deviceIdentifier
|
||||
<< ") @(" << context->device.discoveredDevice.ipAddr << "). "
|
||||
<< "cmd_set: " << (int)response->command.cmd_set
|
||||
<< ", cmd_id: " << (int)response->command.cmd_id
|
||||
<< ", ret_code: " << (int)response->ret_code << "\n";
|
||||
}
|
||||
context->callOriginalCallbackWithFailure();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user