1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 00:14:49 -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,14 +4,16 @@ set(testsource_SOURCES
testsourceinput.cpp
testsourceplugin.cpp
testsourcethread.cpp
testsourcesettings.cpp
testsourcesettings.cpp
testsourcewebapiadapter.cpp
)
set(testsource_HEADERS
testsourceinput.h
testsourceplugin.h
testsourcethread.h
testsourcesettings.h
testsourcesettings.h
testsourcewebapiadapter.h
)
include_directories(
@@ -497,7 +497,26 @@ int TestSourceInput::webapiSettingsPutPatch(
{
(void) errorMessage;
TestSourceSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureTestSource *msg = MsgConfigureTestSource::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureTestSource *msgToGUI = MsgConfigureTestSource::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void TestSourceInput::webapiUpdateDeviceSettings(
TestSourceSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response)
{
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getTestSourceSettings()->getCenterFrequency();
}
@@ -569,18 +588,6 @@ int TestSourceInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getTestSourceSettings()->getReverseApiDeviceIndex();
}
MsgConfigureTestSource *msg = MsgConfigureTestSource::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureTestSource *msgToGUI = MsgConfigureTestSource::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void TestSourceInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestSourceSettings& settings)
@@ -135,6 +135,15 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const TestSourceSettings& settings);
static void webapiUpdateDeviceSettings(
TestSourceSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response);
private:
DeviceAPI *m_deviceAPI;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
@@ -148,7 +157,6 @@ private:
QNetworkRequest m_networkRequest;
bool applySettings(const TestSourceSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const TestSourceSettings& settings);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const TestSourceSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);
@@ -26,10 +26,11 @@
#include "testsourcegui.h"
#endif
#include "testsourceplugin.h"
#include "testsourcewebapiadapter.h"
const PluginDescriptor TestSourcePlugin::m_pluginDescriptor = {
QString("Test Source input"),
QString("4.5.2"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@@ -112,3 +113,7 @@ DeviceSampleSource *TestSourcePlugin::createSampleSourcePluginInstance(const QSt
}
}
DeviceWebAPIAdapter *TestSourcePlugin::createDeviceWebAPIAdapter() const
{
return new TestSourceWebAPIAdapter();
}
@@ -42,6 +42,7 @@ public:
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSource* createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI);
virtual DeviceWebAPIAdapter* createDeviceWebAPIAdapter() const;
static const QString m_hardwareID;
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 "testsourceinput.h"
#include "testsourcewebapiadapter.h"
TestSourceWebAPIAdapter::TestSourceWebAPIAdapter()
{}
TestSourceWebAPIAdapter::~TestSourceWebAPIAdapter()
{}
int TestSourceWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
response.getAirspyHfSettings()->init();
TestSourceInput::webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int TestSourceWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage)
{
(void) errorMessage;
TestSourceInput::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 "testsourcesettings.h"
class TestSourceWebAPIAdapter : public DeviceWebAPIAdapter
{
public:
TestSourceWebAPIAdapter();
virtual ~TestSourceWebAPIAdapter();
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:
TestSourceSettings m_settings;
};