mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-28 13:04:17 -04:00
REST API: config: GET (11). Support of the rest of devices
This commit is contained in:
@@ -3,14 +3,16 @@ project(bladerf1input)
|
||||
set(bladerf1input_SOURCES
|
||||
bladerf1input.cpp
|
||||
bladerf1inputplugin.cpp
|
||||
bladerf1inputsettings.cpp
|
||||
bladerf1inputsettings.cpp
|
||||
bladerf1inputwebapiadapter.cpp
|
||||
bladerf1inputthread.cpp
|
||||
)
|
||||
|
||||
set(bladerf1input_HEADERS
|
||||
bladerf1input.h
|
||||
bladerf1inputplugin.h
|
||||
bladerf1inputsettings.h
|
||||
bladerf1inputsettings.h
|
||||
bladerf1inputwebapiadapter.h
|
||||
bladerf1inputthread.h
|
||||
)
|
||||
|
||||
|
||||
@@ -667,7 +667,26 @@ int Bladerf1Input::webapiSettingsPutPatch(
|
||||
{
|
||||
(void) errorMessage;
|
||||
BladeRF1InputSettings settings = m_settings;
|
||||
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
|
||||
|
||||
MsgConfigureBladerf1 *msg = MsgConfigureBladerf1::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureBladerf1 *msgToGUI = MsgConfigureBladerf1::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void Bladerf1Input::webapiUpdateDeviceSettings(
|
||||
BladeRF1InputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response)
|
||||
{
|
||||
if (deviceSettingsKeys.contains("centerFrequency")) {
|
||||
settings.m_centerFrequency = response.getBladeRf1InputSettings()->getCenterFrequency();
|
||||
}
|
||||
@@ -722,18 +741,6 @@ int Bladerf1Input::webapiSettingsPutPatch(
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getBladeRf1InputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
|
||||
MsgConfigureBladerf1 *msg = MsgConfigureBladerf1::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureBladerf1 *msgToGUI = MsgConfigureBladerf1::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatDeviceSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int Bladerf1Input::webapiRunGet(
|
||||
|
||||
@@ -138,6 +138,15 @@ public:
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage);
|
||||
|
||||
static void webapiFormatDeviceSettings(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
const BladeRF1InputSettings& settings);
|
||||
|
||||
static void webapiUpdateDeviceSettings(
|
||||
BladeRF1InputSettings& settings,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response);
|
||||
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
@@ -155,7 +164,6 @@ private:
|
||||
void closeDevice();
|
||||
bool applySettings(const BladeRF1InputSettings& settings, bool force);
|
||||
bladerf_lna_gain getLnaGain(int lnaGain);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const BladeRF1InputSettings& settings);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const BladeRF1InputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <libbladeRF.h>
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "util/simpleserializer.h"
|
||||
#include "bladerf1inputwebapiadapter.h"
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
#include "bladerf1input.h"
|
||||
@@ -150,3 +151,7 @@ DeviceSampleSource *Blderf1InputPlugin::createSampleSourcePluginInstance(const Q
|
||||
}
|
||||
}
|
||||
|
||||
DeviceWebAPIAdapter *Blderf1InputPlugin::createDeviceWebAPIAdapter() const
|
||||
{
|
||||
return new BladeRF1InputWebAPIAdapter();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,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 "bladerf1input.h"
|
||||
#include "bladerf1inputwebapiadapter.h"
|
||||
|
||||
BladeRF1InputWebAPIAdapter::BladeRF1InputWebAPIAdapter()
|
||||
{}
|
||||
|
||||
BladeRF1InputWebAPIAdapter::~BladeRF1InputWebAPIAdapter()
|
||||
{}
|
||||
|
||||
int BladeRF1InputWebAPIAdapter::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
|
||||
response.getAirspyHfSettings()->init();
|
||||
Bladerf1Input::webapiFormatDeviceSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int BladeRF1InputWebAPIAdapter::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
Bladerf1Input::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 "bladerf1inputsettings.h"
|
||||
|
||||
class BladeRF1InputWebAPIAdapter : public DeviceWebAPIAdapter
|
||||
{
|
||||
public:
|
||||
BladeRF1InputWebAPIAdapter();
|
||||
virtual ~BladeRF1InputWebAPIAdapter();
|
||||
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:
|
||||
BladeRF1InputSettings m_settings;
|
||||
};
|
||||
Reference in New Issue
Block a user