Proposal for the bind interface
This commit is contained in:
committed by
diegoalonso29
parent
daf849ef45
commit
5f0e3fd0cd
@@ -222,6 +222,11 @@ void OnDeviceInfoChange(const DeviceInfo *info, DeviceEvent type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDeviceInfoChangeExtra(int param, const DeviceInfo *info, DeviceEvent type) {
|
||||||
|
// ... Do stuff with the extra param
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Callback function when broadcast message received.
|
/** Callback function when broadcast message received.
|
||||||
* You need to add listening device broadcast code and set the point cloud data callback in this function.
|
* You need to add listening device broadcast code and set the point cloud data callback in this function.
|
||||||
*/
|
*/
|
||||||
@@ -238,6 +243,15 @@ void OnDeviceBroadcast(const BroadcastDeviceInfo *info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OptBcast{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
};
|
||||||
|
|
||||||
|
void OnDeviceBroadcastExtra(OptBcast o, const BroadcastDeviceInfo *info) {
|
||||||
|
// ... Do stuff with the extra param
|
||||||
|
}
|
||||||
|
|
||||||
/** Wait until no new device arriving in 2 second. */
|
/** Wait until no new device arriving in 2 second. */
|
||||||
void WaitForDevicesReady( ) {
|
void WaitForDevicesReady( ) {
|
||||||
bool device_ready = false;
|
bool device_ready = false;
|
||||||
@@ -391,14 +405,19 @@ int main(int argc, const char *argv[]) {
|
|||||||
printf("Livox SDK version %d.%d.%d .\n", _sdkversion.major, _sdkversion.minor, _sdkversion.patch);
|
printf("Livox SDK version %d.%d.%d .\n", _sdkversion.major, _sdkversion.minor, _sdkversion.patch);
|
||||||
|
|
||||||
memset(devices, 0, sizeof(devices));
|
memset(devices, 0, sizeof(devices));
|
||||||
|
using namespace std::placeholders;
|
||||||
|
|
||||||
|
|
||||||
/** Set the callback function receiving broadcast message from Livox LiDAR. */
|
/** Set the callback function receiving broadcast message from Livox LiDAR. */
|
||||||
SetBroadcastCallback(OnDeviceBroadcast);
|
OptBcast bcastopts;
|
||||||
|
std::function<void(const BroadcastDeviceInfo *info)> cb_bcast(std::bind(OnDeviceBroadcastExtra, bcastopts, _1));
|
||||||
|
SetBroadcastCallback(cb_bcast);
|
||||||
|
|
||||||
/** Set the callback function called when device state change,
|
/** Set the callback function called when device state change,
|
||||||
* which means connection/disconnection and changing of LiDAR state.
|
* which means connection/disconnection and changing of LiDAR state.
|
||||||
*/
|
*/
|
||||||
SetDeviceStateUpdateCallback(OnDeviceInfoChange);
|
std::function<void(const DeviceInfo *, DeviceEvent)> cb_device_state(std::bind(OnDeviceInfoChangeExtra, 1, _1, _2));
|
||||||
|
SetDeviceStateUpdateCallback(cb_device_state);
|
||||||
|
|
||||||
/** Start the device discovering routine. */
|
/** Start the device discovering routine. */
|
||||||
if (!Start()) {
|
if (!Start()) {
|
||||||
@@ -457,4 +476,4 @@ int main(int argc, const char *argv[]) {
|
|||||||
|
|
||||||
/** Uninitialize Livox-SDK. */
|
/** Uninitialize Livox-SDK. */
|
||||||
Uninit();
|
Uninit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,10 @@
|
|||||||
#ifndef LIVOX_SDK_H_
|
#ifndef LIVOX_SDK_H_
|
||||||
#define LIVOX_SDK_H_
|
#define LIVOX_SDK_H_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
#include<functional>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -100,6 +103,8 @@ typedef void (*DeviceStateUpdateCallback)(const DeviceInfo *device, DeviceEvent
|
|||||||
*/
|
*/
|
||||||
void SetDeviceStateUpdateCallback(DeviceStateUpdateCallback cb);
|
void SetDeviceStateUpdateCallback(DeviceStateUpdateCallback cb);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a broadcast code to the connecting list and only devices with broadcast code in this list will be connected. The
|
* Add a broadcast code to the connecting list and only devices with broadcast code in this list will be connected. The
|
||||||
* broadcast code is unique for every device.
|
* broadcast code is unique for every device.
|
||||||
@@ -261,7 +266,7 @@ livox_status SetStaticDynamicIP(uint8_t handle,
|
|||||||
void *client_data);
|
void *client_data);
|
||||||
/**
|
/**
|
||||||
* Set device's static IP mode.
|
* Set device's static IP mode.
|
||||||
* @note Mid40/100 is not supported to set subnet mask and gateway address.
|
* @note Mid40/100 is not supported to set subnet mask and gateway address.
|
||||||
* \ref SetStaticDeviceIpModeRequest's setting: net_mask and gw_addr will not take effect on Mid40/100.
|
* \ref SetStaticDeviceIpModeRequest's setting: net_mask and gw_addr will not take effect on Mid40/100.
|
||||||
* @param handle device handle.
|
* @param handle device handle.
|
||||||
* @param req request sent to device.
|
* @param req request sent to device.
|
||||||
@@ -857,6 +862,11 @@ livox_status LidarSetUtcSyncTime(uint8_t handle,
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SetDeviceStateUpdateCallback(const std::function<void(const DeviceInfo *, DeviceEvent)> &cb);
|
||||||
|
void SetBroadcastCallback(const std::function<void(const BroadcastDeviceInfo *info)> &cb );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // LIVOX_SDK_H_
|
#endif // LIVOX_SDK_H_
|
||||||
|
|||||||
@@ -42,10 +42,18 @@ void SetDeviceStateUpdateCallback(DeviceStateUpdateCallback cb) {
|
|||||||
device_manager().SetDeviceConnectedCallback(cb);
|
device_manager().SetDeviceConnectedCallback(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDeviceStateUpdateCallback(const std::function<void(const DeviceInfo *, DeviceEvent)> &cb){
|
||||||
|
device_manager().SetDeviceConnectedCallback(cb);
|
||||||
|
}
|
||||||
|
|
||||||
void SetBroadcastCallback(DeviceBroadcastCallback cb) {
|
void SetBroadcastCallback(DeviceBroadcastCallback cb) {
|
||||||
device_manager().SetDeviceBroadcastCallback(cb);
|
device_manager().SetDeviceBroadcastCallback(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetBroadcastCallback(const std::function<void(const BroadcastDeviceInfo *info)> &cb ){
|
||||||
|
device_manager().SetDeviceBroadcastCallback(cb);
|
||||||
|
}
|
||||||
|
|
||||||
livox_status AddHubToConnect(const char *broadcast_code, uint8_t *handle) {
|
livox_status AddHubToConnect(const char *broadcast_code, uint8_t *handle) {
|
||||||
bool result = device_manager().AddListeningDevice(broadcast_code, kDeviceModeHub, *handle);
|
bool result = device_manager().AddListeningDevice(broadcast_code, kDeviceModeHub, *handle);
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -317,7 +325,7 @@ livox_status SetStaticDynamicIP(uint8_t handle,
|
|||||||
|
|
||||||
livox_status SetDynamicIp(uint8_t handle, CommonCommandCallback cb, void *client_data) {
|
livox_status SetDynamicIp(uint8_t handle, CommonCommandCallback cb, void *client_data) {
|
||||||
SetDeviceIpExtendModeRequest req;
|
SetDeviceIpExtendModeRequest req;
|
||||||
req.ip_mode = kLidarDynamicIpMode;
|
req.ip_mode = kLidarDynamicIpMode;
|
||||||
return SetDeviceIp(handle, &req, cb, client_data);
|
return SetDeviceIp(handle, &req, cb, client_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +411,7 @@ livox_status LidarGetExtrinsicParameter(uint8_t handle, LidarGetExtrinsicParamet
|
|||||||
}
|
}
|
||||||
|
|
||||||
livox_status LidarRainFogSuppress(uint8_t handle, bool enable, CommonCommandCallback cb, void *client_data) {
|
livox_status LidarRainFogSuppress(uint8_t handle, bool enable, CommonCommandCallback cb, void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeLidar
|
if (device_manager().device_mode() != kDeviceModeLidar
|
||||||
|| !device_manager().IsLidarMid40(handle)) {
|
|| !device_manager().IsLidarMid40(handle)) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
}
|
}
|
||||||
@@ -629,9 +637,9 @@ livox_status HubQuerySlotPowerStatus(HubQuerySlotPowerStatusCallback cb, void *c
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubFanControl(HubFanControlRequest *req,
|
livox_status HubFanControl(HubFanControlRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubFanControlCallback cb,
|
HubFanControlCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -645,9 +653,9 @@ livox_status HubFanControl(HubFanControlRequest *req,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubGetFanState(HubGetFanStateRequest *req,
|
livox_status HubGetFanState(HubGetFanStateRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubGetFanStateCallback cb,
|
HubGetFanStateCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -661,9 +669,9 @@ livox_status HubGetFanState(HubGetFanStateRequest *req,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubSetPointCloudReturnMode(HubSetPointCloudReturnModeRequest *req,
|
livox_status HubSetPointCloudReturnMode(HubSetPointCloudReturnModeRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubSetPointCloudReturnModeCallback cb,
|
HubSetPointCloudReturnModeCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -677,9 +685,9 @@ livox_status HubSetPointCloudReturnMode(HubSetPointCloudReturnModeRequest *req,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubGetPointCloudReturnMode(HubGetPointCloudReturnModeRequest *req,
|
livox_status HubGetPointCloudReturnMode(HubGetPointCloudReturnModeRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubGetPointCloudReturnModeCallback cb,
|
HubGetPointCloudReturnModeCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -693,9 +701,9 @@ livox_status HubGetPointCloudReturnMode(HubGetPointCloudReturnModeRequest *req,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubSetImuPushFrequency(HubSetImuPushFrequencyRequest *req,
|
livox_status HubSetImuPushFrequency(HubSetImuPushFrequencyRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubSetImuPushFrequencyCallback cb,
|
HubSetImuPushFrequencyCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -709,9 +717,9 @@ livox_status HubSetImuPushFrequency(HubSetImuPushFrequencyRequest *req,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
livox_status HubGetImuPushFrequency(HubGetImuPushFrequencyRequest *req,
|
livox_status HubGetImuPushFrequency(HubGetImuPushFrequencyRequest *req,
|
||||||
uint16_t length,
|
uint16_t length,
|
||||||
HubGetImuPushFrequencyCallback cb,
|
HubGetImuPushFrequencyCallback cb,
|
||||||
void *client_data) {
|
void *client_data) {
|
||||||
if (device_manager().device_mode() != kDeviceModeHub) {
|
if (device_manager().device_mode() != kDeviceModeHub) {
|
||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
@@ -756,7 +764,7 @@ livox_status LidarSetRmcSyncTime(uint8_t handle,
|
|||||||
return kStatusNotSupported;
|
return kStatusNotSupported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LidarSetUtcSyncTimeRequest utc_time_req;
|
LidarSetUtcSyncTimeRequest utc_time_req;
|
||||||
if (!ParseRmcTime(rmc, rmc_length, &utc_time_req)) {
|
if (!ParseRmcTime(rmc, rmc_length, &utc_time_req)) {
|
||||||
return kStatusFailure;
|
return kStatusFailure;
|
||||||
|
|||||||
Reference in New Issue
Block a user