Web API: /sdrangel/deviceset/{deviceSetIndex}/device/settings PUT, PATCH with all settings parameters optional

pull/127/head
f4exb 2017-12-27 01:46:33 +01:00
rodzic 85f9be7c64
commit ccffb5101d
15 zmienionych plików z 236 dodań i 100 usunięć

Wyświetl plik

@ -1061,41 +1061,57 @@ int LimeSDROutput::webapiSettingsGet(
QString& errorMessage __attribute__((unused)))
{
response.setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings());
response.getLimeSdrOutputSettings()->setAntennaPath((int) m_settings.m_antennaPath);
response.getLimeSdrOutputSettings()->setCenterFrequency(m_settings.m_centerFrequency);
response.getLimeSdrOutputSettings()->setDevSampleRate(m_settings.m_devSampleRate);
response.getLimeSdrOutputSettings()->setExtClock(m_settings.m_extClock ? 1 : 0);
response.getLimeSdrOutputSettings()->setExtClockFreq(m_settings.m_extClockFreq);
response.getLimeSdrOutputSettings()->setGain(m_settings.m_gain);
response.getLimeSdrOutputSettings()->setLog2HardInterp(m_settings.m_log2HardInterp);
response.getLimeSdrOutputSettings()->setLog2SoftInterp(m_settings.m_log2SoftInterp);
response.getLimeSdrOutputSettings()->setLpfBw(m_settings.m_lpfBW);
response.getLimeSdrOutputSettings()->setLpfFirEnable(m_settings.m_lpfFIREnable ? 1 : 0);
response.getLimeSdrOutputSettings()->setLpfFirbw(m_settings.m_lpfFIRBW);
response.getLimeSdrOutputSettings()->setNcoEnable(m_settings.m_ncoEnable ? 1 : 0);
response.getLimeSdrOutputSettings()->setNcoFrequency(m_settings.m_ncoFrequency);
webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int LimeSDROutput::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage __attribute__((unused)))
{
LimeSDROutputSettings settings;
settings.m_antennaPath = (LimeSDROutputSettings::PathRFE) response.getLimeSdrOutputSettings()->getAntennaPath();
settings.m_centerFrequency = response.getLimeSdrOutputSettings()->getCenterFrequency();
settings.m_devSampleRate = response.getLimeSdrOutputSettings()->getDevSampleRate();
settings.m_extClock = response.getLimeSdrOutputSettings()->getExtClock() != 0;
settings.m_extClockFreq = response.getLimeSdrOutputSettings()->getExtClockFreq();
settings.m_gain = response.getLimeSdrOutputSettings()->getGain();
settings.m_log2HardInterp = response.getLimeSdrOutputSettings()->getLog2HardInterp();
settings.m_log2SoftInterp = response.getLimeSdrOutputSettings()->getLog2SoftInterp();
settings.m_lpfBW = response.getLimeSdrOutputSettings()->getLpfBw();
settings.m_lpfFIREnable = response.getLimeSdrOutputSettings()->getLpfFirEnable() != 0;
settings.m_lpfFIRBW = response.getLimeSdrOutputSettings()->getLpfFirbw();
settings.m_ncoEnable = response.getLimeSdrOutputSettings()->getNcoEnable() != 0;
settings.m_ncoFrequency = response.getLimeSdrOutputSettings()->getNcoFrequency();
LimeSDROutputSettings settings = m_settings;
if (deviceSettingsKeys.contains("antennaPath")) {
settings.m_antennaPath = (LimeSDROutputSettings::PathRFE) response.getLimeSdrOutputSettings()->getAntennaPath();
}
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getLimeSdrOutputSettings()->getCenterFrequency();
}
if (deviceSettingsKeys.contains("devSampleRate")) {
settings.m_devSampleRate = response.getLimeSdrOutputSettings()->getDevSampleRate();
}
if (deviceSettingsKeys.contains("extClock")) {
settings.m_extClock = response.getLimeSdrOutputSettings()->getExtClock() != 0;
}
if (deviceSettingsKeys.contains("extClockFreq")) {
settings.m_extClockFreq = response.getLimeSdrOutputSettings()->getExtClockFreq();
}
if (deviceSettingsKeys.contains("gain")) {
settings.m_gain = response.getLimeSdrOutputSettings()->getGain();
}
if (deviceSettingsKeys.contains("log2HardInterp")) {
settings.m_log2HardInterp = response.getLimeSdrOutputSettings()->getLog2HardInterp();
}
if (deviceSettingsKeys.contains("log2SoftInterp")) {
settings.m_log2SoftInterp = response.getLimeSdrOutputSettings()->getLog2SoftInterp();
}
if (deviceSettingsKeys.contains("lpfBW")) {
settings.m_lpfBW = response.getLimeSdrOutputSettings()->getLpfBw();
}
if (deviceSettingsKeys.contains("lpfFIREnable")) {
settings.m_lpfFIREnable = response.getLimeSdrOutputSettings()->getLpfFirEnable() != 0;
}
if (deviceSettingsKeys.contains("lpfFIRBW")) {
settings.m_lpfFIRBW = response.getLimeSdrOutputSettings()->getLpfFirbw();
}
if (deviceSettingsKeys.contains("ncoEnable")) {
settings.m_ncoEnable = response.getLimeSdrOutputSettings()->getNcoEnable() != 0;
}
if (deviceSettingsKeys.contains("ncoFrequency")) {
settings.m_ncoFrequency = response.getLimeSdrOutputSettings()->getNcoFrequency();
}
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force);
m_inputMessageQueue.push(msg);
@ -1106,9 +1122,27 @@ int LimeSDROutput::webapiSettingsPutPatch(
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void LimeSDROutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDROutputSettings& settings)
{
response.getLimeSdrOutputSettings()->setAntennaPath((int) settings.m_antennaPath);
response.getLimeSdrOutputSettings()->setCenterFrequency(settings.m_centerFrequency);
response.getLimeSdrOutputSettings()->setDevSampleRate(settings.m_devSampleRate);
response.getLimeSdrOutputSettings()->setExtClock(settings.m_extClock ? 1 : 0);
response.getLimeSdrOutputSettings()->setExtClockFreq(settings.m_extClockFreq);
response.getLimeSdrOutputSettings()->setGain(settings.m_gain);
response.getLimeSdrOutputSettings()->setLog2HardInterp(settings.m_log2HardInterp);
response.getLimeSdrOutputSettings()->setLog2SoftInterp(settings.m_log2SoftInterp);
response.getLimeSdrOutputSettings()->setLpfBw(settings.m_lpfBW);
response.getLimeSdrOutputSettings()->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
response.getLimeSdrOutputSettings()->setLpfFirbw(settings.m_lpfFIRBW);
response.getLimeSdrOutputSettings()->setNcoEnable(settings.m_ncoEnable ? 1 : 0);
response.getLimeSdrOutputSettings()->setNcoFrequency(settings.m_ncoFrequency);
}
int LimeSDROutput::webapiRunGet(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))

Wyświetl plik

@ -205,6 +205,7 @@ public:
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
@ -244,6 +245,7 @@ private:
void suspendTxBuddies();
void resumeTxBuddies();
bool applySettings(const LimeSDROutputSettings& settings, bool force = false, bool forceNCOFrequency = false);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDROutputSettings& settings);
};
#endif /* PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_ */

Wyświetl plik

@ -1214,53 +1214,75 @@ int LimeSDRInput::webapiSettingsGet(
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);
webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int LimeSDRInput::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
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();
LimeSDRInputSettings settings = m_settings;
if (deviceSettingsKeys.contains("antennaPath")) {
settings.m_antennaPath = (LimeSDRInputSettings::PathRFE) response.getLimeSdrInputSettings()->getAntennaPath();
}
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getLimeSdrInputSettings()->getCenterFrequency();
}
if (deviceSettingsKeys.contains("dcBlock")) {
settings.m_dcBlock = response.getLimeSdrInputSettings()->getDcBlock() != 0;
}
if (deviceSettingsKeys.contains("devSampleRate")) {
settings.m_devSampleRate = response.getLimeSdrInputSettings()->getDevSampleRate();
}
if (deviceSettingsKeys.contains("extClock")) {
settings.m_extClock = response.getLimeSdrInputSettings()->getExtClock() != 0;
}
if (deviceSettingsKeys.contains("extClockFreq")) {
settings.m_extClockFreq = response.getLimeSdrInputSettings()->getExtClockFreq();
}
if (deviceSettingsKeys.contains("gain")) {
settings.m_gain = response.getLimeSdrInputSettings()->getGain();
}
if (deviceSettingsKeys.contains("gainMode")) {
settings.m_gainMode = (LimeSDRInputSettings::GainMode) response.getLimeSdrInputSettings()->getGainMode();
}
if (deviceSettingsKeys.contains("iqCorrection")) {
settings.m_iqCorrection = response.getLimeSdrInputSettings()->getIqCorrection() != 0;
}
if (deviceSettingsKeys.contains("lnaGain")) {
settings.m_lnaGain = response.getLimeSdrInputSettings()->getLnaGain();
}
if (deviceSettingsKeys.contains("log2HardDecim")) {
settings.m_log2HardDecim = response.getLimeSdrInputSettings()->getLog2HardDecim();
}
if (deviceSettingsKeys.contains("log2SoftDecim")) {
settings.m_log2SoftDecim = response.getLimeSdrInputSettings()->getLog2SoftDecim();
}
if (deviceSettingsKeys.contains("lpfBW")) {
settings.m_lpfBW = response.getLimeSdrInputSettings()->getLpfBw();
}
if (deviceSettingsKeys.contains("lpfFIREnable")) {
settings.m_lpfFIREnable = response.getLimeSdrInputSettings()->getLpfFirEnable() != 0;
}
if (deviceSettingsKeys.contains("lpfFIRBW")) {
settings.m_lpfFIRBW = response.getLimeSdrInputSettings()->getLpfFirbw();
}
if (deviceSettingsKeys.contains("ncoEnable")) {
settings.m_ncoEnable = response.getLimeSdrInputSettings()->getNcoEnable() != 0;
}
if (deviceSettingsKeys.contains("ncoFrequency")) {
settings.m_ncoFrequency = response.getLimeSdrInputSettings()->getNcoFrequency();
}
if (deviceSettingsKeys.contains("pgaGain")) {
settings.m_pgaGain = response.getLimeSdrInputSettings()->getPgaGain();
}
if (deviceSettingsKeys.contains("tiaGain")) {
settings.m_tiaGain = response.getLimeSdrInputSettings()->getTiaGain();
}
MsgConfigureLimeSDR *msg = MsgConfigureLimeSDR::create(settings, force);
m_inputMessageQueue.push(msg);
@ -1271,9 +1293,33 @@ int LimeSDRInput::webapiSettingsPutPatch(
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void LimeSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDRInputSettings& settings)
{
response.getLimeSdrInputSettings()->setAntennaPath((int) settings.m_antennaPath);
response.getLimeSdrInputSettings()->setCenterFrequency(settings.m_centerFrequency);
response.getLimeSdrInputSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
response.getLimeSdrInputSettings()->setDevSampleRate(settings.m_devSampleRate);
response.getLimeSdrInputSettings()->setExtClock(settings.m_extClock ? 1 : 0);
response.getLimeSdrInputSettings()->setExtClockFreq(settings.m_extClockFreq);
response.getLimeSdrInputSettings()->setGain(settings.m_gain);
response.getLimeSdrInputSettings()->setGainMode((int) settings.m_gainMode);
response.getLimeSdrInputSettings()->setIqCorrection(settings.m_iqCorrection ? 1 : 0);
response.getLimeSdrInputSettings()->setLnaGain(settings.m_lnaGain);
response.getLimeSdrInputSettings()->setLog2HardDecim(settings.m_log2HardDecim);
response.getLimeSdrInputSettings()->setLog2SoftDecim(settings.m_log2SoftDecim);
response.getLimeSdrInputSettings()->setLpfBw(settings.m_lpfBW);
response.getLimeSdrInputSettings()->setLpfFirEnable(settings.m_lpfFIREnable ? 1 : 0);
response.getLimeSdrInputSettings()->setLpfFirbw(settings.m_lpfFIRBW);
response.getLimeSdrInputSettings()->setNcoEnable(settings.m_ncoEnable ? 1 : 0);
response.getLimeSdrInputSettings()->setNcoFrequency(settings.m_ncoFrequency);
response.getLimeSdrInputSettings()->setPgaGain(settings.m_pgaGain);
response.getLimeSdrInputSettings()->setTiaGain(settings.m_tiaGain);
}
int LimeSDRInput::webapiRunGet(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))

Wyświetl plik

@ -225,6 +225,7 @@ public:
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
@ -264,6 +265,7 @@ private:
void suspendTxBuddies();
void resumeTxBuddies();
bool applySettings(const LimeSDRInputSettings& settings, bool force = false, bool forceNCOFrequency = false);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const LimeSDRInputSettings& settings);
};
#endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUT_H_ */

Wyświetl plik

@ -495,41 +495,57 @@ int RTLSDRInput::webapiSettingsGet(
QString& errorMessage __attribute__((unused)))
{
response.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
response.getRtlSdrSettings()->setAgc(m_settings.m_agc ? 1 : 0);
response.getRtlSdrSettings()->setCenterFrequency(m_settings.m_centerFrequency);
response.getRtlSdrSettings()->setDcBlock(m_settings.m_dcBlock ? 1 : 0);
response.getRtlSdrSettings()->setDevSampleRate(m_settings.m_devSampleRate);
response.getRtlSdrSettings()->setFcPos((int) m_settings.m_fcPos);
response.getRtlSdrSettings()->setGain(m_settings.m_gain);
response.getRtlSdrSettings()->setIqImbalance(m_settings.m_iqImbalance ? 1 : 0);
response.getRtlSdrSettings()->setLoPpmCorrection(m_settings.m_loPpmCorrection);
response.getRtlSdrSettings()->setLog2Decim(m_settings.m_log2Decim);
response.getRtlSdrSettings()->setLowSampleRate(m_settings.m_lowSampleRate ? 1 : 0);
response.getRtlSdrSettings()->setNoModMode(m_settings.m_noModMode ? 1 : 0);
response.getRtlSdrSettings()->setTransverterDeltaFrequency(m_settings.m_transverterDeltaFrequency);
response.getRtlSdrSettings()->setTransverterMode(m_settings.m_transverterMode ? 1 : 0);
webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int RTLSDRInput::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage __attribute__((unused)))
{
RTLSDRSettings settings;
settings.m_agc = response.getRtlSdrSettings()->getAgc() != 0;
settings.m_centerFrequency = response.getRtlSdrSettings()->getCenterFrequency();
settings.m_dcBlock = response.getRtlSdrSettings()->getDcBlock() != 0;
settings.m_devSampleRate = response.getRtlSdrSettings()->getDevSampleRate();
settings.m_fcPos = (RTLSDRSettings::fcPos_t) response.getRtlSdrSettings()->getFcPos();
settings.m_gain = response.getRtlSdrSettings()->getGain();
settings.m_iqImbalance = response.getRtlSdrSettings()->getIqImbalance() != 0;
settings.m_loPpmCorrection = response.getRtlSdrSettings()->getLoPpmCorrection();
settings.m_log2Decim = response.getRtlSdrSettings()->getLog2Decim();
settings.m_lowSampleRate = response.getRtlSdrSettings()->getLowSampleRate() != 0;
settings.m_noModMode = response.getRtlSdrSettings()->getNoModMode() != 0;
settings.m_transverterDeltaFrequency = response.getRtlSdrSettings()->getTransverterDeltaFrequency();
settings.m_transverterMode = response.getRtlSdrSettings()->getTransverterMode() != 0;
RTLSDRSettings settings = m_settings;
if (deviceSettingsKeys.contains("agc")) {
settings.m_agc = response.getRtlSdrSettings()->getAgc() != 0;
}
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getRtlSdrSettings()->getCenterFrequency();
}
if (deviceSettingsKeys.contains("dcBlock")) {
settings.m_dcBlock = response.getRtlSdrSettings()->getDcBlock() != 0;
}
if (deviceSettingsKeys.contains("devSampleRate")) {
settings.m_devSampleRate = response.getRtlSdrSettings()->getDevSampleRate();
}
if (deviceSettingsKeys.contains("fcPos")) {
settings.m_fcPos = (RTLSDRSettings::fcPos_t) response.getRtlSdrSettings()->getFcPos();
}
if (deviceSettingsKeys.contains("gain")) {
settings.m_gain = response.getRtlSdrSettings()->getGain();
}
if (deviceSettingsKeys.contains("iqImbalance")) {
settings.m_iqImbalance = response.getRtlSdrSettings()->getIqImbalance() != 0;
}
if (deviceSettingsKeys.contains("loPpmCorrection")) {
settings.m_loPpmCorrection = response.getRtlSdrSettings()->getLoPpmCorrection();
}
if (deviceSettingsKeys.contains("log2Decim")) {
settings.m_log2Decim = response.getRtlSdrSettings()->getLog2Decim();
}
if (deviceSettingsKeys.contains("lowSampleRate")) {
settings.m_lowSampleRate = response.getRtlSdrSettings()->getLowSampleRate() != 0;
}
if (deviceSettingsKeys.contains("noModMode")) {
settings.m_noModMode = response.getRtlSdrSettings()->getNoModMode() != 0;
}
if (deviceSettingsKeys.contains("transverterDeltaFrequency")) {
settings.m_transverterDeltaFrequency = response.getRtlSdrSettings()->getTransverterDeltaFrequency();
}
if (deviceSettingsKeys.contains("transverterMode")) {
settings.m_transverterMode = response.getRtlSdrSettings()->getTransverterMode() != 0;
}
MsgConfigureRTLSDR *msg = MsgConfigureRTLSDR::create(settings, force);
m_inputMessageQueue.push(msg);
@ -540,9 +556,27 @@ int RTLSDRInput::webapiSettingsPutPatch(
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void RTLSDRInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RTLSDRSettings& settings)
{
response.getRtlSdrSettings()->setAgc(settings.m_agc ? 1 : 0);
response.getRtlSdrSettings()->setCenterFrequency(settings.m_centerFrequency);
response.getRtlSdrSettings()->setDcBlock(settings.m_dcBlock ? 1 : 0);
response.getRtlSdrSettings()->setDevSampleRate(settings.m_devSampleRate);
response.getRtlSdrSettings()->setFcPos((int) settings.m_fcPos);
response.getRtlSdrSettings()->setGain(settings.m_gain);
response.getRtlSdrSettings()->setIqImbalance(settings.m_iqImbalance ? 1 : 0);
response.getRtlSdrSettings()->setLoPpmCorrection(settings.m_loPpmCorrection);
response.getRtlSdrSettings()->setLog2Decim(settings.m_log2Decim);
response.getRtlSdrSettings()->setLowSampleRate(settings.m_lowSampleRate ? 1 : 0);
response.getRtlSdrSettings()->setNoModMode(settings.m_noModMode ? 1 : 0);
response.getRtlSdrSettings()->setTransverterDeltaFrequency(settings.m_transverterDeltaFrequency);
response.getRtlSdrSettings()->setTransverterMode(settings.m_transverterMode ? 1 : 0);
}
int RTLSDRInput::webapiRunGet(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))

Wyświetl plik

@ -112,6 +112,7 @@ public:
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
@ -150,6 +151,7 @@ private:
bool openDevice();
void closeDevice();
bool applySettings(const RTLSDRSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RTLSDRSettings& settings);
};
#endif // INCLUDE_RTLSDRINPUT_H

Wyświetl plik

@ -55,6 +55,7 @@ public:
virtual int webapiSettingsPutPatch(
bool force __attribute__((unused)), //!< true to force settings = put
const QStringList& deviceSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }

Wyświetl plik

@ -55,6 +55,7 @@ public:
virtual int webapiSettingsPutPatch(
bool force __attribute__((unused)), //!< true to force settings = put
const QStringList& deviceSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }

Wyświetl plik

@ -384,6 +384,7 @@ public:
virtual int devicesetDeviceSettingsPutPatch(
int deviceSetIndex __attribute__((unused)),
bool force __attribute__((unused)), //!< true to force settings = put else patch
const QStringList& channelSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error)
{

Wyświetl plik

@ -892,12 +892,14 @@ void WebAPIRequestMapper::devicesetDeviceSettingsService(const std::string& inde
{
SWGSDRangel::SWGDeviceSettings normalResponse;
resetDeviceSettings(normalResponse);
QStringList deviceSettingsKeys;
if (validateDeviceSettings(normalResponse, jsonObject))
if (validateDeviceSettings(normalResponse, jsonObject, deviceSettingsKeys))
{
int status = m_adapter->devicesetDeviceSettingsPutPatch(
deviceSetIndex,
(request.getMethod() == "PUT"), // force settings on PUT
deviceSettingsKeys,
normalResponse,
errorResponse);
response.setStatus(status);
@ -1351,7 +1353,10 @@ bool WebAPIRequestMapper::validateDeviceListItem(SWGSDRangel::SWGDeviceListItem&
return identified;
}
bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject)
bool WebAPIRequestMapper::validateDeviceSettings(
SWGSDRangel::SWGDeviceSettings& deviceSettings,
QJsonObject& jsonObject,
QStringList& deviceSettingsKeys)
{
if (jsonObject.contains("tx")) {
deviceSettings.setTx(jsonObject["tx"].toInt());
@ -1372,6 +1377,7 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
if (jsonObject.contains("fileSourceSettings") && jsonObject["fileSourceSettings"].isObject())
{
QJsonObject fileSourceSettingsJsonObject = jsonObject["fileSourceSettings"].toObject();
deviceSettingsKeys = fileSourceSettingsJsonObject.keys();
deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
deviceSettings.getFileSourceSettings()->fromJsonObject(fileSourceSettingsJsonObject);
return true;
@ -1386,6 +1392,7 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
if (jsonObject.contains("rtlSdrSettings") && jsonObject["rtlSdrSettings"].isObject())
{
QJsonObject rtlSdrSettingsJsonObject = jsonObject["rtlSdrSettings"].toObject();
deviceSettingsKeys = rtlSdrSettingsJsonObject.keys();
deviceSettings.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
deviceSettings.getRtlSdrSettings()->fromJsonObject(rtlSdrSettingsJsonObject);
return true;
@ -1400,6 +1407,7 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
if (jsonObject.contains("limeSdrInputSettings") && jsonObject["limeSdrInputSettings"].isObject())
{
QJsonObject limeSdrInputSettingsJsonObject = jsonObject["limeSdrInputSettings"].toObject();
deviceSettingsKeys = limeSdrInputSettingsJsonObject.keys();
deviceSettings.setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
deviceSettings.getLimeSdrInputSettings()->fromJsonObject(limeSdrInputSettingsJsonObject);
return true;
@ -1414,6 +1422,7 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
if (jsonObject.contains("limeSdrOutputSettings") && jsonObject["limeSdrOutputSettings"].isObject())
{
QJsonObject limeSdrOutputSettingsJsonObject = jsonObject["limeSdrOutputSettings"].toObject();
deviceSettingsKeys = limeSdrOutputSettingsJsonObject.keys();
deviceSettings.setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings());
deviceSettings.getLimeSdrOutputSettings()->fromJsonObject(limeSdrOutputSettingsJsonObject);
return true;

Wyświetl plik

@ -70,7 +70,7 @@ private:
bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier);
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject);
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys);
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
void appendSettingsSubKeys(

Wyświetl plik

@ -737,6 +737,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsGet(
int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
int deviceSetIndex,
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{
@ -759,7 +760,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
else
{
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsPutPatch(force, response, *error.getMessage());
return source->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else if (deviceSet->m_deviceSinkEngine) // Tx
@ -777,7 +778,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
else
{
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsPutPatch(force, response, *error.getMessage());
return sink->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else

Wyświetl plik

@ -128,6 +128,7 @@ public:
virtual int devicesetDeviceSettingsPutPatch(
int deviceSetIndex,
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error);

Wyświetl plik

@ -866,6 +866,7 @@ int WebAPIAdapterSrv::devicesetDeviceSettingsGet(
int WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch(
int deviceSetIndex,
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{
@ -888,7 +889,7 @@ int WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch(
else
{
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsPutPatch(force, response, *error.getMessage());
return source->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else if (deviceSet->m_deviceSinkEngine) // Tx
@ -906,7 +907,7 @@ int WebAPIAdapterSrv::devicesetDeviceSettingsPutPatch(
else
{
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsPutPatch(force, response, *error.getMessage());
return sink->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else

Wyświetl plik

@ -143,6 +143,7 @@ public:
virtual int devicesetDeviceSettingsPutPatch(
int deviceSetIndex,
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error);