1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-08-14 15:33:34 -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,6 +4,7 @@ set(hackrfoutput_SOURCES
hackrfoutput.cpp
hackrfoutputplugin.cpp
hackrfoutputsettings.cpp
hackrfoutputwebapiadapter.cpp
hackrfoutputthread.cpp
)
@@ -11,6 +12,7 @@ set(hackrfoutput_HEADERS
hackrfoutput.h
hackrfoutputplugin.h
hackrfoutputsettings.h
hackrfoutputwebapiadapter.h
hackrfoutputthread.h
)
@@ -561,7 +561,26 @@ int HackRFOutput::webapiSettingsPutPatch(
{
(void) errorMessage;
HackRFOutputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureHackRF *msg = MsgConfigureHackRF::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureHackRF *msgToGUI = MsgConfigureHackRF::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void HackRFOutput::webapiUpdateDeviceSettings(
HackRFOutputSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response)
{
if (deviceSettingsKeys.contains("centerFrequency")) {
settings.m_centerFrequency = response.getHackRfOutputSettings()->getCenterFrequency();
}
@@ -604,18 +623,6 @@ int HackRFOutput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
settings.m_reverseAPIDeviceIndex = response.getHackRfOutputSettings()->getReverseApiDeviceIndex();
}
MsgConfigureHackRF *msg = MsgConfigureHackRF::create(settings, force);
m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any
{
MsgConfigureHackRF *msgToGUI = MsgConfigureHackRF::create(settings, force);
m_guiMessageQueue->push(msgToGUI);
}
webapiFormatDeviceSettings(response, settings);
return 200;
}
void HackRFOutput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const HackRFOutputSettings& settings)
@@ -134,6 +134,15 @@ public:
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
static void webapiFormatDeviceSettings(
SWGSDRangel::SWGDeviceSettings& response,
const HackRFOutputSettings& settings);
static void webapiUpdateDeviceSettings(
HackRFOutputSettings& settings,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response);
private:
DeviceAPI *m_deviceAPI;
QMutex m_mutex;
@@ -151,7 +160,6 @@ private:
bool applySettings(const HackRFOutputSettings& settings, bool force);
// hackrf_device *open_hackrf_from_sequence(int sequence);
void setDeviceCenterFrequency(quint64 freq_hz, qint32 LOppmTenths);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const HackRFOutputSettings& settings);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);
@@ -27,10 +27,11 @@
#include "hackrfoutputgui.h"
#endif
#include "hackrfoutputplugin.h"
#include "hackrfoutputwebapiadapter.h"
const PluginDescriptor HackRFOutputPlugin::m_pluginDescriptor = {
QString("HackRF Output"),
QString("4.5.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@@ -57,13 +58,6 @@ void HackRFOutputPlugin::initPlugin(PluginAPI* pluginAPI)
PluginInterface::SamplingDevices HackRFOutputPlugin::enumSampleSinks()
{
// hackrf_error rc = (hackrf_error) hackrf_init();
//
// if (rc != HACKRF_SUCCESS)
// {
// qCritical("HackRFOutputPlugin::enumSampleSinks: failed to initiate HackRF library: %s", hackrf_error_name(rc));
// }
SamplingDevices result;
hackrf_device_list_t *hackrf_devices = hackrf_device_list();
hackrf_device *hackrf_ptr;
@@ -115,9 +109,6 @@ PluginInterface::SamplingDevices HackRFOutputPlugin::enumSampleSinks()
}
hackrf_device_list_free(hackrf_devices);
// rc = (hackrf_error) hackrf_exit();
// qDebug("HackRFOutputPlugin::enumSampleSinks: hackrf_exit: %s", hackrf_error_name(rc));
return result;
}
@@ -165,4 +156,7 @@ DeviceSampleSink* HackRFOutputPlugin::createSampleSinkPluginInstance(const QStri
}
DeviceWebAPIAdapter *HackRFOutputPlugin::createDeviceWebAPIAdapter() const
{
return new HackRFOutputWebAPIAdapter();
}
@@ -42,6 +42,7 @@ public:
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSink* createSampleSinkPluginInstance(const QString& sinkId, 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 "hackrfoutput.h"
#include "hackrfoutputwebapiadapter.h"
HackRFOutputWebAPIAdapter::HackRFOutputWebAPIAdapter()
{}
HackRFOutputWebAPIAdapter::~HackRFOutputWebAPIAdapter()
{}
int HackRFOutputWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGDeviceSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAirspyHfSettings(new SWGSDRangel::SWGAirspyHFSettings());
response.getAirspyHfSettings()->init();
HackRFOutput::webapiFormatDeviceSettings(response, m_settings);
return 200;
}
int HackRFOutputWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage)
{
(void) errorMessage;
HackRFOutput::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 "hackrfoutputsettings.h"
class HackRFOutputWebAPIAdapter : public DeviceWebAPIAdapter
{
public:
HackRFOutputWebAPIAdapter();
virtual ~HackRFOutputWebAPIAdapter();
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:
HackRFOutputSettings m_settings;
};