mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 06:54:39 -04:00
Server: Web API: implemented /sdrangel/preset (PUT)
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include "SWGPresetImport.h"
|
||||
#include "SWGPresetExport.h"
|
||||
#include "SWGPresets.h"
|
||||
#include "SWGPresetTransfer.h"
|
||||
#include "SWGSuccessResponse.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
|
||||
@@ -484,6 +485,60 @@ int WebAPIAdapterSrv::instancePresetGet(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instancePresetPatch(
|
||||
SWGSDRangel::SWGPresetTransfer& query,
|
||||
SWGSDRangel::SWGPresetIdentifier& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
int deviceSetIndex = query.getDeviceSetIndex();
|
||||
SWGSDRangel::SWGPresetIdentifier *presetIdentifier = query.getPreset();
|
||||
int nbDeviceSets = m_mainCore.m_deviceSets.size();
|
||||
|
||||
if (deviceSetIndex >= nbDeviceSets)
|
||||
{
|
||||
*error.getMessage() = QString("There is no device set at index %1. Number of device sets is %2").arg(deviceSetIndex).arg(nbDeviceSets);
|
||||
return 404;
|
||||
}
|
||||
|
||||
const Preset *selectedPreset = m_mainCore.m_settings.getPreset(*presetIdentifier->getGroupName(),
|
||||
presetIdentifier->getCenterFrequency(),
|
||||
*presetIdentifier->getName());
|
||||
|
||||
if (selectedPreset == 0)
|
||||
{
|
||||
*error.getMessage() = QString("There is no preset [%1, %2, %3]")
|
||||
.arg(*presetIdentifier->getGroupName())
|
||||
.arg(presetIdentifier->getCenterFrequency())
|
||||
.arg(*presetIdentifier->getName());
|
||||
return 404;
|
||||
}
|
||||
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if (deviceSet->m_deviceSourceEngine && !selectedPreset->isSourcePreset())
|
||||
{
|
||||
*error.getMessage() = QString("Preset type (T) and device set type (Rx) mismatch");
|
||||
return 404;
|
||||
}
|
||||
|
||||
if (deviceSet->m_deviceSinkEngine && selectedPreset->isSourcePreset())
|
||||
{
|
||||
*error.getMessage() = QString("Preset type (R) and device set type (Tx) mismatch");
|
||||
return 404;
|
||||
}
|
||||
|
||||
MainCore::MsgLoadPreset *msg = MainCore::MsgLoadPreset::create(selectedPreset, deviceSetIndex);
|
||||
m_mainCore.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
response.setCenterFrequency(selectedPreset->getCenterFrequency());
|
||||
*response.getGroupName() = selectedPreset->getGroup();
|
||||
*response.getType() = selectedPreset->isSourcePreset() ? "R" : "T";
|
||||
*response.getName() = selectedPreset->getDescription();
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDeviceSetsPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
|
||||
Reference in New Issue
Block a user