1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-06 16:05:13 -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
@@ -14,6 +14,7 @@ set(remoteinput_SOURCES
remoteinputudphandler.cpp
remoteinput.cpp
remoteinputsettings.cpp
remoteinputwebapiadapter.cpp
remoteinputplugin.cpp
)
@@ -22,6 +23,7 @@ set(remoteinput_HEADERS
remoteinputudphandler.h
remoteinput.h
remoteinputsettings.h
remoteinputwebapiadapter.h
remoteinputplugin.h
)
@@ -333,7 +333,26 @@ int RemoteInput::webapiSettingsPutPatch(
{
(void) errorMessage;
RemoteInputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureRemoteInput *msg = MsgConfigureRemoteInput::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRemoteInput *msgToGUI = MsgConfigureRemoteInput::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void webapiUpdateDeviceSettings(
RemoteInputSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response)
{
if (deviceSettingsKeys.contains("apiAddress")) {
settings.m_apiAddress = *response.getRemoteInputSettings()->getApiAddress();
}
@@ -367,18 +386,6 @@ int RemoteInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getRemoteInputSettings()->getReverseApiDeviceIndex();
}
MsgConfigureRemoteInput *msg = MsgConfigureRemoteInput::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureRemoteInput *msgToGUI = MsgConfigureRemoteInput::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void RemoteInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RemoteInputSettings& settings)
@@ -313,6 +313,15 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const RemoteInputSettings& settings);
static void webapiUpdateDeviceSettings(
RemoteInputSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response);
private:
DeviceAPI *m_deviceAPI;
QMutex m_mutex;
@@ -326,7 +335,6 @@ private:
QNetworkRequest m_networkRequest;
void applySettings(const RemoteInputSettings& settings, bool force = false);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RemoteInputSettings& settings);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const RemoteInputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);
@@ -26,10 +26,11 @@
#include "remoteinputgui.h"
#endif
#include "remoteinputplugin.h"
#include "remoteinputwebapiadapter.h"
const PluginDescriptor RemoteInputPlugin::m_pluginDescriptor = {
QString("Remote device input"),
QString("4.5.6"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@@ -114,3 +115,8 @@ DeviceSampleSource *RemoteInputPlugin::createSampleSourcePluginInstance(const QS
return 0;
}
}
DeviceWebAPIAdapter *RemoteInputPlugin::createDeviceWebAPIAdapter() const
{
return new RemoteInputWebAPIAdapter();
}
@@ -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 "remoteinput.h"
#include "remoteinputwebapiadapter.h"
RemoteInputWebAPIAdapter::RemoteInputWebAPIAdapter()
{}
RemoteInputWebAPIAdapter::~RemoteInputWebAPIAdapter()
{}
int RemoteInputWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
response.getAirspyHfSettings()->init();
RemoteInput::webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int RemoteInputWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage)
{
(void) errorMessage;
RemoteInput::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 "remoteinputsettings.h"
class RemoteInputWebAPIAdapter : public DeviceWebAPIAdapter
{
public:
RemoteInputWebAPIAdapter();
virtual ~RemoteInputWebAPIAdapter();
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:
RemoteInputSettings m_settings;
};