1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 20:31:53 -05:00

Server: Web API: /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/settings PUT, PATCH with all settings parameters optional

This commit is contained in:
f4exb 2017-12-24 03:27:07 +01:00
parent ead034e21d
commit bf6607044a
13 changed files with 304 additions and 47 deletions

View File

@ -361,6 +361,8 @@ bool NFMDemod::handleMessage(const Message& cmd)
settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset; settings.m_inputFrequencyOffset = m_settings.m_inputFrequencyOffset;
qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod:" qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod:"
<< " m_absoluteFrequencyOffset: " << m_absoluteFrequencyOffset
<< " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset
<< " m_rfBandwidth: " << settings.m_rfBandwidth << " m_rfBandwidth: " << settings.m_rfBandwidth
<< " m_afBandwidth: " << settings.m_afBandwidth << " m_afBandwidth: " << settings.m_afBandwidth
<< " m_fmDeviation: " << settings.m_fmDeviation << " m_fmDeviation: " << settings.m_fmDeviation
@ -486,51 +488,84 @@ int NFMDemod::webapiSettingsGet(
QString& errorMessage __attribute__((unused))) QString& errorMessage __attribute__((unused)))
{ {
response.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings()); response.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
response.getNfmDemodSettings()->setAfBandwidth(m_settings.m_afBandwidth); NFMDemodSettings settings = m_settings;
response.getNfmDemodSettings()->setAudioMute(m_settings.m_audioMute ? 1 : 0); settings.m_inputFrequencyOffset = m_absoluteFrequencyOffset;
response.getNfmDemodSettings()->setAudioSampleRate(m_settings.m_audioSampleRate); webapiFormatChannelSettings(response, settings);
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);
return 200; return 200;
} }
int NFMDemod::webapiSettingsPutPatch( int NFMDemod::webapiSettingsPutPatch(
bool force, bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage __attribute__((unused))) QString& errorMessage __attribute__((unused)))
{ {
NFMDemodSettings settings; NFMDemodSettings settings = m_settings;
settings.m_afBandwidth = response.getNfmDemodSettings()->getAfBandwidth(); bool frequencyOffsetChanged;
settings.m_audioMute = response.getNfmDemodSettings()->getAudioMute() != 0;
settings.m_audioSampleRate = response.getNfmDemodSettings()->getAudioSampleRate(); if (channelSettingsKeys.contains("afBandwidth")) {
settings.m_copyAudioToUDP = response.getNfmDemodSettings()->getCopyAudioToUdp() != 0; settings.m_afBandwidth = response.getNfmDemodSettings()->getAfBandwidth();
settings.m_ctcssIndex = response.getNfmDemodSettings()->getCtcssIndex(); }
settings.m_ctcssOn = response.getNfmDemodSettings()->getCtcssOn() != 0; if (channelSettingsKeys.contains("audioMute")) {
settings.m_deltaSquelch = response.getNfmDemodSettings()->getDeltaSquelch() != 0; settings.m_audioMute = response.getNfmDemodSettings()->getAudioMute() != 0;
settings.m_fmDeviation = response.getNfmDemodSettings()->getFmDeviation(); }
settings.m_inputFrequencyOffset = response.getNfmDemodSettings()->getInputFrequencyOffset(); if (channelSettingsKeys.contains("audioSampleRate")) {
settings.m_inputSampleRate = response.getNfmDemodSettings()->getInputSampleRate(); settings.m_audioSampleRate = response.getNfmDemodSettings()->getAudioSampleRate();
settings.m_rfBandwidth = response.getNfmDemodSettings()->getRfBandwidth(); }
settings.m_rgbColor = response.getNfmDemodSettings()->getRgbColor(); if (channelSettingsKeys.contains("copyAudioToUDP")) {
settings.m_squelch = response.getNfmDemodSettings()->getSquelch(); settings.m_copyAudioToUDP = response.getNfmDemodSettings()->getCopyAudioToUdp() != 0;
settings.m_squelchGate = response.getNfmDemodSettings()->getSquelchGate(); }
settings.m_title = *response.getNfmDemodSettings()->getTitle(); if (channelSettingsKeys.contains("ctcssIndex")) {
settings.m_udpAddress = *response.getNfmDemodSettings()->getUdpAddress(); settings.m_ctcssIndex = response.getNfmDemodSettings()->getCtcssIndex();
settings.m_udpPort = response.getNfmDemodSettings()->getUdpPort(); }
settings.m_volume = response.getNfmDemodSettings()->getVolume(); 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); MsgConfigureNFMDemod *msg = MsgConfigureNFMDemod::create(settings, force);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
@ -541,5 +576,40 @@ int NFMDemod::webapiSettingsPutPatch(
m_guiMessageQueue->push(msgToGUI); m_guiMessageQueue->push(msgToGUI);
} }
webapiFormatChannelSettings(response, settings);
return 200; 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));
}
}

View File

@ -132,6 +132,7 @@ public:
virtual int webapiSettingsPutPatch( virtual int webapiSettingsPutPatch(
bool force, bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage); QString& errorMessage);
@ -221,6 +222,7 @@ private:
// void apply(bool force = false); // void apply(bool force = false);
void applySettings(const NFMDemodSettings& settings, bool force = false); void applySettings(const NFMDemodSettings& settings, bool force = false);
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings);
}; };
#endif // INCLUDE_NFMDEMOD_H #endif // INCLUDE_NFMDEMOD_H

View File

@ -532,6 +532,7 @@ int NFMMod::webapiSettingsGet(
int NFMMod::webapiSettingsPutPatch( int NFMMod::webapiSettingsPutPatch(
bool force, bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage __attribute__((unused))) QString& errorMessage __attribute__((unused)))
{ {

View File

@ -254,6 +254,7 @@ public:
virtual int webapiSettingsPutPatch( virtual int webapiSettingsPutPatch(
bool force, bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage); QString& errorMessage);

View File

@ -53,6 +53,7 @@ public:
virtual int webapiSettingsPutPatch( virtual int webapiSettingsPutPatch(
bool force __attribute__((unused)), bool force __attribute__((unused)),
const QStringList& channelSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)), SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
QString& errorMessage) QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }

View File

@ -52,6 +52,7 @@ public:
virtual int webapiSettingsPutPatch( virtual int webapiSettingsPutPatch(
bool force __attribute__((unused)), bool force __attribute__((unused)),
const QStringList& channelSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)), SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
QString& errorMessage) QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; } { errorMessage = "Not implemented"; return 501; }

View File

@ -487,6 +487,7 @@ public:
int deviceSetIndex __attribute__((unused)), int deviceSetIndex __attribute__((unused)),
int channelIndex __attribute__((unused)), int channelIndex __attribute__((unused)),
bool force __attribute__((unused)), bool force __attribute__((unused)),
const QStringList& channelSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGChannelSettings& response __attribute__((unused)), SWGSDRangel::SWGChannelSettings& response __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error) SWGSDRangel::SWGErrorResponse& error)
{ {

View File

@ -1175,13 +1175,15 @@ void WebAPIRequestMapper::devicesetChannelSettingsService(
{ {
SWGSDRangel::SWGChannelSettings normalResponse; SWGSDRangel::SWGChannelSettings normalResponse;
resetChannelSettings(normalResponse); resetChannelSettings(normalResponse);
QStringList channelSettingsKeys;
if (validateChannelSettings(normalResponse, jsonObject)) if (validateChannelSettings(normalResponse, jsonObject, channelSettingsKeys))
{ {
int status = m_adapter->devicesetChannelSettingsPutPatch( int status = m_adapter->devicesetChannelSettingsPutPatch(
deviceSetIndex, deviceSetIndex,
channelIndex, channelIndex,
(request.getMethod() == "PUT"), // force settings on PUT (request.getMethod() == "PUT"), // force settings on PUT
channelSettingsKeys,
normalResponse, normalResponse,
errorResponse); errorResponse);
response.setStatus(status); 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")) { if (jsonObject.contains("tx")) {
channelSettings.setTx(jsonObject["tx"].toInt()); channelSettings.setTx(jsonObject["tx"].toInt());
@ -1448,6 +1453,7 @@ bool WebAPIRequestMapper::validateChannelSettings(SWGSDRangel::SWGChannelSetting
if (channelSettings.getTx() == 0) if (channelSettings.getTx() == 0)
{ {
QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject(); QJsonObject nfmDemodSettingsJsonObject = jsonObject["NFMDemodSettings"].toObject();
channelSettingsKeys = nfmDemodSettingsJsonObject.keys();
channelSettings.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings()); channelSettings.setNfmDemodSettings(new SWGSDRangel::SWGNFMDemodSettings());
channelSettings.getNfmDemodSettings()->fromJsonObject(nfmDemodSettingsJsonObject); channelSettings.getNfmDemodSettings()->fromJsonObject(nfmDemodSettingsJsonObject);
return true; return true;
@ -1461,6 +1467,7 @@ bool WebAPIRequestMapper::validateChannelSettings(SWGSDRangel::SWGChannelSetting
if (channelSettings.getTx() != 0) if (channelSettings.getTx() != 0)
{ {
QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject(); QJsonObject nfmModSettingsJsonObject = jsonObject["NFMModSettings"].toObject();
channelSettingsKeys = nfmModSettingsJsonObject.keys();
channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings()); channelSettings.setNfmModSettings(new SWGSDRangel::SWGNFMModSettings());
channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject); channelSettings.getNfmModSettings()->fromJsonObject(nfmModSettingsJsonObject);
return true; return true;

View File

@ -71,7 +71,7 @@ private:
bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport); bool validatePresetExport(SWGSDRangel::SWGPresetExport& presetExport);
bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject); bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject);
bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, 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); bool parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response);

View File

@ -720,6 +720,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsGet(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -781,6 +782,7 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -815,6 +817,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunGet(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -849,6 +852,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunPost(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -883,6 +887,7 @@ int WebAPIAdapterGUI::devicesetDeviceRunDelete(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -1102,6 +1107,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }
@ -1115,11 +1121,12 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
} }
int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
int deviceSetIndex, int deviceSetIndex,
int channelIndex, int channelIndex,
bool force, bool force,
SWGSDRangel::SWGChannelSettings& response, const QStringList& channelSettingsKeys,
SWGSDRangel::SWGErrorResponse& error) SWGSDRangel::SWGChannelSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{ {
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size())) if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size()))
{ {
@ -1142,7 +1149,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
if (channelType == *response.getChannelType()) if (channelType == *response.getChannelType())
{ {
return channelAPI->webapiSettingsPutPatch(force, response, *error.getMessage()); return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
} }
else else
{ {
@ -1172,7 +1179,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
if (channelType == *response.getChannelType()) if (channelType == *response.getChannelType())
{ {
return channelAPI->webapiSettingsPutPatch(force, response, *error.getMessage()); return channelAPI->webapiSettingsPutPatch(force, channelSettingsKeys, response, *error.getMessage());
} }
else else
{ {
@ -1187,6 +1194,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
} }
else else
{ {
error.init();
*error.getMessage() = QString("DeviceSet error"); *error.getMessage() = QString("DeviceSet error");
return 500; return 500;
} }

View File

@ -168,6 +168,7 @@ public:
int deviceSetIndex, int deviceSetIndex,
int channelIndex, int channelIndex,
bool force, bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGChannelSettings& response,
SWGSDRangel::SWGErrorResponse& error); SWGSDRangel::SWGErrorResponse& error);

View File

@ -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) void WebAPIAdapterSrv::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
{ {
deviceSetList->init(); deviceSetList->init();

View File

@ -158,6 +158,20 @@ public:
SWGSDRangel::SWGSuccessResponse& response, SWGSDRangel::SWGSuccessResponse& response,
SWGSDRangel::SWGErrorResponse& error); 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: private:
MainCore& m_mainCore; MainCore& m_mainCore;