1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-12 18:58:48 -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
@@ -3,14 +3,16 @@ project(fcdproplus)
set(fcdproplus_SOURCES
fcdproplusinput.cpp
fcdproplusplugin.cpp
fcdproplussettings.cpp
fcdproplussettings.cpp
fcdpropluswebapiadapter.cpp
fcdproplusthread.cpp
)
set(fcdproplus_HEADERS
fcdproplusinput.h
fcdproplusplugin.h
fcdproplussettings.h
fcdproplussettings.h
fcdpropluswebapiadapter.h
fcdproplusthread.h
)
@@ -600,7 +600,26 @@ int FCDProPlusInput::webapiSettingsPutPatch(
{
(void) errorMessage;
FCDProPlusSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureFCDProPlus *msg = MsgConfigureFCDProPlus::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureFCDProPlus *msgToGUI = MsgConfigureFCDProPlus::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void FCDProPlusInput::webapiUpdateDeviceSettings(
FCDProPlusSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response)
{
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getFcdProPlusSettings()->getCenterFrequency();
}
@@ -661,18 +680,6 @@ int FCDProPlusInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getFcdProPlusSettings()->getReverseApiDeviceIndex();
}
MsgConfigureFCDProPlus *msg = MsgConfigureFCDProPlus::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureFCDProPlus *msgToGUI = MsgConfigureFCDProPlus::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void FCDProPlusInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProPlusSettings& settings)
@@ -145,6 +145,15 @@ public:
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const FCDProPlusSettings& settings);
static void webapiUpdateDeviceSettings(
FCDProPlusSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response);
void set_center_freq(double freq);
void set_bias_t(bool on);
void set_lna_gain(bool on);
@@ -172,7 +181,6 @@ private:
bool openFCDAudio(const char *filename);
void closeFCDAudio();
void applySettings(const FCDProPlusSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProPlusSettings& settings);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FCDProPlusSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);
@@ -19,6 +19,7 @@
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "fcdproplusplugin.h"
#include "fcdpropluswebapiadapter.h"
#ifdef SERVER_MODE
#include "fcdproplusinput.h"
@@ -124,3 +125,8 @@ DeviceSampleSource *FCDProPlusPlugin::createSampleSourcePluginInstance(const QSt
return 0;
}
}
DeviceWebAPIAdapter *FCDProPlusPlugin::createDeviceWebAPIAdapter() const
{
return new FCDProPlusWebAPIAdapter();
}
@@ -25,6 +25,7 @@ public:
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSource* createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI);
virtual DeviceWebAPIAdapter* createDeviceWebAPIAdapter() const;
static const QString m_deviceTypeID;
@@ -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 "fcdproplusinput.h"
#include "fcdpropluswebapiadapter.h"
FCDProPlusWebAPIAdapter::FCDProPlusWebAPIAdapter()
{}
FCDProPlusWebAPIAdapter::~FCDProPlusWebAPIAdapter()
{}
int FCDProPlusWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
response.getAirspyHfSettings()->init();
FCDProPlusInput::webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int FCDProPlusWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage)
{
(void) errorMessage;
FCDProPlusInput::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 "fcdproplussettings.h"
class FCDProPlusWebAPIAdapter : public DeviceWebAPIAdapter
{
public:
FCDProPlusWebAPIAdapter();
virtual ~FCDProPlusWebAPIAdapter();
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:
FCDProPlusSettings m_settings;
};