mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 05:41:56 -05:00
Server: Web API: /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/settings PUT, PATCH with all settings parameters optional
This commit is contained in:
parent
ead034e21d
commit
bf6607044a
@ -361,6 +361,8 @@ bool NFMDemod::handleMessage(const Message& cmd)
|
||||
settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset;
|
||||
|
||||
qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod:"
|
||||
<< " m_absoluteFrequencyOffset: " << m_absoluteFrequencyOffset
|
||||
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
|
||||
<< " m_rfBandwidth: " << settings.m_rfBandwidth
|
||||
<< " m_afBandwidth: " << settings.m_afBandwidth
|
||||
<< " m_fmDeviation: " << settings.m_fmDeviation
|
||||
@ -486,51 +488,84 @@ int NFMDemod::webapiSettingsGet(
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
response.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
|
||||
response.getNfmDemodSettings()->setAfBandwidth(m_settings.m_afBandwidth);
|
||||
response.getNfmDemodSettings()->setAudioMute(m_settings.m_audioMute ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setAudioSampleRate(m_settings.m_audioSampleRate);
|
||||
response.getNfmDemodSettings()->setCopyAudioToUdp(m_settings.m_copyAudioToUDP ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setCtcssIndex(m_settings.m_ctcssIndex);
|
||||
response.getNfmDemodSettings()->setCtcssOn(m_settings.m_ctcssOn ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setDeltaSquelch(m_settings.m_deltaSquelch ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setFmDeviation(m_settings.m_fmDeviation);
|
||||
response.getNfmDemodSettings()->setInputFrequencyOffset(m_settings.m_inputFrequencyOffset);
|
||||
response.getNfmDemodSettings()->setInputSampleRate(m_settings.m_inputSampleRate);
|
||||
response.getNfmDemodSettings()->setRfBandwidth(m_settings.m_rfBandwidth);
|
||||
response.getNfmDemodSettings()->setRgbColor(m_settings.m_rgbColor);
|
||||
response.getNfmDemodSettings()->setSquelch(m_settings.m_squelch);
|
||||
response.getNfmDemodSettings()->setSquelchGate(m_settings.m_squelchGate);
|
||||
*response.getNfmDemodSettings()->getTitle() = m_settings.m_title;
|
||||
*response.getNfmDemodSettings()->getUdpAddress() = m_settings.m_udpAddress;
|
||||
response.getNfmDemodSettings()->setUdpPort(m_settings.m_udpPort);
|
||||
response.getNfmDemodSettings()->setVolume(m_settings.m_volume);
|
||||
NFMDemodSettings settings = m_settings;
|
||||
settings.m_inputFrequencyOffset = m_absoluteFrequencyOffset;
|
||||
webapiFormatChannelSettings(response, settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int NFMDemod::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
NFMDemodSettings settings;
|
||||
settings.m_afBandwidth = response.getNfmDemodSettings()->getAfBandwidth();
|
||||
settings.m_audioMute = response.getNfmDemodSettings()->getAudioMute() != 0;
|
||||
settings.m_audioSampleRate = response.getNfmDemodSettings()->getAudioSampleRate();
|
||||
settings.m_copyAudioToUDP = response.getNfmDemodSettings()->getCopyAudioToUdp() != 0;
|
||||
settings.m_ctcssIndex = response.getNfmDemodSettings()->getCtcssIndex();
|
||||
settings.m_ctcssOn = response.getNfmDemodSettings()->getCtcssOn() != 0;
|
||||
settings.m_deltaSquelch = response.getNfmDemodSettings()->getDeltaSquelch() != 0;
|
||||
settings.m_fmDeviation = response.getNfmDemodSettings()->getFmDeviation();
|
||||
settings.m_inputFrequencyOffset = response.getNfmDemodSettings()->getInputFrequencyOffset();
|
||||
settings.m_inputSampleRate = response.getNfmDemodSettings()->getInputSampleRate();
|
||||
settings.m_rfBandwidth = response.getNfmDemodSettings()->getRfBandwidth();
|
||||
settings.m_rgbColor = response.getNfmDemodSettings()->getRgbColor();
|
||||
settings.m_squelch = response.getNfmDemodSettings()->getSquelch();
|
||||
settings.m_squelchGate = response.getNfmDemodSettings()->getSquelchGate();
|
||||
settings.m_title = *response.getNfmDemodSettings()->getTitle();
|
||||
settings.m_udpAddress = *response.getNfmDemodSettings()->getUdpAddress();
|
||||
settings.m_udpPort = response.getNfmDemodSettings()->getUdpPort();
|
||||
settings.m_volume = response.getNfmDemodSettings()->getVolume();
|
||||
NFMDemodSettings settings = m_settings;
|
||||
bool frequencyOffsetChanged;
|
||||
|
||||
if (channelSettingsKeys.contains("afBandwidth")) {
|
||||
settings.m_afBandwidth = response.getNfmDemodSettings()->getAfBandwidth();
|
||||
}
|
||||
if (channelSettingsKeys.contains("audioMute")) {
|
||||
settings.m_audioMute = response.getNfmDemodSettings()->getAudioMute() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("audioSampleRate")) {
|
||||
settings.m_audioSampleRate = response.getNfmDemodSettings()->getAudioSampleRate();
|
||||
}
|
||||
if (channelSettingsKeys.contains("copyAudioToUDP")) {
|
||||
settings.m_copyAudioToUDP = response.getNfmDemodSettings()->getCopyAudioToUdp() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("ctcssIndex")) {
|
||||
settings.m_ctcssIndex = response.getNfmDemodSettings()->getCtcssIndex();
|
||||
}
|
||||
if (channelSettingsKeys.contains("ctcssOn")) {
|
||||
settings.m_ctcssOn = response.getNfmDemodSettings()->getCtcssOn() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("deltaSquelch")) {
|
||||
settings.m_deltaSquelch = response.getNfmDemodSettings()->getDeltaSquelch() != 0;
|
||||
}
|
||||
if (channelSettingsKeys.contains("fmDeviation")) {
|
||||
settings.m_fmDeviation = response.getNfmDemodSettings()->getFmDeviation();
|
||||
}
|
||||
if (channelSettingsKeys.contains("inputFrequencyOffset"))
|
||||
{
|
||||
settings.m_inputFrequencyOffset = response.getNfmDemodSettings()->getInputFrequencyOffset();
|
||||
frequencyOffsetChanged = true;
|
||||
}
|
||||
// if (channelSettingsKeys.contains("inputSampleRate")) {
|
||||
// settings.m_inputSampleRate = response.getNfmDemodSettings()->getInputSampleRate();
|
||||
// }
|
||||
if (channelSettingsKeys.contains("rfBandwidth")) {
|
||||
settings.m_rfBandwidth = response.getNfmDemodSettings()->getRfBandwidth();
|
||||
}
|
||||
if (channelSettingsKeys.contains("rgbColor")) {
|
||||
settings.m_rgbColor = response.getNfmDemodSettings()->getRgbColor();
|
||||
}
|
||||
if (channelSettingsKeys.contains("squelch")) {
|
||||
settings.m_squelch = response.getNfmDemodSettings()->getSquelch();
|
||||
}
|
||||
if (channelSettingsKeys.contains("squelchGate")) {
|
||||
settings.m_squelchGate = response.getNfmDemodSettings()->getSquelchGate();
|
||||
}
|
||||
if (channelSettingsKeys.contains("title")) {
|
||||
settings.m_title = *response.getNfmDemodSettings()->getTitle();
|
||||
}
|
||||
if (channelSettingsKeys.contains("udpAddress")) {
|
||||
settings.m_udpAddress = *response.getNfmDemodSettings()->getUdpAddress();
|
||||
}
|
||||
if (channelSettingsKeys.contains("udpPort")) {
|
||||
settings.m_udpPort = response.getNfmDemodSettings()->getUdpPort();
|
||||
}
|
||||
if (channelSettingsKeys.contains("volume")) {
|
||||
settings.m_volume = response.getNfmDemodSettings()->getVolume();
|
||||
}
|
||||
|
||||
if (frequencyOffsetChanged)
|
||||
{
|
||||
MsgConfigureChannelizer* channelConfigMsg = MsgConfigureChannelizer::create(
|
||||
48000, settings.m_inputFrequencyOffset);
|
||||
m_inputMessageQueue.push(channelConfigMsg);
|
||||
}
|
||||
|
||||
MsgConfigureNFMDemod *msg = MsgConfigureNFMDemod::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
@ -541,5 +576,40 @@ int NFMDemod::webapiSettingsPutPatch(
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
webapiFormatChannelSettings(response, settings);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
void NFMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings)
|
||||
{
|
||||
response.getNfmDemodSettings()->setAfBandwidth(settings.m_afBandwidth);
|
||||
response.getNfmDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setAudioSampleRate(settings.m_audioSampleRate);
|
||||
response.getNfmDemodSettings()->setCopyAudioToUdp(settings.m_copyAudioToUDP ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setCtcssIndex(settings.m_ctcssIndex);
|
||||
response.getNfmDemodSettings()->setCtcssOn(settings.m_ctcssOn ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setDeltaSquelch(settings.m_deltaSquelch ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setFmDeviation(settings.m_fmDeviation);
|
||||
response.getNfmDemodSettings()->setInputFrequencyOffset(settings.m_inputFrequencyOffset);
|
||||
response.getNfmDemodSettings()->setInputSampleRate(settings.m_inputSampleRate);
|
||||
response.getNfmDemodSettings()->setRfBandwidth(settings.m_rfBandwidth);
|
||||
response.getNfmDemodSettings()->setRgbColor(settings.m_rgbColor);
|
||||
response.getNfmDemodSettings()->setSquelch(settings.m_squelch);
|
||||
response.getNfmDemodSettings()->setSquelchGate(settings.m_squelchGate);
|
||||
response.getNfmDemodSettings()->setUdpPort(settings.m_udpPort);
|
||||
response.getNfmDemodSettings()->setVolume(settings.m_volume);
|
||||
|
||||
if (response.getNfmDemodSettings()->getTitle()) {
|
||||
*response.getNfmDemodSettings()->getTitle() = settings.m_title;
|
||||
} else {
|
||||
response.getNfmDemodSettings()->setTitle(new QString(settings.m_title));
|
||||
}
|
||||
|
||||
if (response.getNfmDemodSettings()->getUdpAddress()) {
|
||||
*response.getNfmDemodSettings()->getUdpAddress() = settings.m_udpAddress;
|
||||
} else {
|
||||
response.getNfmDemodSettings()->setUdpAddress(new QString(settings.m_udpAddress));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ public:
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
@ -221,6 +222,7 @@ private:
|
||||
|
||||
// void apply(bool force = false);
|
||||
void applySettings(const NFMDemodSettings& settings, bool force = false);
|
||||
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_NFMDEMOD_H
|
||||
|
@ -532,6 +532,7 @@ int NFMMod::webapiSettingsGet(
|
||||
|
||||
int NFMMod::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
|
@ -254,6 +254,7 @@ public:
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force __attribute__((unused)),
|
||||
const QStringList& channelSettingsKeys __attribute__((unused)),
|
||||
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
|
||||
QString& errorMessage)
|
||||
{ errorMessage = "Not implemented"; return 501; }
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
|
||||
virtual int webapiSettingsPutPatch(
|
||||
bool force __attribute__((unused)),
|
||||
const QStringList& channelSettingsKeys __attribute__((unused)),
|
||||
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
|
||||
QString& errorMessage)
|
||||
{ errorMessage = "Not implemented"; return 501; }
|
||||
|
@ -487,6 +487,7 @@ public:
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
int channelIndex __attribute__((unused)),
|
||||
bool force __attribute__((unused)),
|
||||
const QStringList& channelSettingsKeys __attribute__((unused)),
|
||||
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
|
@ -1175,13 +1175,15 @@ void WebAPIRequestMapper::devicesetChannelSettingsService(
|
||||
{
|
||||
SWGSDRangel::SWGChannelSettings normalResponse;
|
||||
resetChannelSettings(normalResponse);
|
||||
QStringList channelSettingsKeys;
|
||||
|
||||
if (validateChannelSettings(normalResponse, jsonObject))
|
||||
if (validateChannelSettings(normalResponse, jsonObject, channelSettingsKeys))
|
||||
{
|
||||
int status = m_adapter->devicesetChannelSettingsPutPatch(
|
||||
deviceSetIndex,
|
||||
channelIndex,
|
||||
(request.getMethod() == "PUT"), // force settings on PUT
|
||||
channelSettingsKeys,
|
||||
normalResponse,
|
||||
errorResponse);
|
||||
response.setStatus(status);
|
||||
@ -1427,7 +1429,10 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
|
||||
}
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::validateChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings, QJsonObject& jsonObject)
|
||||
bool WebAPIRequestMapper::validateChannelSettings(
|
||||
SWGSDRangel::SWGChannelSettings& channelSettings,
|
||||
QJsonObject& jsonObject,
|
||||
QStringList& channelSettingsKeys)
|
||||
{
|
||||
if (jsonObject.contains("tx")) {
|
||||
channelSettings.setTx(jsonObject["tx"].toInt());
|
||||
@ -1448,6 +1453,7 @@ bool WebAPIRequestMapper::validateChannelSettings(SWGSDRangel::SWGChannelSetting
|
||||
if (channelSettings.getTx() == 0)
|
||||
{
|
||||
QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject();
|
||||
channelSettingsKeys = nfmDemodSettingsJsonObject.keys();
|
||||
channelSettings.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
|
||||
channelSettings.getNfmDemodSettings()->fromJsonObject(nfmDemodSettingsJsonObject);
|
||||
return true;
|
||||
@ -1461,6 +1467,7 @@ bool WebAPIRequestMapper::validateChannelSettings(SWGSDRangel::SWGChannelSetting
|
||||
if (channelSettings.getTx() != 0)
|
||||
{
|
||||
QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject();
|
||||
channelSettingsKeys = nfmModSettingsJsonObject.keys();
|
||||
channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
|
||||
channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject);
|
||||
return true;
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
|
||||
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
|
||||
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject);
|
||||
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject);
|
||||
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
|
||||
|
||||
bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);
|
||||
|
||||
|
@ -720,6 +720,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsGet(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -781,6 +782,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -815,6 +817,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunGet(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -849,6 +852,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunPost(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -883,6 +887,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunDelete(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -1102,6 +1107,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
@ -1115,11 +1121,12 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
bool force,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size()))
|
||||
{
|
||||
@ -1142,7 +1149,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
|
||||
|
||||
if (channelType == *response.getChannelType())
|
||||
{
|
||||
return channelAPI->webapiSettingsPutPatch(force, response, *error.getMessage());
|
||||
return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1172,7 +1179,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
|
||||
|
||||
if (channelType == *response.getChannelType())
|
||||
{
|
||||
return channelAPI->webapiSettingsPutPatch(force, response, *error.getMessage());
|
||||
return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1187,6 +1194,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
|
@ -168,6 +168,7 @@ public:
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
@ -1082,6 +1082,156 @@ int WebAPIAdapterSrv::devicesetChannelDelete(
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::devicesetChannelSettingsGet(
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||
{
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if (deviceSet->m_deviceSourceEngine) // Rx
|
||||
{
|
||||
ChannelSinkAPI *channelAPI = deviceSet->m_deviceSourceAPI->getChanelAPIAt(channelIndex);
|
||||
|
||||
if (channelAPI == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||
return 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setChannelType(new QString());
|
||||
channelAPI->getIdentifier(*response.getChannelType());
|
||||
response.setTx(0);
|
||||
return channelAPI->webapiSettingsGet(response, *error.getMessage());
|
||||
}
|
||||
}
|
||||
else if (deviceSet->m_deviceSinkEngine) // Tx
|
||||
{
|
||||
ChannelSourceAPI *channelAPI = deviceSet->m_deviceSinkAPI->getChanelAPIAt(channelIndex);
|
||||
|
||||
if (channelAPI == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||
return 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setChannelType(new QString());
|
||||
channelAPI->getIdentifier(*response.getChannelType());
|
||||
response.setTx(1);
|
||||
return channelAPI->webapiSettingsGet(response, *error.getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::devicesetChannelSettingsPutPatch(
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainCore.m_deviceSets.size()))
|
||||
{
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if (deviceSet->m_deviceSourceEngine) // Rx
|
||||
{
|
||||
ChannelSinkAPI *channelAPI = deviceSet->m_deviceSourceAPI->getChanelAPIAt(channelIndex);
|
||||
|
||||
if (channelAPI == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||
return 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString channelType;
|
||||
channelAPI->getIdentifier(channelType);
|
||||
|
||||
if (channelType == *response.getChannelType())
|
||||
{
|
||||
return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.")
|
||||
.arg(*response.getChannelType())
|
||||
.arg(channelIndex)
|
||||
.arg(channelType);
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (deviceSet->m_deviceSinkEngine) // Tx
|
||||
{
|
||||
ChannelSourceAPI *channelAPI = deviceSet->m_deviceSinkAPI->getChanelAPIAt(channelIndex);
|
||||
|
||||
if (channelAPI == 0)
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
|
||||
return 404;
|
||||
}
|
||||
else
|
||||
{
|
||||
QString channelType;
|
||||
channelAPI->getIdentifier(channelType);
|
||||
|
||||
if (channelType == *response.getChannelType())
|
||||
{
|
||||
return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.")
|
||||
.arg(*response.getChannelType())
|
||||
.arg(channelIndex)
|
||||
.arg(channelType);
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("DeviceSet error");
|
||||
return 500;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||
|
||||
return 404;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
|
||||
{
|
||||
deviceSetList->init();
|
||||
|
@ -158,6 +158,20 @@ public:
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int devicesetChannelSettingsGet(
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int devicesetChannelSettingsPutPatch(
|
||||
int deviceSetIndex,
|
||||
int channelIndex,
|
||||
bool force,
|
||||
const QStringList& channelSettingsKeys,
|
||||
SWGSDRangel::SWGChannelSettings& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
private:
|
||||
MainCore& m_mainCore;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user