LivoxGen1: Port to coros
No longer uses CPS. We also found and documented a potential bug in the way we deal with disablePcloudData during detachDeviceReq.
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
#ifndef ADAPTERS_SMO_LIVOX_PROTO1_CPS_AWAITERS_H
|
||||
#define ADAPTERS_SMO_LIVOX_PROTO1_CPS_AWAITERS_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <adapters/smo/cpsCallbackAReq.h>
|
||||
#include <livoxProto1/livoxProto1.h>
|
||||
#include <spinscale/componentThread.h>
|
||||
|
||||
namespace adapters::smo {
|
||||
|
||||
struct GetOrCreateDeviceResult
|
||||
{
|
||||
bool success = false;
|
||||
std::shared_ptr<livoxProto1::Device> device;
|
||||
};
|
||||
|
||||
struct GetReturnModeResult
|
||||
{
|
||||
bool success = false;
|
||||
uint8_t returnMode = 0;
|
||||
};
|
||||
|
||||
inline auto getGetOrCreateDeviceReqAReqAwaiter(
|
||||
boost::asio::io_service &resumeIoService,
|
||||
livoxProto1_getOrCreateDeviceReqFn *fn,
|
||||
const std::string &deviceIdentifier,
|
||||
const std::shared_ptr<sscl::ComponentThread> &componentThread,
|
||||
int commandTimeoutMs,
|
||||
int retryDelayMs,
|
||||
const std::string &smoIp,
|
||||
uint8_t smoSubnetNbits,
|
||||
uint16_t dataPort,
|
||||
uint16_t cmdPort,
|
||||
uint16_t imuPort)
|
||||
{
|
||||
return ::smo::cpsBoundary::CpsCallbackAReq<
|
||||
GetOrCreateDeviceResult,
|
||||
livoxProto1_getOrCreateDeviceReqCbFn,
|
||||
std::function<void(sscl::cps::Callback<livoxProto1_getOrCreateDeviceReqCbFn>)>>(
|
||||
resumeIoService,
|
||||
[=](sscl::cps::Callback<livoxProto1_getOrCreateDeviceReqCbFn> cb)
|
||||
{
|
||||
(*fn)(
|
||||
deviceIdentifier,
|
||||
componentThread,
|
||||
commandTimeoutMs, retryDelayMs,
|
||||
smoIp, smoSubnetNbits,
|
||||
dataPort, cmdPort, imuPort,
|
||||
std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
inline auto getDeviceGetReturnModeReqAReqAwaiter(
|
||||
boost::asio::io_service &resumeIoService,
|
||||
livoxProto1_device_getReturnModeReqFn *fn,
|
||||
std::shared_ptr<livoxProto1::Device> device)
|
||||
{
|
||||
return ::smo::cpsBoundary::CpsCallbackAReq<
|
||||
GetReturnModeResult,
|
||||
livoxProto1_device_getReturnModeReqCbFn,
|
||||
std::function<void(sscl::cps::Callback<livoxProto1_device_getReturnModeReqCbFn>)>>(
|
||||
resumeIoService,
|
||||
[=](sscl::cps::Callback<livoxProto1_device_getReturnModeReqCbFn> cb)
|
||||
{
|
||||
(*fn)(device, std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
inline auto getDeviceEnablePcloudDataReqAReqAwaiter(
|
||||
boost::asio::io_service &resumeIoService,
|
||||
livoxProto1_device_enablePcloudDataReqFn *fn,
|
||||
std::shared_ptr<livoxProto1::Device> device)
|
||||
{
|
||||
return ::smo::cpsBoundary::CpsCallbackAReq<
|
||||
bool,
|
||||
livoxProto1_device_enablePcloudDataReqCbFn,
|
||||
std::function<void(sscl::cps::Callback<livoxProto1_device_enablePcloudDataReqCbFn>)>>(
|
||||
resumeIoService,
|
||||
[=](sscl::cps::Callback<livoxProto1_device_enablePcloudDataReqCbFn> cb)
|
||||
{
|
||||
(*fn)(device, std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
inline auto getDeviceDisablePcloudDataReqAReqAwaiter(
|
||||
boost::asio::io_service &resumeIoService,
|
||||
livoxProto1_device_disablePcloudDataReqFn *fn,
|
||||
std::shared_ptr<livoxProto1::Device> device)
|
||||
{
|
||||
return ::smo::cpsBoundary::CpsCallbackAReq<
|
||||
bool,
|
||||
livoxProto1_device_disablePcloudDataReqCbFn,
|
||||
std::function<void(sscl::cps::Callback<livoxProto1_device_disablePcloudDataReqCbFn>)>>(
|
||||
resumeIoService,
|
||||
[=](sscl::cps::Callback<livoxProto1_device_disablePcloudDataReqCbFn> cb)
|
||||
{
|
||||
(*fn)(device, std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
inline auto getDestroyDeviceReqAReqAwaiter(
|
||||
boost::asio::io_service &resumeIoService,
|
||||
livoxProto1_destroyDeviceReqFn *fn,
|
||||
std::shared_ptr<livoxProto1::Device> device)
|
||||
{
|
||||
return ::smo::cpsBoundary::CpsCallbackAReq<
|
||||
bool,
|
||||
livoxProto1_destroyDeviceReqCbFn,
|
||||
std::function<void(sscl::cps::Callback<livoxProto1_destroyDeviceReqCbFn>)>>(
|
||||
resumeIoService,
|
||||
[=](sscl::cps::Callback<livoxProto1_destroyDeviceReqCbFn> cb)
|
||||
{
|
||||
(*fn)(device, std::move(cb));
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace adapters::smo
|
||||
|
||||
#endif // ADAPTERS_SMO_LIVOX_PROTO1_CPS_AWAITERS_H
|
||||
Reference in New Issue
Block a user