Web API: LimeSDRInput settings implementation

This commit is contained in:
f4exb 2017-12-08 15:11:16 +01:00
parent 33bca44fc1
commit 8625a07098
5 changed files with 91 additions and 0 deletions

View File

@ -26,6 +26,7 @@ if (BUILD_DEBIAN)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${LIBLIMESUITESRC}/src
${LIBLIMESUITESRC}/src/ADF4002
@ -41,6 +42,7 @@ else (BUILD_DEBIAN)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${LIMESUITE_INCLUDE_DIR}
)
@ -66,6 +68,7 @@ target_link_libraries(inputlimesdr
limesuite
sdrbase
sdrgui
swagger
limesdrdevice
)
else (BUILD_DEBIAN)
@ -74,6 +77,7 @@ target_link_libraries(inputlimesdr
${LIMESUITE_LIBRARY}
sdrbase
sdrgui
swagger
limesdrdevice
)
endif (BUILD_DEBIAN)

View File

@ -20,6 +20,9 @@
#include <string.h>
#include "lime/LimeSuite.h"
#include "SWGDeviceSettings.h"
#include "SWGLimeSdrInputSettings.h"
#include "device/devicesourceapi.h"
#include "device/devicesinkapi.h"
#include "dsp/dspcommands.h"
@ -1175,3 +1178,68 @@ bool LimeSDRInput::applySettings(const LimeSDRInputSettings& settings, bool forc
return true;
}
int LimeSDRInput::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage __attribute__((unused)))
{
response.setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
response.getLimeSdrInputSettings()->setAntennaPath((int) m_settings.m_antennaPath);
response.getLimeSdrInputSettings()->setCenterFrequency(m_settings.m_centerFrequency);
response.getLimeSdrInputSettings()->setDcBlock(m_settings.m_dcBlock ? 1 : 0);
response.getLimeSdrInputSettings()->setDevSampleRate(m_settings.m_devSampleRate);
response.getLimeSdrInputSettings()->setExtClock(m_settings.m_extClock ? 1 : 0);
response.getLimeSdrInputSettings()->setExtClockFreq(m_settings.m_extClockFreq);
response.getLimeSdrInputSettings()->setGain(m_settings.m_gain);
response.getLimeSdrInputSettings()->setGainMode((int) m_settings.m_gainMode);
response.getLimeSdrInputSettings()->setIqCorrection(m_settings.m_iqCorrection ? 1 : 0);
response.getLimeSdrInputSettings()->setLnaGain(m_settings.m_lnaGain);
response.getLimeSdrInputSettings()->setLog2HardDecim(m_settings.m_log2HardDecim);
response.getLimeSdrInputSettings()->setLog2SoftDecim(m_settings.m_log2SoftDecim);
response.getLimeSdrInputSettings()->setLpfBw(m_settings.m_lpfBW);
response.getLimeSdrInputSettings()->setLpfFirEnable(m_settings.m_lpfFIREnable ? 1 : 0);
response.getLimeSdrInputSettings()->setLpfFirbw(m_settings.m_lpfFIRBW);
response.getLimeSdrInputSettings()->setNcoEnable(m_settings.m_ncoEnable ? 1 : 0);
response.getLimeSdrInputSettings()->setNcoFrequency(m_settings.m_ncoFrequency);
response.getLimeSdrInputSettings()->setPgaGain(m_settings.m_pgaGain);
response.getLimeSdrInputSettings()->setTiaGain(m_settings.m_tiaGain);
return 200;
}
int LimeSDRInput::webapiSettingsPutPatch(
bool force,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage __attribute__((unused)))
{
LimeSDRInputSettings settings;
settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) response.getLimeSdrInputSettings()->getAntennaPath();
settings.m_centerFrequency = response.getLimeSdrInputSettings()->getCenterFrequency();
settings.m_dcBlock = response.getLimeSdrInputSettings()->getDcBlock() != 0;
settings.m_devSampleRate = response.getLimeSdrInputSettings()->getDevSampleRate();
settings.m_extClock = response.getLimeSdrInputSettings()->getExtClock() != 0;
settings.m_extClockFreq = response.getLimeSdrInputSettings()->getExtClockFreq();
settings.m_gain = response.getLimeSdrInputSettings()->getGain();
settings.m_gainMode = (LimeSDRInputSettings::GainMode) response.getLimeSdrInputSettings()->getGainMode();
settings.m_iqCorrection = response.getLimeSdrInputSettings()->getIqCorrection() != 0;
settings.m_lnaGain = response.getLimeSdrInputSettings()->getLnaGain();
settings.m_log2HardDecim = response.getLimeSdrInputSettings()->getLog2HardDecim();
settings.m_log2SoftDecim = response.getLimeSdrInputSettings()->getLog2SoftDecim();
settings.m_lpfBW = response.getLimeSdrInputSettings()->getLpfBw();
settings.m_lpfFIREnable = response.getLimeSdrInputSettings()->getLpfFirEnable() != 0;
settings.m_lpfFIRBW = response.getLimeSdrInputSettings()->getLpfFirbw();
settings.m_ncoEnable = response.getLimeSdrInputSettings()->getNcoEnable() != 0;
settings.m_ncoFrequency = response.getLimeSdrInputSettings()->getNcoFrequency();
settings.m_pgaGain = response.getLimeSdrInputSettings()->getPgaGain();
settings.m_tiaGain = response.getLimeSdrInputSettings()->getTiaGain();
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureLimeSDR *msgToGUI = MsgConfigureLimeSDR::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
return 200;
}

View File

@ -198,6 +198,15 @@ public:
virtual bool handleMessage(const Message& message);
virtual int webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
std::size_t getChannelIndex();
void getLORange(float& minF, float& maxF, float& stepF) const;
void getSRRange(float& minF, float& maxF, float& stepF) const;

View File

@ -25,6 +25,7 @@ CONFIG(MINGW64):LIBLIMESUITESRC = "D:\softs\LimeSuite"
INCLUDEPATH += $$PWD
INCLUDEPATH += ../../../sdrbase
INCLUDEPATH += ../../../sdrgui
INCLUDEPATH += ../../../swagger/sdrangel/code/qt5/client
INCLUDEPATH += ../../../devices
INCLUDEPATH += ../../../liblimesuite/srcmw
INCLUDEPATH += $$LIBLIMESUITESRC/src
@ -57,6 +58,7 @@ FORMS += limesdrinputgui.ui
LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui
LIBS += -L../../../swagger/$${build_subdir} -lswagger
LIBS += -L../../../liblimesuite/$${build_subdir} -lliblimesuite
LIBS += -L../../../devices/$${build_subdir} -ldevices

View File

@ -239,6 +239,14 @@ void LimeSDRInputGUI::handleInputMessages()
delete message;
}
else if (LimeSDRInput::MsgConfigureLimeSDR::match(*message))
{
const LimeSDRInput::MsgConfigureLimeSDR& cfg = (LimeSDRInput::MsgConfigureLimeSDR&) *message;
m_settings = cfg.getSettings();
displaySettings();
delete message;
}
else
{
if (handleMessage(*message)) {