1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

RTL-SDR input: implemeted WEB API for reporting

This commit is contained in:
f4exb 2018-05-26 14:28:06 +02:00
parent 73a3291008
commit f9cba5844b
15 changed files with 476 additions and 4 deletions

View File

@ -22,6 +22,8 @@
#include "SWGDeviceSettings.h"
#include "SWGRtlSdrSettings.h"
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGRtlSdrReport.h"
#include "rtlsdrinput.h"
#include "device/devicesourceapi.h"
@ -653,3 +655,26 @@ int RTLSDRInput::webapiRun(
return 200;
}
int RTLSDRInput::webapiReportGet(
SWGSDRangel::SWGDeviceReport& response,
QString& errorMessage __attribute__((unused)))
{
response.setRtlSdrReport(new SWGSDRangel::SWGRtlSdrReport());
response.getRtlSdrReport()->init();
webapiFormatDeviceReport(response);
return 200;
}
void RTLSDRInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
{
response.getRtlSdrReport()->setGains(new QList<SWGSDRangel::SWGRtlSdrReport_gains*>);
for (std::vector<int>::const_iterator it = getGains().begin(); it != getGains().end(); ++it)
{
response.getRtlSdrReport()->getGains()->append(new SWGSDRangel::SWGRtlSdrReport_gains);
response.getRtlSdrReport()->getGains()->back()->setGain(*it);
}
}

View File

@ -121,6 +121,10 @@ public:
SWGSDRangel::SWGDeviceSettings& response, // query + response
QString& errorMessage);
virtual int webapiReportGet(
SWGSDRangel::SWGDeviceReport& response,
QString& errorMessage);
virtual int webapiRunGet(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage);
@ -157,6 +161,7 @@ private:
void closeDevice();
bool applySettings(const RTLSDRSettings& settings, bool force);
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const RTLSDRSettings& settings);
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
};
#endif // INCLUDE_RTLSDRINPUT_H

View File

@ -1717,6 +1717,9 @@ margin-bottom: 20px;
},
"perseusReport" : {
"$ref" : "#/definitions/PerseusReport"
},
"rtlSdrReport" : {
"$ref" : "#/definitions/RtlSdrReport"
}
},
"description" : "Base device report. The specific device report present depeds on deviceHwType"
@ -2714,6 +2717,25 @@ margin-bottom: 20px;
"format" : "float"
}
}
};
defs.RtlSdrReport = {
"properties" : {
"gains" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/RtlSdrReport_gains"
}
}
},
"description" : "RTLSDR"
};
defs.RtlSdrReport_gains = {
"properties" : {
"gain" : {
"type" : "integer",
"description" : "gain in centi Bels"
}
}
};
defs.RtlSdrSettings = {
"properties" : {
@ -21922,7 +21944,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2018-05-26T12:32:33.813+02:00
Generated 2018-05-26T14:09:06.509+02:00
</div>
</div>
</div>

View File

@ -33,4 +33,14 @@ RtlSdrSettings:
type: integer
fileRecordName:
type: string
RtlSdrReport:
description: RTLSDR
properties:
gains:
type: array
items:
properties:
gain:
description: gain in centi Bels
type: integer

View File

@ -1793,6 +1793,8 @@ definitions:
$ref: "/doc/swagger/include/FileSource.yaml#/FileSourceReport"
perseusReport:
$ref: "/doc/swagger/include/Perseus.yaml#/PerseusReport"
rtlSdrReport:
$ref: "/doc/swagger/include/RtlSdr.yaml#/RtlSdrReport"
ChannelSettings:
description: Base channel settings. The specific channel settings present depends on channelType.

View File

@ -33,4 +33,14 @@ RtlSdrSettings:
type: integer
fileRecordName:
type: string
RtlSdrReport:
description: RTLSDR
properties:
gains:
type: array
items:
properties:
gain:
description: gain in centi Bels
type: integer

View File

@ -1793,6 +1793,8 @@ definitions:
$ref: "http://localhost:8081/api/swagger/include/FileSource.yaml#/FileSourceReport"
perseusReport:
$ref: "http://localhost:8081/api/swagger/include/Perseus.yaml#/PerseusReport"
rtlSdrReport:
$ref: "http://localhost:8081/api/swagger/include/RtlSdr.yaml#/RtlSdrReport"
ChannelSettings:
description: Base channel settings. The specific channel settings present depends on channelType.

View File

@ -1717,6 +1717,9 @@ margin-bottom: 20px;
},
"perseusReport" : {
"$ref" : "#/definitions/PerseusReport"
},
"rtlSdrReport" : {
"$ref" : "#/definitions/RtlSdrReport"
}
},
"description" : "Base device report. The specific device report present depeds on deviceHwType"
@ -2714,6 +2717,25 @@ margin-bottom: 20px;
"format" : "float"
}
}
};
defs.RtlSdrReport = {
"properties" : {
"gains" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/RtlSdrReport_gains"
}
}
},
"description" : "RTLSDR"
};
defs.RtlSdrReport_gains = {
"properties" : {
"gain" : {
"type" : "integer",
"description" : "gain in centi Bels"
}
}
};
defs.RtlSdrSettings = {
"properties" : {
@ -21922,7 +21944,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2018-05-26T12:32:33.813+02:00
Generated 2018-05-26T14:09:06.509+02:00
</div>
</div>
</div>

View File

@ -40,6 +40,8 @@ SWGDeviceReport::SWGDeviceReport() {
m_file_source_report_isSet = false;
perseus_report = nullptr;
m_perseus_report_isSet = false;
rtl_sdr_report = nullptr;
m_rtl_sdr_report_isSet = false;
}
SWGDeviceReport::~SWGDeviceReport() {
@ -60,6 +62,8 @@ SWGDeviceReport::init() {
m_file_source_report_isSet = false;
perseus_report = new SWGPerseusReport();
m_perseus_report_isSet = false;
rtl_sdr_report = new SWGRtlSdrReport();
m_rtl_sdr_report_isSet = false;
}
void
@ -80,6 +84,9 @@ SWGDeviceReport::cleanup() {
if(perseus_report != nullptr) {
delete perseus_report;
}
if(rtl_sdr_report != nullptr) {
delete rtl_sdr_report;
}
}
SWGDeviceReport*
@ -105,6 +112,8 @@ SWGDeviceReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&perseus_report, pJson["perseusReport"], "SWGPerseusReport", "SWGPerseusReport");
::SWGSDRangel::setValue(&rtl_sdr_report, pJson["rtlSdrReport"], "SWGRtlSdrReport", "SWGRtlSdrReport");
}
QString
@ -139,6 +148,9 @@ SWGDeviceReport::asJsonObject() {
if((perseus_report != nullptr) && (perseus_report->isSet())){
toJsonValue(QString("perseusReport"), perseus_report, obj, QString("SWGPerseusReport"));
}
if((rtl_sdr_report != nullptr) && (rtl_sdr_report->isSet())){
toJsonValue(QString("rtlSdrReport"), rtl_sdr_report, obj, QString("SWGRtlSdrReport"));
}
return obj;
}
@ -203,6 +215,16 @@ SWGDeviceReport::setPerseusReport(SWGPerseusReport* perseus_report) {
this->m_perseus_report_isSet = true;
}
SWGRtlSdrReport*
SWGDeviceReport::getRtlSdrReport() {
return rtl_sdr_report;
}
void
SWGDeviceReport::setRtlSdrReport(SWGRtlSdrReport* rtl_sdr_report) {
this->rtl_sdr_report = rtl_sdr_report;
this->m_rtl_sdr_report_isSet = true;
}
bool
SWGDeviceReport::isSet(){
@ -214,6 +236,7 @@ SWGDeviceReport::isSet(){
if(airspy_hf_report != nullptr && airspy_hf_report->isSet()){ isObjectUpdated = true; break;}
if(file_source_report != nullptr && file_source_report->isSet()){ isObjectUpdated = true; break;}
if(perseus_report != nullptr && perseus_report->isSet()){ isObjectUpdated = true; break;}
if(rtl_sdr_report != nullptr && rtl_sdr_report->isSet()){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}

View File

@ -26,6 +26,7 @@
#include "SWGAirspyReport.h"
#include "SWGFileSourceReport.h"
#include "SWGPerseusReport.h"
#include "SWGRtlSdrReport.h"
#include <QString>
#include "SWGObject.h"
@ -64,6 +65,9 @@ public:
SWGPerseusReport* getPerseusReport();
void setPerseusReport(SWGPerseusReport* perseus_report);
SWGRtlSdrReport* getRtlSdrReport();
void setRtlSdrReport(SWGRtlSdrReport* rtl_sdr_report);
virtual bool isSet() override;
@ -86,6 +90,9 @@ private:
SWGPerseusReport* perseus_report;
bool m_perseus_report_isSet;
SWGRtlSdrReport* rtl_sdr_report;
bool m_rtl_sdr_report_isSet;
};
}

View File

@ -77,6 +77,8 @@
#include "SWGPresets.h"
#include "SWGRDSReport.h"
#include "SWGRDSReport_altFrequencies.h"
#include "SWGRtlSdrReport.h"
#include "SWGRtlSdrReport_gains.h"
#include "SWGRtlSdrSettings.h"
#include "SWGSSBModReport.h"
#include "SWGSSBModSettings.h"
@ -283,6 +285,12 @@ namespace SWGSDRangel {
if(QString("SWGRDSReport_altFrequencies").compare(type) == 0) {
return new SWGRDSReport_altFrequencies();
}
if(QString("SWGRtlSdrReport").compare(type) == 0) {
return new SWGRtlSdrReport();
}
if(QString("SWGRtlSdrReport_gains").compare(type) == 0) {
return new SWGRtlSdrReport_gains();
}
if(QString("SWGRtlSdrSettings").compare(type) == 0) {
return new SWGRtlSdrSettings();
}

View File

@ -0,0 +1,112 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGRtlSdrReport.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGRtlSdrReport::SWGRtlSdrReport(QString* json) {
init();
this->fromJson(*json);
}
SWGRtlSdrReport::SWGRtlSdrReport() {
gains = nullptr;
m_gains_isSet = false;
}
SWGRtlSdrReport::~SWGRtlSdrReport() {
this->cleanup();
}
void
SWGRtlSdrReport::init() {
gains = new QList<SWGRtlSdrReport_gains*>();
m_gains_isSet = false;
}
void
SWGRtlSdrReport::cleanup() {
if(gains != nullptr) {
auto arr = gains;
for(auto o: *arr) {
delete o;
}
delete gains;
}
}
SWGRtlSdrReport*
SWGRtlSdrReport::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGRtlSdrReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&gains, pJson["gains"], "QList", "SWGRtlSdrReport_gains");
}
QString
SWGRtlSdrReport::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGRtlSdrReport::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(gains->size() > 0){
toJsonArray((QList<void*>*)gains, obj, "gains", "SWGRtlSdrReport_gains");
}
return obj;
}
QList<SWGRtlSdrReport_gains*>*
SWGRtlSdrReport::getGains() {
return gains;
}
void
SWGRtlSdrReport::setGains(QList<SWGRtlSdrReport_gains*>* gains) {
this->gains = gains;
this->m_gains_isSet = true;
}
bool
SWGRtlSdrReport::isSet(){
bool isObjectUpdated = false;
do{
if(gains->size() > 0){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,60 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGRtlSdrReport.h
*
* RTLSDR
*/
#ifndef SWGRtlSdrReport_H_
#define SWGRtlSdrReport_H_
#include <QJsonObject>
#include "SWGRtlSdrReport_gains.h"
#include <QList>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGRtlSdrReport: public SWGObject {
public:
SWGRtlSdrReport();
SWGRtlSdrReport(QString* json);
virtual ~SWGRtlSdrReport();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGRtlSdrReport* fromJson(QString &jsonString) override;
QList<SWGRtlSdrReport_gains*>* getGains();
void setGains(QList<SWGRtlSdrReport_gains*>* gains);
virtual bool isSet() override;
private:
QList<SWGRtlSdrReport_gains*>* gains;
bool m_gains_isSet;
};
}
#endif /* SWGRtlSdrReport_H_ */

View File

@ -0,0 +1,106 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
#include "SWGRtlSdrReport_gains.h"
#include "SWGHelpers.h"
#include <QJsonDocument>
#include <QJsonArray>
#include <QObject>
#include <QDebug>
namespace SWGSDRangel {
SWGRtlSdrReport_gains::SWGRtlSdrReport_gains(QString* json) {
init();
this->fromJson(*json);
}
SWGRtlSdrReport_gains::SWGRtlSdrReport_gains() {
gain = 0;
m_gain_isSet = false;
}
SWGRtlSdrReport_gains::~SWGRtlSdrReport_gains() {
this->cleanup();
}
void
SWGRtlSdrReport_gains::init() {
gain = 0;
m_gain_isSet = false;
}
void
SWGRtlSdrReport_gains::cleanup() {
}
SWGRtlSdrReport_gains*
SWGRtlSdrReport_gains::fromJson(QString &json) {
QByteArray array (json.toStdString().c_str());
QJsonDocument doc = QJsonDocument::fromJson(array);
QJsonObject jsonObject = doc.object();
this->fromJsonObject(jsonObject);
return this;
}
void
SWGRtlSdrReport_gains::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&gain, pJson["gain"], "qint32", "");
}
QString
SWGRtlSdrReport_gains::asJson ()
{
QJsonObject* obj = this->asJsonObject();
QJsonDocument doc(*obj);
QByteArray bytes = doc.toJson();
delete obj;
return QString(bytes);
}
QJsonObject*
SWGRtlSdrReport_gains::asJsonObject() {
QJsonObject* obj = new QJsonObject();
if(m_gain_isSet){
obj->insert("gain", QJsonValue(gain));
}
return obj;
}
qint32
SWGRtlSdrReport_gains::getGain() {
return gain;
}
void
SWGRtlSdrReport_gains::setGain(qint32 gain) {
this->gain = gain;
this->m_gain_isSet = true;
}
bool
SWGRtlSdrReport_gains::isSet(){
bool isObjectUpdated = false;
do{
if(m_gain_isSet){ isObjectUpdated = true; break;}
}while(false);
return isObjectUpdated;
}
}

View File

@ -0,0 +1,58 @@
/**
* 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. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * 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 demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 ---
*
* OpenAPI spec version: 4.0.0
* Contact: f4exb06@gmail.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/*
* SWGRtlSdrReport_gains.h
*
*
*/
#ifndef SWGRtlSdrReport_gains_H_
#define SWGRtlSdrReport_gains_H_
#include <QJsonObject>
#include "SWGObject.h"
#include "export.h"
namespace SWGSDRangel {
class SWG_API SWGRtlSdrReport_gains: public SWGObject {
public:
SWGRtlSdrReport_gains();
SWGRtlSdrReport_gains(QString* json);
virtual ~SWGRtlSdrReport_gains();
void init();
void cleanup();
virtual QString asJson () override;
virtual QJsonObject* asJsonObject() override;
virtual void fromJsonObject(QJsonObject &json) override;
virtual SWGRtlSdrReport_gains* fromJson(QString &jsonString) override;
qint32 getGain();
void setGain(qint32 gain);
virtual bool isSet() override;
private:
qint32 gain;
bool m_gain_isSet;
};
}
#endif /* SWGRtlSdrReport_gains_H_ */