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;
|
||||
}
|
||||
|
||||
@@ -62,4 +62,32 @@ void livoxProto1_exit(void)
|
||||
livoxProto1::exit();
|
||||
}
|
||||
|
||||
void livoxProto1_device_enablePcloudDataReq(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback
|
||||
)
|
||||
{
|
||||
if (!device)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Device pointer is null");
|
||||
}
|
||||
|
||||
device->enablePcloudDataReq(callback);
|
||||
}
|
||||
|
||||
void livoxProto1_device_disablePcloudDataReq(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback
|
||||
)
|
||||
{
|
||||
if (!device)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Device pointer is null");
|
||||
}
|
||||
|
||||
device->disablePcloudDataReq(callback);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -67,14 +67,29 @@ typedef void livoxProto1_destroyDeviceReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback);
|
||||
|
||||
typedef std::function<void(bool success)>
|
||||
livoxProto1_device_enablePcloudDataReqCbFn;
|
||||
typedef void livoxProto1_device_enablePcloudDataReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback);
|
||||
|
||||
typedef std::function<void(bool success)>
|
||||
livoxProto1_device_disablePcloudDataReqCbFn;
|
||||
typedef void livoxProto1_device_disablePcloudDataReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback);
|
||||
|
||||
|
||||
livoxProto1_mainFn livoxProto1_main;
|
||||
livoxProto1_exitFn livoxProto1_exit;
|
||||
livoxProto1_getOrCreateDeviceReqFn livoxProto1_getOrCreateDeviceReq;
|
||||
livoxProto1_destroyDeviceReqFn livoxProto1_destroyDeviceReq;
|
||||
livoxProto1_device_enablePcloudDataReqFn livoxProto1_device_enablePcloudDataReq;
|
||||
livoxProto1_device_disablePcloudDataReqFn
|
||||
livoxProto1_device_disablePcloudDataReq;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // LIVOXPROTO1_H
|
||||
#endif // LIVOXPROTO1_H
|
||||
|
||||
Reference in New Issue
Block a user