livoxProto1: export getReturnModeReq; cache result in Device
This commit is contained in:
@@ -2124,6 +2124,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
device.currentReturnMode = Device::ReturnMode(context->returnMode);
|
||||
context->callOriginalCallback(true);
|
||||
}
|
||||
|
||||
@@ -2369,6 +2370,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
device.currentReturnMode = Device::ReturnMode(response->mode);
|
||||
context->callOriginalCallback(true, response->mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,14 @@ private:
|
||||
class GetReturnModeReq;
|
||||
|
||||
public:
|
||||
enum class ReturnMode : uint8_t
|
||||
{
|
||||
SingleFirst = 0x00,
|
||||
SingleStrongest = 0x01,
|
||||
Dual = 0x02,
|
||||
Triple = 0x03
|
||||
};
|
||||
|
||||
// Utility methods
|
||||
std::optional<std::string> getSmoIp(const std::string& deviceIP);
|
||||
|
||||
@@ -158,6 +166,9 @@ public:
|
||||
std::unique_ptr<boost::asio::posix::stream_descriptor> pcloudDataSocketDesc;
|
||||
std::atomic<bool> pcloudDataActive;
|
||||
|
||||
// Cached last-known return mode for this device
|
||||
ReturnMode currentReturnMode = ReturnMode::SingleFirst;
|
||||
|
||||
public:
|
||||
// UDP datagram handling
|
||||
void handleUdpDgram(
|
||||
|
||||
@@ -90,4 +90,18 @@ void livoxProto1_device_disablePcloudDataReq(
|
||||
device->disablePcloudDataReq(callback);
|
||||
}
|
||||
|
||||
void livoxProto1_device_getReturnModeReq(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_getReturnModeReqCbFn> callback
|
||||
)
|
||||
{
|
||||
if (!device)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Device pointer is null");
|
||||
}
|
||||
|
||||
device->getReturnModeReq(callback);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
@@ -79,6 +79,11 @@ typedef void livoxProto1_device_disablePcloudDataReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback);
|
||||
|
||||
typedef std::function<void(bool success, uint8_t returnMode)>
|
||||
livoxProto1_device_getReturnModeReqCbFn;
|
||||
typedef void livoxProto1_device_getReturnModeReqFn(
|
||||
std::shared_ptr<livoxProto1::Device> device,
|
||||
smo::Callback<livoxProto1_device_getReturnModeReqCbFn> callback);
|
||||
|
||||
livoxProto1_mainFn livoxProto1_main;
|
||||
livoxProto1_exitFn livoxProto1_exit;
|
||||
@@ -87,6 +92,7 @@ livoxProto1_destroyDeviceReqFn livoxProto1_destroyDeviceReq;
|
||||
livoxProto1_device_enablePcloudDataReqFn livoxProto1_device_enablePcloudDataReq;
|
||||
livoxProto1_device_disablePcloudDataReqFn
|
||||
livoxProto1_device_disablePcloudDataReq;
|
||||
livoxProto1_device_getReturnModeReqFn livoxProto1_device_getReturnModeReq;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user