From c9219ec8ea0d06737aeec0dc7de310b06c5e70d0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 29 Dec 2019 06:03:37 +0100 Subject: [PATCH] REST API: TestMOSyncSettings and BladeRF2MIMOSettings handling --- .../doc/swagger/include/DeviceSettings.yaml | 2 ++ sdrbase/webapi/webapirequestmapper.cpp | 26 +++++++++++++++++-- .../api/swagger/include/DeviceSettings.yaml | 2 ++ .../code/qt5/client/SWGDeviceSettings.cpp | 25 ++++++++++++++++++ .../code/qt5/client/SWGDeviceSettings.h | 7 +++++ .../code/qt5/client/SWGModelFactory.h | 4 +++ .../code/qt5/client/SWGTestMOSyncSettings.cpp | 2 +- .../code/qt5/client/SWGTestMOSyncSettings.h | 2 +- 8 files changed, 66 insertions(+), 4 deletions(-) diff --git a/sdrbase/resources/webapi/doc/swagger/include/DeviceSettings.yaml b/sdrbase/resources/webapi/doc/swagger/include/DeviceSettings.yaml index 61bc48dab..faef35a6f 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/DeviceSettings.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/DeviceSettings.yaml @@ -70,6 +70,8 @@ DeviceSettings: $ref: "/doc/swagger/include/TestSource.yaml#/TestSourceSettings" testMISettings: $ref: "/doc/swagger/include/TestMI.yaml#/TestMISettings" + testMOSyncSettings: + $ref: "/doc/swagger/include/TestMOSync.yaml#/TestMOSyncSettings" xtrxInputSettings: $ref: "/doc/swagger/include/Xtrx.yaml#/XtrxInputSettings" xtrxOutputSettings: diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index f7952bf45..ddefc69fe 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -94,6 +94,7 @@ const QMap WebAPIRequestMapper::m_deviceIdToSettingsKey = { {"sdrangel.samplesource.bladerf2input", "bladeRF2InputSettings"}, {"sdrangel.samplesink.bladerf2output", "bladeRF2OutputSettings"}, {"sdrangel.samplesource.bladerf2output", "bladeRF2OutputSettings"}, // remap + {"sdrangel.samplemimo.bladerf2mimo", "bladeRF2MIMOSettings"}, {"sdrangel.samplesource.fcdpro", "fcdProSettings"}, {"sdrangel.samplesource.fcdproplus", "fcdProPlusSettings"}, {"sdrangel.samplesource.fileinput", "fileInputSettings"}, @@ -118,6 +119,7 @@ const QMap WebAPIRequestMapper::m_deviceIdToSettingsKey = { {"sdrangel.samplesink.soapysdroutput", "soapySDROutputSettings"}, {"sdrangel.samplesource.testsource", "testSourceSettings"}, {"sdrangel.samplemimo.testmi", "testMISettings"}, + {"sdrangel.samplemimo.testmosync", "testMOSyncSettings"}, {"sdrangel.samplesource.xtrx", "XtrxInputSettings"}, {"sdrangel.samplesink.xtrx", "XtrxOutputSettings"} }; @@ -184,7 +186,9 @@ const QMap WebAPIRequestMapper::m_sinkDeviceHwIdToSettingsKey }; const QMap WebAPIRequestMapper::m_mimoDeviceHwIdToSettingsKey= { - {"TestMI", "testMISettings"} + {"BladeRF2", "BladeRF2MIMOSettings"}, + {"TestMI", "testMISettings"}, + {"TestMOSync", "TestMOSyncSettings"} }; WebAPIRequestMapper::WebAPIRequestMapper(QObject* parent) : @@ -2737,11 +2741,20 @@ bool WebAPIRequestMapper::getDevice( deviceSettings->setBladeRf2InputSettings(new SWGSDRangel::SWGBladeRF2InputSettings()); deviceSettings->getBladeRf2InputSettings()->fromJsonObject(settingsJsonObject); } - else if (deviceSettingsKey == "bladeRF2InputSettings") + else if (deviceSettingsKey == "bladeRF2OutputSettings") { deviceSettings->setBladeRf2OutputSettings(new SWGSDRangel::SWGBladeRF2OutputSettings()); deviceSettings->getBladeRf2OutputSettings()->fromJsonObject(settingsJsonObject); } + else if (deviceSettingsKey == "bladeRF2MIMOSettings") + { + if (deviceSettingsKeys.contains("streams") && settingsJsonObject["streams"].isArray()) { + appendSettingsArrayKeys(settingsJsonObject, "streams", deviceSettingsKeys); + } + + deviceSettings->setBladeRf2MimoSettings(new SWGSDRangel::SWGBladeRF2MIMOSettings()); + deviceSettings->getBladeRf2MimoSettings()->fromJsonObject(settingsJsonObject); + } else if (deviceSettingsKey == "fcdProSettings") { deviceSettings->setFcdProSettings(new SWGSDRangel::SWGFCDProSettings()); @@ -2835,6 +2848,15 @@ bool WebAPIRequestMapper::getDevice( deviceSettings->setTestMiSettings(new SWGSDRangel::SWGTestMISettings()); deviceSettings->getTestMiSettings()->fromJsonObject(settingsJsonObject); } + else if (deviceSettingsKey == "TestMOSyncSettings") + { + if (deviceSettingsKeys.contains("streams") && settingsJsonObject["streams"].isArray()) { + appendSettingsArrayKeys(settingsJsonObject, "streams", deviceSettingsKeys); + } + + deviceSettings->setTestMoSyncSettings(new SWGSDRangel::SWGTestMOSyncSettings()); + deviceSettings->getTestMoSyncSettings()->fromJsonObject(settingsJsonObject); + } else if (deviceSettingsKey == "XtrxInputSettings") { deviceSettings->setXtrxInputSettings(new SWGSDRangel::SWGXtrxInputSettings()); diff --git a/swagger/sdrangel/api/swagger/include/DeviceSettings.yaml b/swagger/sdrangel/api/swagger/include/DeviceSettings.yaml index 550400585..ee9bdf8b1 100644 --- a/swagger/sdrangel/api/swagger/include/DeviceSettings.yaml +++ b/swagger/sdrangel/api/swagger/include/DeviceSettings.yaml @@ -70,6 +70,8 @@ DeviceSettings: $ref: "http://localhost:8081/api/swagger/include/TestSource.yaml#/TestSourceSettings" testMISettings: $ref: "http://localhost:8081/api/swagger/include/TestMI.yaml#/TestMISettings" + testMOSyncSettings: + $ref: "http://localhost:8081/api/swagger/include/TestMOSync.yaml#/TestMOSyncSettings" xtrxInputSettings: $ref: "http://localhost:8081/api/swagger/include/Xtrx.yaml#/XtrxInputSettings" xtrxOutputSettings: diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.cpp index 9596f43b8..9f44fdd80 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.cpp @@ -90,6 +90,8 @@ SWGDeviceSettings::SWGDeviceSettings() { m_test_source_settings_isSet = false; test_mi_settings = nullptr; m_test_mi_settings_isSet = false; + test_mo_sync_settings = nullptr; + m_test_mo_sync_settings_isSet = false; xtrx_input_settings = nullptr; m_xtrx_input_settings_isSet = false; xtrx_output_settings = nullptr; @@ -164,6 +166,8 @@ SWGDeviceSettings::init() { m_test_source_settings_isSet = false; test_mi_settings = new SWGTestMISettings(); m_test_mi_settings_isSet = false; + test_mo_sync_settings = new SWGTestMOSyncSettings(); + m_test_mo_sync_settings_isSet = false; xtrx_input_settings = new SWGXtrxInputSettings(); m_xtrx_input_settings_isSet = false; xtrx_output_settings = new SWGXtrxOutputSettings(); @@ -261,6 +265,9 @@ SWGDeviceSettings::cleanup() { if(test_mi_settings != nullptr) { delete test_mi_settings; } + if(test_mo_sync_settings != nullptr) { + delete test_mo_sync_settings; + } if(xtrx_input_settings != nullptr) { delete xtrx_input_settings; } @@ -342,6 +349,8 @@ SWGDeviceSettings::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&test_mi_settings, pJson["testMISettings"], "SWGTestMISettings", "SWGTestMISettings"); + ::SWGSDRangel::setValue(&test_mo_sync_settings, pJson["testMOSyncSettings"], "SWGTestMOSyncSettings", "SWGTestMOSyncSettings"); + ::SWGSDRangel::setValue(&xtrx_input_settings, pJson["xtrxInputSettings"], "SWGXtrxInputSettings", "SWGXtrxInputSettings"); ::SWGSDRangel::setValue(&xtrx_output_settings, pJson["xtrxOutputSettings"], "SWGXtrxOutputSettings", "SWGXtrxOutputSettings"); @@ -455,6 +464,9 @@ SWGDeviceSettings::asJsonObject() { if((test_mi_settings != nullptr) && (test_mi_settings->isSet())){ toJsonValue(QString("testMISettings"), test_mi_settings, obj, QString("SWGTestMISettings")); } + if((test_mo_sync_settings != nullptr) && (test_mo_sync_settings->isSet())){ + toJsonValue(QString("testMOSyncSettings"), test_mo_sync_settings, obj, QString("SWGTestMOSyncSettings")); + } if((xtrx_input_settings != nullptr) && (xtrx_input_settings->isSet())){ toJsonValue(QString("xtrxInputSettings"), xtrx_input_settings, obj, QString("SWGXtrxInputSettings")); } @@ -775,6 +787,16 @@ SWGDeviceSettings::setTestMiSettings(SWGTestMISettings* test_mi_settings) { this->m_test_mi_settings_isSet = true; } +SWGTestMOSyncSettings* +SWGDeviceSettings::getTestMoSyncSettings() { + return test_mo_sync_settings; +} +void +SWGDeviceSettings::setTestMoSyncSettings(SWGTestMOSyncSettings* test_mo_sync_settings) { + this->test_mo_sync_settings = test_mo_sync_settings; + this->m_test_mo_sync_settings_isSet = true; +} + SWGXtrxInputSettings* SWGDeviceSettings::getXtrxInputSettings() { return xtrx_input_settings; @@ -893,6 +915,9 @@ SWGDeviceSettings::isSet(){ if(test_mi_settings && test_mi_settings->isSet()){ isObjectUpdated = true; break; } + if(test_mo_sync_settings && test_mo_sync_settings->isSet()){ + isObjectUpdated = true; break; + } if(xtrx_input_settings && xtrx_input_settings->isSet()){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h index b48b17ae5..ad7610d81 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h @@ -49,6 +49,7 @@ #include "SWGSoapySDRInputSettings.h" #include "SWGSoapySDROutputSettings.h" #include "SWGTestMISettings.h" +#include "SWGTestMOSyncSettings.h" #include "SWGTestSourceSettings.h" #include "SWGXtrxInputSettings.h" #include "SWGXtrxOutputSettings.h" @@ -165,6 +166,9 @@ public: SWGTestMISettings* getTestMiSettings(); void setTestMiSettings(SWGTestMISettings* test_mi_settings); + SWGTestMOSyncSettings* getTestMoSyncSettings(); + void setTestMoSyncSettings(SWGTestMOSyncSettings* test_mo_sync_settings); + SWGXtrxInputSettings* getXtrxInputSettings(); void setXtrxInputSettings(SWGXtrxInputSettings* xtrx_input_settings); @@ -268,6 +272,9 @@ private: SWGTestMISettings* test_mi_settings; bool m_test_mi_settings_isSet; + SWGTestMOSyncSettings* test_mo_sync_settings; + bool m_test_mo_sync_settings_isSet; + SWGXtrxInputSettings* xtrx_input_settings; bool m_xtrx_input_settings_isSet; diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index 107d739be..8f3bc22e6 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -153,6 +153,7 @@ #include "SWGSoapySDRReport.h" #include "SWGSuccessResponse.h" #include "SWGTestMISettings.h" +#include "SWGTestMOSyncSettings.h" #include "SWGTestMiStreamSettings.h" #include "SWGTestSourceSettings.h" #include "SWGTraceData.h" @@ -590,6 +591,9 @@ namespace SWGSDRangel { if(QString("SWGTestMISettings").compare(type) == 0) { return new SWGTestMISettings(); } + if(QString("SWGTestMOSyncSettings").compare(type) == 0) { + return new SWGTestMOSyncSettings(); + } if(QString("SWGTestMiStreamSettings").compare(type) == 0) { return new SWGTestMiStreamSettings(); } diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.cpp b/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.cpp index add9b9037..a6cfdf558 100644 --- a/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.cpp @@ -2,7 +2,7 @@ * SDRangel * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- * - * OpenAPI spec version: 5.0.0 + * OpenAPI spec version: 4.11.6 * Contact: f4exb06@gmail.com * * NOTE: This class is auto generated by the swagger code generator program. diff --git a/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.h b/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.h index 3d673efec..edf8981be 100644 --- a/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGTestMOSyncSettings.h @@ -2,7 +2,7 @@ * SDRangel * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- * - * OpenAPI spec version: 5.0.0 + * OpenAPI spec version: 4.11.6 * Contact: f4exb06@gmail.com * * NOTE: This class is auto generated by the swagger code generator program.