1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 14:04:46 -04:00

Web API: have /sdrangel/deviceset/{deviceSetIndex}/device/settings PUT,PATCH (1)

This commit is contained in:
f4exb
2017-12-07 13:55:42 +01:00
parent 3b69d6517b
commit c38497d9df
8 changed files with 131 additions and 16 deletions
+51
View File
@@ -732,6 +732,57 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsGet(
}
}
int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
int deviceSetIndex,
bool force,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size()))
{
DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex];
if (deviceSet->m_deviceSourceEngine) // Rx
{
if ((response.getTx() != 0) || (deviceSet->m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType()))
{
*error.getMessage() = QString("Device mismatch. Found %1 input").arg(deviceSet->m_deviceSourceAPI->getHardwareId());
return 400;
}
else
{
DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsPutPatch(force, response, *error.getMessage());
}
}
else if (deviceSet->m_deviceSinkEngine) // Tx
{
if ((response.getTx() == 0) || (deviceSet->m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType()))
{
*error.getMessage() = QString("Device mismatch. Found %1 output").arg(deviceSet->m_deviceSourceAPI->getHardwareId());
return 400;
}
else
{
DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsPutPatch(force, response, *error.getMessage());
}
}
else
{
*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 WebAPIAdapterGUI::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
{
deviceSetList->init();