SDRdaemon: Web API: implemented daemonSettingsPutPatch

pull/228/head
f4exb 2018-08-19 19:58:14 +02:00
rodzic dcfb405dd5
commit 1d968e9efa
1 zmienionych plików z 46 dodań i 3 usunięć

Wyświetl plik

@ -202,12 +202,55 @@ int WebAPIAdapterDaemon::daemonSettingsGet(
}
int WebAPIAdapterDaemon::daemonSettingsPutPatch(
bool force __attribute__((unused)),
const QStringList& deviceSettingsKeys __attribute__((unused)),
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
bool force,
const QStringList& deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings& response,
SWGSDRangel::SWGErrorResponse& error)
{
error.init();
if (m_sdrDaemonMain.m_deviceSourceEngine) // Rx
{
if (response.getTx() != 0)
{
*error.getMessage() = QString("Rx device found but Tx device requested");
return 400;
}
if (m_sdrDaemonMain.m_deviceSourceAPI->getHardwareId() != *response.getDeviceHwType())
{
*error.getMessage() = QString("Device mismatch. Found %1 input").arg(m_sdrDaemonMain.m_deviceSourceAPI->getHardwareId());
return 400;
}
else
{
DeviceSampleSource *source = m_sdrDaemonMain.m_deviceSourceAPI->getSampleSource();
return source->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else if (m_sdrDaemonMain.m_deviceSinkEngine) // Tx
{
if (response.getTx() == 0)
{
*error.getMessage() = QString("Tx device found but Rx device requested");
return 400;
}
else if (m_sdrDaemonMain.m_deviceSinkAPI->getHardwareId() != *response.getDeviceHwType())
{
*error.getMessage() = QString("Device mismatch. Found %1 output").arg(m_sdrDaemonMain.m_deviceSinkAPI->getHardwareId());
return 400;
}
else
{
DeviceSampleSink *sink = m_sdrDaemonMain.m_deviceSinkAPI->getSampleSink();
return sink->webapiSettingsPutPatch(force, deviceSettingsKeys, response, *error.getMessage());
}
}
else
{
*error.getMessage() = QString("DeviceSet error");
return 500;
}
*error.getMessage() = "Not implemented";
return 501;
}