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