1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-02-03 09:44:01 -05:00

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

This commit is contained in:
f4exb 2017-12-07 22:38:39 +01:00
parent 2cf797a0a2
commit a041f827b4

View File

@ -643,10 +643,9 @@ void WebAPIRequestMapper::devicesetDeviceSettingsService(const std::string& inde
if (parseJsonBody(jsonStr, jsonObject, response)) if (parseJsonBody(jsonStr, jsonObject, response))
{ {
SWGSDRangel::SWGDeviceSettings normalResponse; SWGSDRangel::SWGDeviceSettings normalResponse;
//resetDeviceSettings(normalResponse); resetDeviceSettings(normalResponse);
normalResponse.fromJson(jsonStr);
if (validateDeviceSettings(normalResponse)) if (validateDeviceSettings(normalResponse, jsonObject))
{ {
int status = m_adapter->devicesetDeviceSettingsPutPatch( int status = m_adapter->devicesetDeviceSettingsPutPatch(
deviceSetIndex, deviceSetIndex,
@ -753,24 +752,34 @@ bool WebAPIRequestMapper::validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifi
bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject) bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject)
{ {
QString *deviceHwType = deviceSettings.getDeviceHwType(); if (jsonObject.contains("tx")) {
deviceSettings.setTx(jsonObject["tx"].toInt());
} else {
deviceSettings.setTx(0); // assume Rx
}
if (deviceHwType == 0) if (jsonObject.contains("deviceHwType")) {
{ deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString()));
} else {
return false; return false;
} }
else
{ QString *deviceHwType = deviceSettings.getDeviceHwType();
if (*deviceHwType == "FileSource") {
return deviceSettings.getFileSourceSettings() != 0; if (*deviceHwType == "FileSource") {
} else if (*deviceHwType == "RTLSDR") { if (jsonObject.contains("fileSourceSettings")) {
return deviceSettings.getRtlSdrSettings() != 0; deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
} else if (*deviceHwType == "LimeSDR") { return true;
if (deviceSettings.getTx() == 0) { } else {
return deviceSettings.getLimeSdrInputSettings() != 0; return false;
} else { }
return deviceSettings.getLimeSdrOutputSettings() != 0; } else if (*deviceHwType == "RTLSDR") {
} return deviceSettings.getRtlSdrSettings() != 0;
} else if (*deviceHwType == "LimeSDR") {
if (deviceSettings.getTx() == 0) {
return deviceSettings.getLimeSdrInputSettings() != 0;
} else {
return deviceSettings.getLimeSdrOutputSettings() != 0;
} }
} }
} }