1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-01 16:38:06 -04:00

REST API: config: GET (11). Support of the rest of devices

This commit is contained in:
f4exb
2019-08-04 20:24:44 +02:00
parent 16e9684118
commit a078239685
205 changed files with 3843 additions and 494 deletions
+4 -2
View File
@@ -3,14 +3,16 @@ project(fcdpro)
set(fcdpro_SOURCES
fcdproinput.cpp
fcdproplugin.cpp
fcdprosettings.cpp
fcdprosettings.cpp
fcdprowebapiadapter.cpp
fcdprothread.cpp
)
set(fcdpro_HEADERS
fcdproinput.h
fcdproplugin.h
fcdprosettings.h
fcdprosettings.h
fcdprowebapiadapter.h
fcdprothread.h
)
+19 -12
View File
@@ -873,7 +873,26 @@ int FCDProInput::webapiSettingsPutPatch(
{
(void) errorMessage;
FCDProSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureFCDPro *msg = MsgConfigureFCDPro::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureFCDPro *msgToGUI = MsgConfigureFCDPro::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void FCDProInput::webapiUpdateDeviceSettings(
FCDProSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response)
{
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getFcdProSettings()->getCenterFrequency();
}
@@ -961,18 +980,6 @@ int FCDProInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getFcdProSettings()->getReverseApiDeviceIndex();
}
MsgConfigureFCDPro *msg = MsgConfigureFCDPro::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureFCDPro *msgToGUI = MsgConfigureFCDPro::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void FCDProInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProSettings& settings)
+9 -1
View File
@@ -145,6 +145,15 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const FCDProSettings& settings);
static void webapiUpdateDeviceSettings(
FCDProSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response);
void set_center_freq(double freq);
void set_bias_t(bool on);
void set_lnaGain(int index);
@@ -184,7 +193,6 @@ private:
void closeFCDAudio();
void applySettings(const FCDProSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProSettings& settings);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FCDProSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);
@@ -19,6 +19,7 @@
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "fcdproplugin.h"
#include "fcdprowebapiadapter.h"
#ifdef SERVER_MODE
#include "fcdproinput.h"
@@ -122,3 +123,8 @@ DeviceSampleSource *FCDProPlugin::createSampleSourcePluginInstance(const QString
return 0;
}
}
DeviceWebAPIAdapter *FCDProPlugin::createDeviceWebAPIAdapter() const
{
return new FCDProWebAPIAdapter();
}
@@ -25,6 +25,7 @@ public:
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSource* createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI);
virtual DeviceWebAPIAdapter* createDeviceWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;
@@ -0,0 +1,51 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// //
// Implementation of static web API adapters used for preset serialization and //
// deserialization //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "SWGDeviceSettings.h"
#include "fcdproinput.h"
#include "fcdprowebapiadapter.h"
FCDProWebAPIAdapter::FCDProWebAPIAdapter()
{}
FCDProWebAPIAdapter::~FCDProWebAPIAdapter()
{}
int FCDProWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
response.getAirspyHfSettings()->init();
FCDProInput::webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int FCDProWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage)
{
(void) errorMessage;
FCDProInput::webapiUpdateDeviceSettings(m_settings, deviceSettingsKeys, response);
return 200;
}
@@ -0,0 +1,44 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
// //
// Implementation of static web API adapters used for preset serialization and //
// deserialization //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "device/devicewebapiadapter.h"
#include "fcdprosettings.h"
class FCDProWebAPIAdapter : public DeviceWebAPIAdapter
{
public:
FCDProWebAPIAdapter();
virtual ~FCDProWebAPIAdapter();
virtual QByteArray serialize() { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { return m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
private:
FCDProSettings m_settings;
};