mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-27 15:26:33 -04:00
Web API: /sdrangel/deviceset/{deviceSetIndex}/device/settings PUT,PATCH RtlSdr (1)
This commit is contained in:
parent
a041f827b4
commit
34cb4aa89b
@ -287,10 +287,11 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
{
|
{
|
||||||
if (rtlsdr_set_agc_mode(m_dev, settings.m_agc ? 1 : 0) < 0)
|
if (rtlsdr_set_agc_mode(m_dev, settings.m_agc ? 1 : 0) < 0)
|
||||||
{
|
{
|
||||||
qCritical("could not set AGC mode %s", settings.m_agc ? "on" : "off");
|
qCritical("RTLSDRInput::applySettings: could not set AGC mode %s", settings.m_agc ? "on" : "off");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qDebug("RTLSDRInput::applySettings: AGC mode %s", settings.m_agc ? "on" : "off");
|
||||||
m_settings.m_agc = settings.m_agc;
|
m_settings.m_agc = settings.m_agc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,9 +302,13 @@ bool RTLSDRInput::applySettings(const RTLSDRSettings& settings, bool force)
|
|||||||
|
|
||||||
if(m_dev != 0)
|
if(m_dev != 0)
|
||||||
{
|
{
|
||||||
if(rtlsdr_set_tuner_gain(m_dev, m_settings.m_gain) != 0)
|
if (rtlsdr_set_tuner_gain(m_dev, m_settings.m_gain) != 0)
|
||||||
{
|
{
|
||||||
qDebug("rtlsdr_set_tuner_gain() failed");
|
qCritical("RTLSDRInput::applySettings: rtlsdr_set_tuner_gain() failed");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("RTLSDRInput::applySettings: rtlsdr_set_tuner_gain() to %d", m_settings.m_gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -491,7 +496,7 @@ int RTLSDRInput::webapiSettingsGet(
|
|||||||
int RTLSDRInput::webapiSettingsPutPatch(
|
int RTLSDRInput::webapiSettingsPutPatch(
|
||||||
bool force,
|
bool force,
|
||||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||||
QString& errorMessage)
|
QString& errorMessage __attribute__((unused)))
|
||||||
{
|
{
|
||||||
RTLSDRSettings settings;
|
RTLSDRSettings settings;
|
||||||
settings.m_agc = response.getRtlSdrSettings()->getAgc() != 0;
|
settings.m_agc = response.getRtlSdrSettings()->getAgc() != 0;
|
||||||
@ -508,19 +513,14 @@ int RTLSDRInput::webapiSettingsPutPatch(
|
|||||||
settings.m_transverterDeltaFrequency = response.getRtlSdrSettings()->getTransverterDeltaFrequency();
|
settings.m_transverterDeltaFrequency = response.getRtlSdrSettings()->getTransverterDeltaFrequency();
|
||||||
settings.m_transverterMode = response.getRtlSdrSettings()->getTransverterMode() != 0;
|
settings.m_transverterMode = response.getRtlSdrSettings()->getTransverterMode() != 0;
|
||||||
|
|
||||||
if (applySettings(settings, force))
|
MsgConfigureRTLSDR *msg = MsgConfigureRTLSDR::create(settings, force);
|
||||||
{
|
m_inputMessageQueue.push(msg);
|
||||||
if (m_guiMessageQueue) // forward to GUI if any
|
|
||||||
{
|
|
||||||
MsgConfigureRTLSDR *msg = MsgConfigureRTLSDR::create(settings, force);
|
|
||||||
m_guiMessageQueue->push(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 200;
|
if (m_guiMessageQueue) // forward to GUI if any
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
errorMessage = "RTLSDRInput::webapiSettingsPutPatch: error applying settings";
|
MsgConfigureRTLSDR *msgToGUI = MsgConfigureRTLSDR::create(settings, force);
|
||||||
return 500;
|
m_guiMessageQueue->push(msgToGUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 200;
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
|
|||||||
deviceSettings.setTx(0); // assume Rx
|
deviceSettings.setTx(0); // assume Rx
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("deviceHwType")) {
|
if (jsonObject.contains("deviceHwType") && jsonObject["deviceHwType"].isString()) {
|
||||||
deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString()));
|
deviceSettings.setDeviceHwType(new QString(jsonObject["deviceHwType"].toString()));
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -766,21 +766,65 @@ bool WebAPIRequestMapper::validateDeviceSettings(SWGSDRangel::SWGDeviceSettings&
|
|||||||
|
|
||||||
QString *deviceHwType = deviceSettings.getDeviceHwType();
|
QString *deviceHwType = deviceSettings.getDeviceHwType();
|
||||||
|
|
||||||
if (*deviceHwType == "FileSource") {
|
if (*deviceHwType == "FileSource")
|
||||||
if (jsonObject.contains("fileSourceSettings")) {
|
{
|
||||||
|
if (jsonObject.contains("fileSourceSettings") && jsonObject["fileSourceSettings"].isObject())
|
||||||
|
{
|
||||||
|
QJsonObject fileSourceSettingsJsonObject = jsonObject["fileSourceSettings"].toObject();
|
||||||
deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
|
deviceSettings.setFileSourceSettings(new SWGSDRangel::SWGFileSourceSettings());
|
||||||
|
deviceSettings.getFileSourceSettings()->fromJsonObject(fileSourceSettingsJsonObject);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (*deviceHwType == "RTLSDR") {
|
}
|
||||||
return deviceSettings.getRtlSdrSettings() != 0;
|
else if (*deviceHwType == "RTLSDR")
|
||||||
} else if (*deviceHwType == "LimeSDR") {
|
{
|
||||||
if (deviceSettings.getTx() == 0) {
|
if (jsonObject.contains("rtlSdrSettings") && jsonObject["rtlSdrSettings"].isObject())
|
||||||
return deviceSettings.getLimeSdrInputSettings() != 0;
|
{
|
||||||
} else {
|
QJsonObject rtlSdrSettingsJsonObject = jsonObject["rtlSdrSettings"].toObject();
|
||||||
return deviceSettings.getLimeSdrOutputSettings() != 0;
|
deviceSettings.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
|
||||||
|
deviceSettings.getRtlSdrSettings()->fromJsonObject(rtlSdrSettingsJsonObject);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getTx() == 0))
|
||||||
|
{
|
||||||
|
if (jsonObject.contains("limeSdrInputSettings") && jsonObject["limeSdrInputSettings"].isObject())
|
||||||
|
{
|
||||||
|
QJsonObject limeSdrInputSettingsJsonObject = jsonObject["limeSdrInputSettings"].toObject();
|
||||||
|
deviceSettings.setLimeSdrInputSettings(new SWGSDRangel::SWGLimeSdrInputSettings());
|
||||||
|
deviceSettings.getLimeSdrInputSettings()->fromJsonObject(limeSdrInputSettingsJsonObject);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((*deviceHwType == "LimeSDR") && (deviceSettings.getTx() != 0))
|
||||||
|
{
|
||||||
|
if (jsonObject.contains("limeSdrOutputSettings") && jsonObject["limeSdrOutputSettings"].isObject())
|
||||||
|
{
|
||||||
|
QJsonObject limeSdrOutputSettingsJsonObject = jsonObject["limeSdrOutputSettings"].toObject();
|
||||||
|
deviceSettings.setLimeSdrOutputSettings(new SWGSDRangel::SWGLimeSdrOutputSettings());
|
||||||
|
deviceSettings.getLimeSdrOutputSettings()->fromJsonObject(limeSdrOutputSettingsJsonObject);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import requests, json
|
import requests, json
|
||||||
|
|
||||||
base_url = "http://10.0.2.2:8091/sdrangel"
|
base_url = "http://127.0.0.1:8888/sdrangel"
|
||||||
|
|
||||||
requests_methods = {
|
requests_methods = {
|
||||||
"GET": requests.get,
|
"GET": requests.get,
|
||||||
@ -66,4 +66,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user