mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-03 13:11:20 -05:00 
			
		
		
		
	Web API: have /sdrangel/deviceset/{deviceSetIndex}/device/settings PUT,PATCH (3)
This commit is contained in:
		
							parent
							
								
									2cf797a0a2
								
							
						
					
					
						commit
						a041f827b4
					
				@ -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,16 +752,27 @@ 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") {
 | 
					    if (*deviceHwType == "FileSource") {
 | 
				
			||||||
            return deviceSettings.getFileSourceSettings() != 0;
 | 
					        if (jsonObject.contains("fileSourceSettings")) {
 | 
				
			||||||
 | 
					            deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    } else if (*deviceHwType == "RTLSDR") {
 | 
					    } else if (*deviceHwType == "RTLSDR") {
 | 
				
			||||||
        return deviceSettings.getRtlSdrSettings() != 0;
 | 
					        return deviceSettings.getRtlSdrSettings() != 0;
 | 
				
			||||||
    } else if (*deviceHwType == "LimeSDR") {
 | 
					    } else if (*deviceHwType == "LimeSDR") {
 | 
				
			||||||
@ -773,7 +783,6 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings)
 | 
					void WebAPIRequestMapper::resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user