From 0ec7ec414d847f811153f8203f0683e6b162371f Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 25 Aug 2021 15:27:06 +0200 Subject: [PATCH] SDRplay V3: added device type in API report --- .../samplesource/sdrplayv3/sdrplayv3input.cpp | 22 ++++++++++++++++ sdrbase/resources/webapi/doc/html2/index.html | 6 ++++- .../webapi/doc/swagger/include/SDRPlayV3.yaml | 3 +++ .../api/swagger/include/SDRPlayV3.yaml | 3 +++ swagger/sdrangel/code/html2/index.html | 6 ++++- .../code/qt5/client/SWGSDRPlayV3Report.cpp | 25 +++++++++++++++++++ .../code/qt5/client/SWGSDRPlayV3Report.h | 7 ++++++ 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/plugins/samplesource/sdrplayv3/sdrplayv3input.cpp b/plugins/samplesource/sdrplayv3/sdrplayv3input.cpp index 4ab7464a6..7b91c4b9d 100644 --- a/plugins/samplesource/sdrplayv3/sdrplayv3input.cpp +++ b/plugins/samplesource/sdrplayv3/sdrplayv3input.cpp @@ -937,6 +937,28 @@ void SDRPlayV3Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp response.getSdrPlayV3Report()->getBandwidths()->append(new SWGSDRangel::SWGBandwidth); response.getSdrPlayV3Report()->getBandwidths()->back()->setBandwidth(SDRPlayV3Bandwidths::getBandwidth(i)); } + + switch(getDeviceId()) + { + case SDRPLAY_RSP1_ID: + response.getSdrPlayV3Report()->setDeviceType(new QString("RSP1")); + break; + case SDRPLAY_RSP1A_ID: + response.getSdrPlayV3Report()->setDeviceType(new QString("RSP1A")); + break; + case SDRPLAY_RSP2_ID: + response.getSdrPlayV3Report()->setDeviceType(new QString("RSP2")); + break; + case SDRPLAY_RSPduo_ID: + response.getSdrPlayV3Report()->setDeviceType(new QString("RSPduo")); + break; + case SDRPLAY_RSPdx_ID: + response.getSdrPlayV3Report()->setDeviceType(new QString("RSPdx")); + break; + default: + response.getSdrPlayV3Report()->setDeviceType(new QString("Unknown")); + break; + } } void SDRPlayV3Input::webapiReverseSendSettings(QList& deviceSettingsKeys, const SDRPlayV3Settings& settings, bool force) diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index cb240e552..428dadd3d 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -9495,6 +9495,10 @@ margin-bottom: 20px; }; defs.SDRPlayV3Report = { "properties" : { + "deviceType" : { + "type" : "string", + "description" : "SDRplay device type. Can be RSP1, RSP1A, RSP2, RSPduo, RSPdx, Unknown" + }, "bandwidths" : { "type" : "array", "items" : { @@ -47724,7 +47728,7 @@ except ApiException as e:
- Generated 2021-08-21T12:00:48.492+02:00 + Generated 2021-08-25T15:15:18.832+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/SDRPlayV3.yaml b/sdrbase/resources/webapi/doc/swagger/include/SDRPlayV3.yaml index 3aa7005af..9ecdab669 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/SDRPlayV3.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/SDRPlayV3.yaml @@ -51,6 +51,9 @@ SDRPlayV3Settings: SDRPlayV3Report: description: SDRplayV3 properties: + deviceType: + type: string + description: SDRplay device type. Can be RSP1, RSP1A, RSP2, RSPduo, RSPdx, Unknown bandwidths: type: array items: diff --git a/swagger/sdrangel/api/swagger/include/SDRPlayV3.yaml b/swagger/sdrangel/api/swagger/include/SDRPlayV3.yaml index 3c6b958e5..83b2606cf 100644 --- a/swagger/sdrangel/api/swagger/include/SDRPlayV3.yaml +++ b/swagger/sdrangel/api/swagger/include/SDRPlayV3.yaml @@ -51,6 +51,9 @@ SDRPlayV3Settings: SDRPlayV3Report: description: SDRplayV3 properties: + deviceType: + type: string + description: SDRplay device type. Can be RSP1, RSP1A, RSP2, RSPduo, RSPdx, Unknown bandwidths: type: array items: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index cb240e552..428dadd3d 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -9495,6 +9495,10 @@ margin-bottom: 20px; }; defs.SDRPlayV3Report = { "properties" : { + "deviceType" : { + "type" : "string", + "description" : "SDRplay device type. Can be RSP1, RSP1A, RSP2, RSPduo, RSPdx, Unknown" + }, "bandwidths" : { "type" : "array", "items" : { @@ -47724,7 +47728,7 @@ except ApiException as e:
- Generated 2021-08-21T12:00:48.492+02:00 + Generated 2021-08-25T15:15:18.832+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.cpp b/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.cpp index 21b71a07a..b9bfed1cd 100644 --- a/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.cpp @@ -28,6 +28,8 @@ SWGSDRPlayV3Report::SWGSDRPlayV3Report(QString* json) { } SWGSDRPlayV3Report::SWGSDRPlayV3Report() { + device_type = nullptr; + m_device_type_isSet = false; bandwidths = nullptr; m_bandwidths_isSet = false; intermediate_frequencies = nullptr; @@ -40,6 +42,8 @@ SWGSDRPlayV3Report::~SWGSDRPlayV3Report() { void SWGSDRPlayV3Report::init() { + device_type = new QString(""); + m_device_type_isSet = false; bandwidths = new QList(); m_bandwidths_isSet = false; intermediate_frequencies = new QList(); @@ -48,6 +52,9 @@ SWGSDRPlayV3Report::init() { void SWGSDRPlayV3Report::cleanup() { + if(device_type != nullptr) { + delete device_type; + } if(bandwidths != nullptr) { auto arr = bandwidths; for(auto o: *arr) { @@ -75,6 +82,8 @@ SWGSDRPlayV3Report::fromJson(QString &json) { void SWGSDRPlayV3Report::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&device_type, pJson["deviceType"], "QString", "QString"); + ::SWGSDRangel::setValue(&bandwidths, pJson["bandwidths"], "QList", "SWGBandwidth"); @@ -95,6 +104,9 @@ SWGSDRPlayV3Report::asJson () QJsonObject* SWGSDRPlayV3Report::asJsonObject() { QJsonObject* obj = new QJsonObject(); + if(device_type != nullptr && *device_type != QString("")){ + toJsonValue(QString("deviceType"), device_type, obj, QString("QString")); + } if(bandwidths && bandwidths->size() > 0){ toJsonArray((QList*)bandwidths, obj, "bandwidths", "SWGBandwidth"); } @@ -105,6 +117,16 @@ SWGSDRPlayV3Report::asJsonObject() { return obj; } +QString* +SWGSDRPlayV3Report::getDeviceType() { + return device_type; +} +void +SWGSDRPlayV3Report::setDeviceType(QString* device_type) { + this->device_type = device_type; + this->m_device_type_isSet = true; +} + QList* SWGSDRPlayV3Report::getBandwidths() { return bandwidths; @@ -130,6 +152,9 @@ bool SWGSDRPlayV3Report::isSet(){ bool isObjectUpdated = false; do{ + if(device_type && *device_type != QString("")){ + isObjectUpdated = true; break; + } if(bandwidths && (bandwidths->size() > 0)){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.h b/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.h index 1f78abd9d..2a31af916 100644 --- a/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.h +++ b/swagger/sdrangel/code/qt5/client/SWGSDRPlayV3Report.h @@ -25,6 +25,7 @@ #include "SWGBandwidth.h" #include "SWGFrequency.h" #include +#include #include "SWGObject.h" #include "export.h" @@ -44,6 +45,9 @@ public: virtual void fromJsonObject(QJsonObject &json) override; virtual SWGSDRPlayV3Report* fromJson(QString &jsonString) override; + QString* getDeviceType(); + void setDeviceType(QString* device_type); + QList* getBandwidths(); void setBandwidths(QList* bandwidths); @@ -54,6 +58,9 @@ public: virtual bool isSet() override; private: + QString* device_type; + bool m_device_type_isSet; + QList* bandwidths; bool m_bandwidths_isSet;