1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-17 23:28:50 -05:00

REST API: config (8): preset channel Tx adapters where there is CW keyer. AM mod working only

This commit is contained in:
f4exb 2019-08-02 18:16:37 +02:00
parent 9610a6b93a
commit 68a4e23fb0
27 changed files with 777 additions and 15 deletions

View File

@ -3,13 +3,15 @@ project(modam)
set(modam_SOURCES
ammod.cpp
ammodplugin.cpp
ammodsettings.cpp
ammodsettings.cpp
ammodwebapiadapter.cpp
)
set(modam_HEADERS
ammod.h
ammodplugin.h
ammodsettings.h
ammodsettings.h
ammodwebapiadapter.h
)
include_directories(

View File

@ -22,11 +22,12 @@
#include "ammodgui.h"
#endif
#include "ammod.h"
#include "ammodwebapiadapter.h"
#include "ammodplugin.h"
const PluginDescriptor AMModPlugin::m_pluginDescriptor = {
QString("AM Modulator"),
QString("4.11.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -76,3 +77,7 @@ ChannelAPI* AMModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
return new AMMod(deviceAPI);
}
ChannelAPI* AMModPlugin::createChannelWebAPIAdapter() const
{
return new AMModWebAPIAdapter();
}

View File

@ -38,6 +38,7 @@ public:
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;

View File

@ -65,6 +65,8 @@ QByteArray AMModSettings::serialize() const
if (m_cwKeyerGUI) {
s.writeBlob(7, m_cwKeyerGUI->serialize());
} else { // standalone operation with presets
s.writeBlob(7, m_cwKeyerSettings.serialize());
}
if (m_channelMarker) {
@ -109,9 +111,10 @@ bool AMModSettings::deserialize(const QByteArray& data)
d.readReal(4, &m_modFactor, 0.2f);
d.readU32(5, &m_rgbColor);
d.readReal(6, &m_volumeFactor, 1.0);
d.readBlob(7, &bytetmp);
m_cwKeyerSettings.deserialize(bytetmp);
if (m_cwKeyerGUI) {
d.readBlob(7, &bytetmp);
m_cwKeyerGUI->deserialize(bytetmp);
}

View File

@ -20,6 +20,8 @@
#include <QByteArray>
#include "dsp/cwkeyersettings.h"
class Serializable;
struct AMModSettings
@ -56,12 +58,16 @@ struct AMModSettings
Serializable *m_channelMarker;
Serializable *m_cwKeyerGUI;
CWKeyerSettings m_cwKeyerSettings; //!< For standalone deserialize operation (without m_cwKeyerGUI)
AMModSettings();
void resetToDefaults();
void setChannelMarker(Serializable *channelMarker) { m_channelMarker = channelMarker; }
void setCWKeyerGUI(Serializable *cwKeyerGUI) { m_cwKeyerGUI = cwKeyerGUI; }
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
const CWKeyerSettings& getCWKeyerSettings() const { return m_cwKeyerSettings; }
void setCWKeyerSettings(const CWKeyerSettings& cwKeyerSettings) { m_cwKeyerSettings = cwKeyerSettings; }
};

View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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 "SWGChannelSettings.h"
#include "ammod.h"
#include "ammodwebapiadapter.h"
AMModWebAPIAdapter::AMModWebAPIAdapter() :
ChannelAPI(AMMod::m_channelIdURI, ChannelAPI::StreamSingleSource)
{}
AMModWebAPIAdapter::~AMModWebAPIAdapter()
{}
int AMModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setAmModSettings(new SWGSDRangel::SWGAMModSettings());
response.getAmModSettings()->init();
AMMod::webapiFormatChannelSettings(response, m_settings);
const CWKeyerSettings& cwKeyerSettings = m_settings.getCWKeyerSettings();
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getAmModSettings()->getCwKeyer();
apiCwKeyerSettings->init();
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
return 200;
}
int AMModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
AMMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
if (channelSettingsKeys.contains("cwKeyer"))
{
CWKeyerSettings newCWKeyerSettings;
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getAmModSettings()->getCwKeyer();
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, newCWKeyerSettings, apiCwKeyerSettings);
m_settings.setCWKeyerSettings(newCWKeyerSettings);
const QByteArray& serializedNewSettings = m_settings.serialize(); // effectively update CW keyer settings
}
AMMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AMMOD_WEBAPIADAPTER_H
#define INCLUDE_AMMOD_WEBAPIADAPTER_H
#include "channel/channelapi.h"
#include "dsp/cwkeyersettings.h"
#include "ammodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class AMModWebAPIAdapter : public ChannelAPI {
public:
AMModWebAPIAdapter();
virtual ~AMModWebAPIAdapter();
// unused pure virtual methods
virtual void destroy() {}
virtual void getIdentifier(QString& id) {}
virtual void getTitle(QString& title) {}
virtual qint64 getCenterFrequency() const { return 0; }
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
// virtual methods actually implemented
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
AMModSettings m_settings;
};
#endif // INCLUDE_AMMOD_WEBAPIADAPTER_H

View File

@ -4,12 +4,14 @@ set(modfreedv_SOURCES
freedvmod.cpp
freedvmodplugin.cpp
freedvmodsettings.cpp
freedvmodwebapiadapter.cpp
)
set(modfreedv_HEADERS
freedvmod.h
freedvmodplugin.h
freedvmodsettings.h
freedvmodwebapiadapter.h
)
include_directories(

View File

@ -22,11 +22,12 @@
#include "freedvmodgui.h"
#endif
#include "freedvmod.h"
#include "freedvmodwebapiadapter.h"
#include "freedvmodplugin.h"
const PluginDescriptor FreeDVModPlugin::m_pluginDescriptor = {
QString("FreeDV Modulator"),
QString("4.11.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -76,4 +77,7 @@ ChannelAPI* FreeDVModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
return new FreeDVMod(deviceAPI);
}
ChannelAPI* FreeDVModPlugin::createChannelWebAPIAdapter() const
{
return new FreeDVModWebAPIAdapter();
}

View File

@ -38,6 +38,7 @@ public:
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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 "SWGChannelSettings.h"
#include "settings/serializable.h"
#include "freedvmod.h"
#include "freedvmodwebapiadapter.h"
FreeDVModWebAPIAdapter::FreeDVModWebAPIAdapter() :
ChannelAPI(FreeDVMod::m_channelIdURI, ChannelAPI::StreamSingleSource)
{}
FreeDVModWebAPIAdapter::~FreeDVModWebAPIAdapter()
{}
int FreeDVModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setFreeDvModSettings(new SWGSDRangel::SWGFreeDVModSettings());
response.getFreeDvModSettings()->init();
FreeDVMod::webapiFormatChannelSettings(response, m_settings);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer();
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
}
}
return 200;
}
int FreeDVModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
FreeDVMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (channelSettingsKeys.contains("cwKeyer") && cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getFreeDvModSettings()->getCwKeyer();
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
const QByteArray& serializedNewCWKeyerSettings = cwKeyerSettings.serialize();
cwKeyerGUI->deserialize(serializedNewCWKeyerSettings);
}
}
FreeDVMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_FREEDVMOD_WEBAPIADAPTER_H
#define INCLUDE_FREEDVMOD_WEBAPIADAPTER_H
#include "channel/channelapi.h"
#include "freedvmodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class FreeDVModWebAPIAdapter : public ChannelAPI {
public:
FreeDVModWebAPIAdapter();
virtual ~FreeDVModWebAPIAdapter();
// unused pure virtual methods
virtual void destroy() {}
virtual void getIdentifier(QString& id) {}
virtual void getTitle(QString& title) {}
virtual qint64 getCenterFrequency() const { return 0; }
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
// virtual methods actually implemented
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
FreeDVModSettings m_settings;
};
#endif // INCLUDE_FREEDVMOD_WEBAPIADAPTER_H

View File

@ -3,13 +3,15 @@ project(modnfm)
set(modnfm_SOURCES
nfmmod.cpp
nfmmodplugin.cpp
nfmmodsettings.cpp
nfmmodsettings.cpp
nfmmodwebapiadapter.cpp
)
set(modnfm_HEADERS
nfmmod.h
nfmmodplugin.h
nfmmodsettings.h
nfmmodsettings.h
nfmmodwebapiadapter.h
)
include_directories(

View File

@ -22,11 +22,12 @@
#include "nfmmodgui.h"
#endif
#include "nfmmod.h"
#include "nfmmodwebapiadapter.h"
#include "nfmmodplugin.h"
const PluginDescriptor NFMModPlugin::m_pluginDescriptor = {
QString("NFM Modulator"),
QString("4.11.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -76,4 +77,7 @@ ChannelAPI* NFMModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
return new NFMMod(deviceAPI);
}
ChannelAPI* NFMModPlugin::createChannelWebAPIAdapter() const
{
return new NFMModWebAPIAdapter();
}

View File

@ -38,6 +38,7 @@ public:
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *rxChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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 "SWGChannelSettings.h"
#include "settings/serializable.h"
#include "nfmmod.h"
#include "nfmmodwebapiadapter.h"
NFMModWebAPIAdapter::NFMModWebAPIAdapter() :
ChannelAPI(NFMMod::m_channelIdURI, ChannelAPI::StreamSingleSource)
{}
NFMModWebAPIAdapter::~NFMModWebAPIAdapter()
{}
int NFMModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
response.getNfmModSettings()->init();
NFMMod::webapiFormatChannelSettings(response, m_settings);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer();
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
}
}
return 200;
}
int NFMModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
NFMMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (channelSettingsKeys.contains("cwKeyer") && cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getNfmModSettings()->getCwKeyer();
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
const QByteArray& serializedNewCWKeyerSettings = cwKeyerSettings.serialize();
cwKeyerGUI->deserialize(serializedNewCWKeyerSettings);
}
}
NFMMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_NFMMOD_WEBAPIADAPTER_H
#define INCLUDE_NFMMOD_WEBAPIADAPTER_H
#include "channel/channelapi.h"
#include "nfmmodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class NFMModWebAPIAdapter : public ChannelAPI {
public:
NFMModWebAPIAdapter();
virtual ~NFMModWebAPIAdapter();
// unused pure virtual methods
virtual void destroy() {}
virtual void getIdentifier(QString& id) {}
virtual void getTitle(QString& title) {}
virtual qint64 getCenterFrequency() const { return 0; }
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
// virtual methods actually implemented
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
NFMModSettings m_settings;
};
#endif // INCLUDE_NFMMOD_WEBAPIADAPTER_H

View File

@ -4,12 +4,14 @@ set(modssb_SOURCES
ssbmod.cpp
ssbmodplugin.cpp
ssbmodsettings.cpp
ssbmodwebapiadapter.cpp
)
set(modssb_HEADERS
ssbmod.h
ssbmodplugin.h
ssbmodsettings.h
ssbmodwebapiadapter.h
)
include_directories(

View File

@ -22,11 +22,12 @@
#include "ssbmodgui.h"
#endif
#include "ssbmod.h"
#include "ssbmodwebapiadapter.h"
#include "ssbmodplugin.h"
const PluginDescriptor SSBModPlugin::m_pluginDescriptor = {
QString("SSB Modulator"),
QString("4.11.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -76,4 +77,8 @@ ChannelAPI* SSBModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
return new SSBMod(deviceAPI);
}
ChannelAPI* SSBModPlugin::createChannelWebAPIAdapter() const
{
return new SSBModWebAPIAdapter();
}

View File

@ -38,6 +38,7 @@ public:
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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 "SWGChannelSettings.h"
#include "settings/serializable.h"
#include "ssbmod.h"
#include "ssbmodwebapiadapter.h"
SSBModWebAPIAdapter::SSBModWebAPIAdapter() :
ChannelAPI(SSBMod::m_channelIdURI, ChannelAPI::StreamSingleSource)
{}
SSBModWebAPIAdapter::~SSBModWebAPIAdapter()
{}
int SSBModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setSsbModSettings(new SWGSDRangel::SWGSSBModSettings());
response.getSsbModSettings()->init();
SSBMod::webapiFormatChannelSettings(response, m_settings);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer();
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
}
}
return 200;
}
int SSBModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
SSBMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (channelSettingsKeys.contains("cwKeyer") && cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getSsbModSettings()->getCwKeyer();
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
const QByteArray& serializedNewCWKeyerSettings = cwKeyerSettings.serialize();
cwKeyerGUI->deserialize(serializedNewCWKeyerSettings);
}
}
SSBMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_SSBMOD_WEBAPIADAPTER_H
#define INCLUDE_SSBMOD_WEBAPIADAPTER_H
#include "channel/channelapi.h"
#include "ssbmodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class SSBModWebAPIAdapter : public ChannelAPI {
public:
SSBModWebAPIAdapter();
virtual ~SSBModWebAPIAdapter();
// unused pure virtual methods
virtual void destroy() {}
virtual void getIdentifier(QString& id) {}
virtual void getTitle(QString& title) {}
virtual qint64 getCenterFrequency() const { return 0; }
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
// virtual methods actually implemented
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
SSBModSettings m_settings;
};
#endif // INCLUDE_SSBMOD_WEBAPIADAPTER_H

View File

@ -3,13 +3,15 @@ project(modwfm)
set(modwfm_SOURCES
wfmmod.cpp
wfmmodplugin.cpp
wfmmodsettings.cpp
wfmmodsettings.cpp
wfmmodwebapiadapter.cpp
)
set(modwfm_HEADERS
wfmmod.h
wfmmodplugin.h
wfmmodsettings.h
wfmmodsettings.h
wfmmodwebapiadapter.h
)
include_directories(

View File

@ -22,11 +22,12 @@
#include "wfmmodgui.h"
#endif
#include "wfmmod.h"
#include "wfmmodwebapiadapter.h"
#include "wfmmodplugin.h"
const PluginDescriptor WFMModPlugin::m_pluginDescriptor = {
QString("WFM Modulator"),
QString("4.11.5"),
QString("4.11.6"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
@ -76,4 +77,7 @@ ChannelAPI* WFMModPlugin::createTxChannelCS(DeviceAPI *deviceAPI) const
return new WFMMod(deviceAPI);
}
ChannelAPI* WFMModPlugin::createChannelWebAPIAdapter() const
{
return new WFMModWebAPIAdapter();
}

View File

@ -37,6 +37,7 @@ public:
virtual PluginInstanceGUI* createTxChannelGUI(DeviceUISet *deviceUISet, BasebandSampleSource *txChannel) const;
virtual BasebandSampleSource* createTxChannelBS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createTxChannelCS(DeviceAPI *deviceAPI) const;
virtual ChannelAPI* createChannelWebAPIAdapter() const;
private:
static const PluginDescriptor m_pluginDescriptor;

View File

@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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 "SWGChannelSettings.h"
#include "settings/serializable.h"
#include "wfmmod.h"
#include "wfmmodwebapiadapter.h"
WFMModWebAPIAdapter::WFMModWebAPIAdapter() :
ChannelAPI(WFMMod::m_channelIdURI, ChannelAPI::StreamSingleSource)
{}
WFMModWebAPIAdapter::~WFMModWebAPIAdapter()
{}
int WFMModWebAPIAdapter::webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
response.setWfmModSettings(new SWGSDRangel::SWGWFMModSettings());
response.getWfmModSettings()->init();
WFMMod::webapiFormatChannelSettings(response, m_settings);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer();
CWKeyer::webapiFormatChannelSettings(apiCwKeyerSettings, cwKeyerSettings);
}
}
return 200;
}
int WFMModWebAPIAdapter::webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage)
{
(void) errorMessage;
WFMMod::webapiUpdateChannelSettings(m_settings, channelSettingsKeys, response);
Serializable *cwKeyerGUI = m_settings.m_cwKeyerGUI;
if (channelSettingsKeys.contains("cwKeyer") && cwKeyerGUI)
{
const QByteArray& serializedCWKeyerSettings = cwKeyerGUI->serialize();
CWKeyerSettings cwKeyerSettings;
if (cwKeyerSettings.deserialize(serializedCWKeyerSettings))
{
SWGSDRangel::SWGCWKeyerSettings *apiCwKeyerSettings = response.getWfmModSettings()->getCwKeyer();
CWKeyer::webapiSettingsPutPatch(channelSettingsKeys, cwKeyerSettings, apiCwKeyerSettings);
const QByteArray& serializedNewCWKeyerSettings = cwKeyerSettings.serialize();
cwKeyerGUI->deserialize(serializedNewCWKeyerSettings);
}
}
WFMMod::webapiFormatChannelSettings(response, m_settings);
return 200;
}

View File

@ -0,0 +1,65 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2019 Edouard Griffiths, F4EXB. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_WFMMOD_WEBAPIADAPTER_H
#define INCLUDE_WFMMOD_WEBAPIADAPTER_H
#include "channel/channelapi.h"
#include "wfmmodsettings.h"
/**
* Standalone API adapter only for the settings
*/
class WFMModWebAPIAdapter : public ChannelAPI {
public:
WFMModWebAPIAdapter();
virtual ~WFMModWebAPIAdapter();
// unused pure virtual methods
virtual void destroy() {}
virtual void getIdentifier(QString& id) {}
virtual void getTitle(QString& title) {}
virtual qint64 getCenterFrequency() const { return 0; }
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return 0;
}
// virtual methods actually implemented
virtual QByteArray serialize() const { return m_settings.serialize(); }
virtual bool deserialize(const QByteArray& data) { m_settings.deserialize(data); }
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
private:
WFMModSettings m_settings;
};
#endif // INCLUDE_WFMMOD_WEBAPIADAPTER_H