libs: Add smohook for getting cmdline opts
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include <opts.h>
|
#include <opts.h>
|
||||||
#include <componentThread.h>
|
#include <componentThread.h>
|
||||||
#include "broadcastListener.h"
|
#include "broadcastListener.h"
|
||||||
|
#include "core.h"
|
||||||
|
|
||||||
namespace livoxProto1 {
|
namespace livoxProto1 {
|
||||||
namespace comms {
|
namespace comms {
|
||||||
@@ -96,7 +97,7 @@ void BroadcastListener::broadcastMsgInd(
|
|||||||
if (deviceExists(broadcastCode))
|
if (deviceExists(broadcastCode))
|
||||||
{
|
{
|
||||||
// Device already exists, just log the update
|
// Device already exists, just log the update
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__
|
std::cout << __func__
|
||||||
<< ": Received broadcast from known device: "
|
<< ": Received broadcast from known device: "
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ public:
|
|||||||
|
|
||||||
// Connection successful, add device to collection
|
// Connection successful, add device to collection
|
||||||
context->deviceManager.devices.push_back(context->pendingDevice);
|
context->deviceManager.devices.push_back(context->pendingDevice);
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Successfully connected and added device "
|
std::cout << __func__ << ": Successfully connected and added device "
|
||||||
<< context->pendingDevice->discoveredDevice.deviceIdentifier
|
<< context->pendingDevice->discoveredDevice.deviceIdentifier
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public:
|
|||||||
// Fail early - if handshake failed, try next method
|
// Fail early - if handshake failed, try next method
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Trying to connect to device by "
|
std::cout << __func__ << ": Trying to connect to device by "
|
||||||
<< "identifier" << "\n";
|
<< "identifier" << "\n";
|
||||||
@@ -222,7 +222,7 @@ void Device::connectReq(smo::Callback<Device::connectReqCbFn> callback)
|
|||||||
auto request = std::make_shared<ConnectReq>(*this, std::move(callback));
|
auto request = std::make_shared<ConnectReq>(*this, std::move(callback));
|
||||||
|
|
||||||
// Try connecting to known device first
|
// Try connecting to known device first
|
||||||
if (OptionParser::getOptions().verbose) {
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose) {
|
||||||
std::cout << __func__ << ": Trying to connect to known device" << "\n";
|
std::cout << __func__ << ": Trying to connect to known device" << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ void Device::connectToKnownDeviceReq(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Detected SMO listening IP for known device "
|
std::cout << __func__ << ": Detected SMO listening IP for known device "
|
||||||
<< request->device.discoveredDevice.deviceIdentifier
|
<< request->device.discoveredDevice.deviceIdentifier
|
||||||
@@ -402,7 +402,7 @@ void Device::connectByDeviceIdentifierReq(
|
|||||||
// For heuristic construction, always use the provided smoIp.
|
// For heuristic construction, always use the provided smoIp.
|
||||||
request->device.detectedSmoListeningIp = request->device.smoIp;
|
request->device.detectedSmoListeningIp = request->device.smoIp;
|
||||||
|
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": About to try to connect to device by "
|
std::cout << __func__ << ": About to try to connect to device by "
|
||||||
<< "identifier (" << discoveredDevice.deviceIdentifier << ")"
|
<< "identifier (" << discoveredDevice.deviceIdentifier << ")"
|
||||||
@@ -720,7 +720,7 @@ private:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Handshake successful with "
|
std::cout << __func__ << ": Handshake successful with "
|
||||||
<< deviceIP << "("
|
<< deviceIP << "("
|
||||||
@@ -1512,7 +1512,7 @@ protected:
|
|||||||
response->command.cmd_id == 0x04 &&
|
response->command.cmd_id == 0x04 &&
|
||||||
response->ret_code == 0x00))
|
response->ret_code == 0x00))
|
||||||
{
|
{
|
||||||
if (OptionParser::getOptions().verbose)
|
if (getProtoState().smoCallbacks.OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Failed to en/disable pcloud data "
|
std::cout << __func__ << ": Failed to en/disable pcloud data "
|
||||||
"for device "
|
"for device "
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
#include <user/deviceAttachmentSpec.h>
|
#include <user/deviceAttachmentSpec.h>
|
||||||
#include <callback.h>
|
#include <callback.h>
|
||||||
|
|
||||||
|
class OptionParser;
|
||||||
|
|
||||||
namespace smo {
|
namespace smo {
|
||||||
|
|
||||||
class ComponentThread;
|
class ComponentThread;
|
||||||
@@ -81,6 +83,15 @@ struct SmoCallbacks
|
|||||||
* equivalent to calling ComponentThread::getSelf().
|
* equivalent to calling ComponentThread::getSelf().
|
||||||
*/
|
*/
|
||||||
std::shared_ptr<ComponentThread> (*ComponentThread_getSelf)(void);
|
std::shared_ptr<ComponentThread> (*ComponentThread_getSelf)(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the OptionParser singleton instance
|
||||||
|
* @return Reference to the OptionParser singleton
|
||||||
|
*
|
||||||
|
* This function provides access to the OptionParser singleton instance,
|
||||||
|
* equivalent to calling OptionParser::getOptions().
|
||||||
|
*/
|
||||||
|
OptionParser& (*OptionParser_getOptions)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Sal_Mgmt_LibOps
|
struct Sal_Mgmt_LibOps
|
||||||
|
|||||||
@@ -79,13 +79,20 @@ static std::shared_ptr<ComponentThread> ComponentThread_getSelf()
|
|||||||
return ComponentThread::getSelf();
|
return ComponentThread::getSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Local static function to wrap OptionParser::getOptions for SmoCallbacks */
|
||||||
|
static OptionParser& OptionParser_getOptions()
|
||||||
|
{
|
||||||
|
return OptionParser::getOptions();
|
||||||
|
}
|
||||||
|
|
||||||
/* Hooks to be provided to stimBuffApiLibs, enabling them to call into Salmanoff
|
/* Hooks to be provided to stimBuffApiLibs, enabling them to call into Salmanoff
|
||||||
* code.
|
* code.
|
||||||
*/
|
*/
|
||||||
static SmoCallbacks smoCallbacks =
|
static SmoCallbacks smoCallbacks =
|
||||||
{
|
{
|
||||||
.searchForLibInSmoSearchPaths = searchForLibInSmoSearchPaths,
|
.searchForLibInSmoSearchPaths = searchForLibInSmoSearchPaths,
|
||||||
.ComponentThread_getSelf = ComponentThread_getSelf
|
.ComponentThread_getSelf = ComponentThread_getSelf,
|
||||||
|
.OptionParser_getOptions = OptionParser_getOptions
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Static file-scope threading model object for senseApi libraries */
|
/* Static file-scope threading model object for senseApi libraries */
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ void IoUringAssemblyEngine::stop(bool doAcquireLock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sawCancelCqe && OptionParser::getOptions().verbose) {
|
if (!sawCancelCqe && smoHooksPtr->OptionParser_getOptions().verbose) {
|
||||||
std::cerr << __func__ << ": no CQE seen for cancel operation\n";
|
std::cerr << __func__ << ": no CQE seen for cancel operation\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,7 +483,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OptionParser::getOptions().verbose)
|
if (smoHooksPtr->OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cerr << __func__ << ": Invalid state: nSucceeded ("
|
std::cerr << __func__ << ": Invalid state: nSucceeded ("
|
||||||
<< context->loop.nSucceeded.load()
|
<< context->loop.nSucceeded.load()
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public:
|
|||||||
// Stash device pointer until after getReturnMode succeeds
|
// Stash device pointer until after getReturnMode succeeds
|
||||||
context->deviceTmp = dev;
|
context->deviceTmp = dev;
|
||||||
|
|
||||||
if (1 || OptionParser::getOptions().verbose)
|
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Successfully attached/found Livox "
|
std::cout << __func__ << ": Successfully attached/found Livox "
|
||||||
"device: " << context->spec->deviceSelector << " (ID: "
|
"device: " << context->spec->deviceSelector << " (ID: "
|
||||||
@@ -205,7 +205,7 @@ public:
|
|||||||
|
|
||||||
pcloudStimBuff->start();
|
pcloudStimBuff->start();
|
||||||
|
|
||||||
if (1 || OptionParser::getOptions().verbose)
|
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Got return mode (" << (int)mode
|
std::cout << __func__ << ": Got return mode (" << (int)mode
|
||||||
<< ") for device: " << context->spec->deviceSelector
|
<< ") for device: " << context->spec->deviceSelector
|
||||||
@@ -264,7 +264,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 || OptionParser::getOptions().verbose)
|
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Enabled pcloud data for device: "
|
std::cout << __func__ << ": Enabled pcloud data for device: "
|
||||||
<< context->spec->deviceSelector << std::endl;
|
<< context->spec->deviceSelector << std::endl;
|
||||||
@@ -372,7 +372,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 || OptionParser::getOptions().verbose)
|
if (1 || smoHooksPtr->OptionParser_getOptions().verbose)
|
||||||
{
|
{
|
||||||
std::cout << __func__ << ": Successfully detached pcloud stimbuff "
|
std::cout << __func__ << ": Successfully detached pcloud stimbuff "
|
||||||
"for device " << context->spec->deviceSelector
|
"for device " << context->spec->deviceSelector
|
||||||
|
|||||||
Reference in New Issue
Block a user