2025-11-03 22:18:45 -04:00
|
|
|
#include <boostAsioLinkageFix.h>
|
2025-09-06 20:06:38 -04:00
|
|
|
#include <stdexcept>
|
2025-09-27 18:30:09 -04:00
|
|
|
#include <callback.h>
|
2025-11-01 22:41:58 -04:00
|
|
|
#include <boost/asio/posix/stream_descriptor.hpp>
|
2025-09-05 00:08:25 -04:00
|
|
|
#include "livoxProto1.h"
|
2025-09-06 20:06:38 -04:00
|
|
|
#include "device.h"
|
|
|
|
|
#include "core.h"
|
2025-11-01 22:41:58 -04:00
|
|
|
#include "udpCommandDemuxer.h"
|
2025-09-06 20:06:38 -04:00
|
|
|
|
2025-09-05 00:08:25 -04:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
2025-09-09 12:07:49 -04:00
|
|
|
void livoxProto1_getOrCreateDeviceReq(
|
2025-09-06 20:06:38 -04:00
|
|
|
const std::string& deviceIdentifier,
|
|
|
|
|
const std::shared_ptr<smo::ComponentThread>& componentThread,
|
2025-11-01 02:45:24 -04:00
|
|
|
int commandTimeoutMs, int retryDelayMs,
|
2025-09-06 20:06:38 -04:00
|
|
|
const std::string& smoIp, uint8_t smoSubnetNbits,
|
2025-09-09 12:07:49 -04:00
|
|
|
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
|
2025-09-27 18:30:09 -04:00
|
|
|
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback
|
2025-09-06 20:06:38 -04:00
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// Get the global DeviceManager instance
|
|
|
|
|
auto& protoState = livoxProto1::getProtoState();
|
|
|
|
|
if (!protoState.deviceManager)
|
|
|
|
|
{
|
|
|
|
|
throw std::runtime_error(
|
|
|
|
|
std::string(__func__) + ": LivoxProto1 not initialized - call "
|
|
|
|
|
"livoxProto1_main first");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delegate to DeviceManager
|
2025-09-09 12:07:49 -04:00
|
|
|
protoState.deviceManager->getOrCreateDeviceReq(
|
2025-09-06 20:06:38 -04:00
|
|
|
deviceIdentifier, componentThread,
|
2025-11-01 02:45:24 -04:00
|
|
|
commandTimeoutMs, retryDelayMs,
|
2025-09-06 20:06:38 -04:00
|
|
|
smoIp, smoSubnetNbits,
|
2025-09-09 12:07:49 -04:00
|
|
|
dataPort, cmdPort, imuPort,
|
|
|
|
|
callback);
|
2025-09-06 20:06:38 -04:00
|
|
|
}
|
2025-09-05 00:08:25 -04:00
|
|
|
|
2025-09-09 12:07:49 -04:00
|
|
|
void livoxProto1_destroyDeviceReq(
|
|
|
|
|
std::shared_ptr<livoxProto1::Device> device,
|
2025-09-27 18:30:09 -04:00
|
|
|
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback
|
2025-09-09 12:07:49 -04:00
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
auto& protoState = livoxProto1::getProtoState();
|
|
|
|
|
if (!protoState.deviceManager)
|
|
|
|
|
{
|
|
|
|
|
throw std::runtime_error(std::string(__func__)
|
|
|
|
|
+ ": DeviceManager not initialized");
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-16 18:36:11 -04:00
|
|
|
protoState.deviceManager->destroyDeviceReq(
|
|
|
|
|
device, callback);
|
2025-09-09 12:07:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void livoxProto1_main(
|
|
|
|
|
const std::shared_ptr<smo::ComponentThread>& componentThread,
|
2025-10-01 18:47:42 -04:00
|
|
|
const smo::stim_buff::SmoCallbacks& smoCallbacks)
|
2025-09-05 00:08:25 -04:00
|
|
|
{
|
2025-09-09 12:07:49 -04:00
|
|
|
livoxProto1::main(componentThread, smoCallbacks);
|
2025-09-05 00:08:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void livoxProto1_exit(void)
|
|
|
|
|
{
|
|
|
|
|
livoxProto1::exit();
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-25 12:53:07 -04:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-30 11:49:54 -04:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-01 22:41:58 -04:00
|
|
|
std::shared_ptr<boost::asio::posix::stream_descriptor>
|
|
|
|
|
livoxProto1_getPcloudDataFdDesc(void)
|
|
|
|
|
{
|
|
|
|
|
auto& protoState = livoxProto1::getProtoState();
|
|
|
|
|
if (!protoState.deviceManager)
|
|
|
|
|
{
|
|
|
|
|
throw std::runtime_error(std::string(__func__)
|
|
|
|
|
+ ": DeviceManager not initialized");
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-02 19:16:22 -04:00
|
|
|
return protoState.deviceManager->udpCommandDemuxer.getPcloudDataFdDesc();
|
2025-11-01 22:41:58 -04:00
|
|
|
}
|
|
|
|
|
|
2025-09-05 00:08:25 -04:00
|
|
|
} // extern "C"
|