mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
Web API: Added settings getter for RTLSDR. Added more device URLs
This commit is contained in:
parent
f9794c7701
commit
3b69d6517b
@ -225,7 +225,7 @@ public:
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
private:
|
||||
|
@ -1,5 +1,7 @@
|
||||
project(rtlsdr)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
|
||||
set(rtlsdr_SOURCES
|
||||
rtlsdrgui.cpp
|
||||
rtlsdrinput.cpp
|
||||
@ -24,6 +26,7 @@ if (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
${LIBRTLSDRSRC}/include
|
||||
${LIBRTLSDRSRC}/src
|
||||
)
|
||||
@ -31,6 +34,7 @@ else (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
${LIBRTLSDR_INCLUDE_DIR}
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
@ -55,6 +59,7 @@ target_link_libraries(inputrtlsdr
|
||||
rtlsdr
|
||||
sdrbase
|
||||
sdrgui
|
||||
swagger
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
target_link_libraries(inputrtlsdr
|
||||
@ -62,6 +67,7 @@ target_link_libraries(inputrtlsdr
|
||||
${LIBRTLSDR_LIBRARIES}
|
||||
sdrbase
|
||||
sdrgui
|
||||
swagger
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
|
@ -18,10 +18,12 @@
|
||||
#include <QDebug>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGRtlSdrSettings.h"
|
||||
|
||||
#include "rtlsdrinput.h"
|
||||
|
||||
#include "device/devicesourceapi.h"
|
||||
|
||||
#include "rtlsdrthread.h"
|
||||
#include "rtlsdrgui.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
@ -465,3 +467,24 @@ void RTLSDRInput::set_ds_mode(int on)
|
||||
rtlsdr_set_direct_sampling(m_dev, on);
|
||||
}
|
||||
|
||||
int RTLSDRInput::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
{
|
||||
response.setRtlSdrSettings(new SWGSDRangel::SWGRtlSdrSettings());
|
||||
response.getRtlSdrSettings()->setAgc(m_settings.m_agc ? 1 : 0);
|
||||
response.getRtlSdrSettings()->setCenterFrequency(m_settings.m_centerFrequency);
|
||||
response.getRtlSdrSettings()->setDcBlock(m_settings.m_dcBlock ? 1 : 0);
|
||||
response.getRtlSdrSettings()->setDevSampleRate(m_settings.m_devSampleRate);
|
||||
response.getRtlSdrSettings()->setFcPos((int) m_settings.m_fcPos);
|
||||
response.getRtlSdrSettings()->setGain(m_settings.m_gain);
|
||||
response.getRtlSdrSettings()->setIqImbalance(m_settings.m_iqImbalance ? 1 : 0);
|
||||
response.getRtlSdrSettings()->setLoPpmCorrection(m_settings.m_loPpmCorrection);
|
||||
response.getRtlSdrSettings()->setLog2Decim(m_settings.m_log2Decim);
|
||||
response.getRtlSdrSettings()->setLowSampleRate(m_settings.m_lowSampleRate ? 1 : 0);
|
||||
response.getRtlSdrSettings()->setNoModMode(m_settings.m_noModMode ? 1 : 0);
|
||||
response.getRtlSdrSettings()->setTransverterDeltaFrequency(m_settings.m_transverterDeltaFrequency);
|
||||
response.getRtlSdrSettings()->setTransverterMode(m_settings.m_transverterMode ? 1 : 0);
|
||||
return 200;
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,10 @@ public:
|
||||
virtual bool handleMessage(const Message& message);
|
||||
virtual void setMessageQueueToGUI(MessageQueue *queue);
|
||||
|
||||
virtual int webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage);
|
||||
|
||||
const std::vector<int>& getGains() const { return m_gains; }
|
||||
void set_ds_mode(int on);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,3 +31,4 @@ QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets";
|
||||
std::regex WebAPIAdapterInterface::devicesetURLRe("^/sdrangel/deviceset/([0-9]{1,2})$");
|
||||
std::regex WebAPIAdapterInterface::devicesetDeviceURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device$");
|
||||
std::regex WebAPIAdapterInterface::devicesetDeviceSettingsURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device/settings$");
|
||||
std::regex WebAPIAdapterInterface::devicesetDeviceRunURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device/run");
|
||||
|
@ -39,6 +39,7 @@ namespace SWGSDRangel
|
||||
class SWGDeviceSet;
|
||||
class SWGDeviceListItem;
|
||||
class SWGDeviceSettings;
|
||||
class SWGDeviceState;
|
||||
class SWGErrorResponse;
|
||||
}
|
||||
|
||||
@ -246,6 +247,46 @@ public:
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset/{devicesetIndex}/device/settings (PUT) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int devicesetDeviceSettingsPut(
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset/{devicesetIndex}/device/settings (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int devicesetDeviceSettingsPatch(
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceSettings& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset/{devicesetIndex}/device/run (POST) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int devicesetDeviceRunPost(
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceState& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/deviceset/{devicesetIndex}/device/run (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int devicesetDeviceRunDelete(
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceState& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
{ return 501; }
|
||||
|
||||
static QString instanceSummaryURL;
|
||||
static QString instanceDevicesURL;
|
||||
static QString instanceChannelsURL;
|
||||
@ -258,6 +299,7 @@ public:
|
||||
static std::regex devicesetURLRe;
|
||||
static std::regex devicesetDeviceURLRe;
|
||||
static std::regex devicesetDeviceSettingsURLRe;
|
||||
static std::regex devicesetDeviceRunURLRe;
|
||||
};
|
||||
|
||||
|
||||
|
@ -548,6 +548,128 @@ paths:
|
||||
description: On success returns current settings values
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceSettings"
|
||||
"404":
|
||||
description: Invalid device set index or device not found
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"500":
|
||||
description: Error
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"501":
|
||||
description: Function not implemented
|
||||
put:
|
||||
description: Apply all settings unconditionally (force)
|
||||
operationId: devicesetDeviceSettingsPut
|
||||
tags:
|
||||
- DeviceSet
|
||||
parameters:
|
||||
- in: path
|
||||
name: deviceSetIndex
|
||||
type: integer
|
||||
required: true
|
||||
description: Index of device set in the device set list
|
||||
- name: body
|
||||
in: body
|
||||
description: Device settings to apply
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceSettings"
|
||||
responses:
|
||||
"200":
|
||||
description: On success returns new settings values
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceSettings"
|
||||
"404":
|
||||
description: Invalid device set index or device not found
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"500":
|
||||
description: Error
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"501":
|
||||
description: Function not implemented
|
||||
patch:
|
||||
description: Apply settings differentially (no force)
|
||||
operationId: devicesetDeviceSettingsPatch
|
||||
tags:
|
||||
- DeviceSet
|
||||
parameters:
|
||||
- in: path
|
||||
name: deviceSetIndex
|
||||
type: integer
|
||||
required: true
|
||||
description: Index of device set in the device set list
|
||||
- name: body
|
||||
in: body
|
||||
description: Device settings to apply
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceSettings"
|
||||
responses:
|
||||
"200":
|
||||
description: On success returns new settings values
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceSettings"
|
||||
"404":
|
||||
description: Invalid device set index or device not found
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"500":
|
||||
description: Error
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"501":
|
||||
description: Function not implemented
|
||||
/sdrangel/deviceset/{deviceSetIndex}/device/run:
|
||||
x-swagger-router-controller: deviceset
|
||||
post:
|
||||
description: start device
|
||||
operationId: devicesetDeviceRunPost
|
||||
tags:
|
||||
- DeviceSet
|
||||
parameters:
|
||||
- in: path
|
||||
name: deviceSetIndex
|
||||
type: integer
|
||||
required: true
|
||||
description: Index of device set in the device set list
|
||||
responses:
|
||||
"200":
|
||||
description: On success return current state
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceState"
|
||||
"404":
|
||||
description: Invalid device set index or device not found
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"500":
|
||||
description: Error
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"501":
|
||||
description: Function not implemented
|
||||
delete:
|
||||
description: stop device
|
||||
operationId: devicesetDeviceRunDelete
|
||||
tags:
|
||||
- DeviceSet
|
||||
parameters:
|
||||
- in: path
|
||||
name: deviceSetIndex
|
||||
type: integer
|
||||
required: true
|
||||
description: Index of device set in the device set list
|
||||
responses:
|
||||
"200":
|
||||
description: On success return current state
|
||||
schema:
|
||||
$ref: "#/definitions/DeviceState"
|
||||
"404":
|
||||
description: Invalid device set index or device not found
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
"500":
|
||||
description: Error
|
||||
schema:
|
||||
@ -699,7 +821,14 @@ definitions:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/DeviceSet"
|
||||
|
||||
DeviceState:
|
||||
description: "Device running state"
|
||||
required:
|
||||
- state
|
||||
properties:
|
||||
state:
|
||||
description: "State: notStarted, idle, ready, running, error"
|
||||
type: string
|
||||
SamplingDevice:
|
||||
description: "Information about a logical device available from an attached hardware device that can be used as a sampling device"
|
||||
required:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,56 +28,6 @@ SWGDeviceSetApi::SWGDeviceSetApi(QString host, QString basePath) {
|
||||
this->basePath = basePath;
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceGet(qint32 device_set_index) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/settings");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceGetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceGetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceSettings* output = static_cast<SWGDeviceSettings*>(create(json, QString("SWGDeviceSettings")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceGetSignal(output);
|
||||
emit devicesetDeviceGetSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDevicePut(qint32 device_set_index, SWGDeviceListItem body) {
|
||||
QString fullPath;
|
||||
@ -130,6 +80,260 @@ SWGDeviceSetApi::devicesetDevicePutCallback(HttpRequestWorker * worker) {
|
||||
emit devicesetDevicePutSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceRunDelete(qint32 device_set_index) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/run");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "DELETE");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceRunDeleteCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceRunDeleteCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceState* output = static_cast<SWGDeviceState*>(create(json, QString("SWGDeviceState")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceRunDeleteSignal(output);
|
||||
emit devicesetDeviceRunDeleteSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceRunPost(qint32 device_set_index) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/run");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "POST");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceRunPostCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceRunPostCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceState* output = static_cast<SWGDeviceState*>(create(json, QString("SWGDeviceState")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceRunPostSignal(output);
|
||||
emit devicesetDeviceRunPostSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsGet(qint32 device_set_index) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/settings");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "GET");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceSettingsGetCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsGetCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceSettings* output = static_cast<SWGDeviceSettings*>(create(json, QString("SWGDeviceSettings")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceSettingsGetSignal(output);
|
||||
emit devicesetDeviceSettingsGetSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsPatch(qint32 device_set_index, SWGDeviceSettings body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/settings");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "PATCH");
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceSettingsPatchCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsPatchCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceSettings* output = static_cast<SWGDeviceSettings*>(create(json, QString("SWGDeviceSettings")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceSettingsPatchSignal(output);
|
||||
emit devicesetDeviceSettingsPatchSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsPut(qint32 device_set_index, SWGDeviceSettings body) {
|
||||
QString fullPath;
|
||||
fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/settings");
|
||||
|
||||
QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}");
|
||||
fullPath.replace(device_set_indexPathParam, stringValue(device_set_index));
|
||||
|
||||
|
||||
HttpRequestWorker *worker = new HttpRequestWorker();
|
||||
HttpRequestInput input(fullPath, "PUT");
|
||||
|
||||
|
||||
QString output = body.asJson();
|
||||
input.request_body.append(output);
|
||||
|
||||
|
||||
|
||||
foreach(QString key, this->defaultHeaders.keys()) {
|
||||
input.headers.insert(key, this->defaultHeaders.value(key));
|
||||
}
|
||||
|
||||
connect(worker,
|
||||
&HttpRequestWorker::on_execution_finished,
|
||||
this,
|
||||
&SWGDeviceSetApi::devicesetDeviceSettingsPutCallback);
|
||||
|
||||
worker->execute(&input);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetDeviceSettingsPutCallback(HttpRequestWorker * worker) {
|
||||
QString msg;
|
||||
QString error_str = worker->error_str;
|
||||
QNetworkReply::NetworkError error_type = worker->error_type;
|
||||
|
||||
if (worker->error_type == QNetworkReply::NoError) {
|
||||
msg = QString("Success! %1 bytes").arg(worker->response.length());
|
||||
}
|
||||
else {
|
||||
msg = "Error: " + worker->error_str;
|
||||
}
|
||||
|
||||
|
||||
QString json(worker->response);
|
||||
SWGDeviceSettings* output = static_cast<SWGDeviceSettings*>(create(json, QString("SWGDeviceSettings")));
|
||||
worker->deleteLater();
|
||||
|
||||
emit devicesetDeviceSettingsPutSignal(output);
|
||||
emit devicesetDeviceSettingsPutSignalE(output, error_type, error_str);
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceSetApi::devicesetGet(qint32 device_set_index) {
|
||||
QString fullPath;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "SWGDeviceListItem.h"
|
||||
#include "SWGDeviceSet.h"
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
|
||||
#include <QObject>
|
||||
@ -36,22 +37,38 @@ public:
|
||||
QString basePath;
|
||||
QMap<QString, QString> defaultHeaders;
|
||||
|
||||
void devicesetDeviceGet(qint32 device_set_index);
|
||||
void devicesetDevicePut(qint32 device_set_index, SWGDeviceListItem body);
|
||||
void devicesetDeviceRunDelete(qint32 device_set_index);
|
||||
void devicesetDeviceRunPost(qint32 device_set_index);
|
||||
void devicesetDeviceSettingsGet(qint32 device_set_index);
|
||||
void devicesetDeviceSettingsPatch(qint32 device_set_index, SWGDeviceSettings body);
|
||||
void devicesetDeviceSettingsPut(qint32 device_set_index, SWGDeviceSettings body);
|
||||
void devicesetGet(qint32 device_set_index);
|
||||
|
||||
private:
|
||||
void devicesetDeviceGetCallback (HttpRequestWorker * worker);
|
||||
void devicesetDevicePutCallback (HttpRequestWorker * worker);
|
||||
void devicesetDeviceRunDeleteCallback (HttpRequestWorker * worker);
|
||||
void devicesetDeviceRunPostCallback (HttpRequestWorker * worker);
|
||||
void devicesetDeviceSettingsGetCallback (HttpRequestWorker * worker);
|
||||
void devicesetDeviceSettingsPatchCallback (HttpRequestWorker * worker);
|
||||
void devicesetDeviceSettingsPutCallback (HttpRequestWorker * worker);
|
||||
void devicesetGetCallback (HttpRequestWorker * worker);
|
||||
|
||||
signals:
|
||||
void devicesetDeviceGetSignal(SWGDeviceSettings* summary);
|
||||
void devicesetDevicePutSignal(SWGDeviceListItem* summary);
|
||||
void devicesetDeviceRunDeleteSignal(SWGDeviceState* summary);
|
||||
void devicesetDeviceRunPostSignal(SWGDeviceState* summary);
|
||||
void devicesetDeviceSettingsGetSignal(SWGDeviceSettings* summary);
|
||||
void devicesetDeviceSettingsPatchSignal(SWGDeviceSettings* summary);
|
||||
void devicesetDeviceSettingsPutSignal(SWGDeviceSettings* summary);
|
||||
void devicesetGetSignal(SWGDeviceSet* summary);
|
||||
|
||||
void devicesetDeviceGetSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDevicePutSignalE(SWGDeviceListItem* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDeviceRunDeleteSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDeviceRunPostSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDeviceSettingsGetSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDeviceSettingsPatchSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetDeviceSettingsPutSignalE(SWGDeviceSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
void devicesetGetSignalE(SWGDeviceSet* summary, QNetworkReply::NetworkError error_type, QString& error_str);
|
||||
|
||||
};
|
||||
|
95
swagger/sdrangel/code/qt5/client/SWGDeviceState.cpp
Normal file
95
swagger/sdrangel/code/qt5/client/SWGDeviceState.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
|
||||
*
|
||||
* 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 "SWGDeviceState.h"
|
||||
|
||||
#include "SWGHelpers.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
SWGDeviceState::SWGDeviceState(QString* json) {
|
||||
init();
|
||||
this->fromJson(*json);
|
||||
}
|
||||
|
||||
SWGDeviceState::SWGDeviceState() {
|
||||
init();
|
||||
}
|
||||
|
||||
SWGDeviceState::~SWGDeviceState() {
|
||||
this->cleanup();
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceState::init() {
|
||||
state = new QString("");
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceState::cleanup() {
|
||||
|
||||
if(state != nullptr) {
|
||||
delete state;
|
||||
}
|
||||
}
|
||||
|
||||
SWGDeviceState*
|
||||
SWGDeviceState::fromJson(QString &json) {
|
||||
QByteArray array (json.toStdString().c_str());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(array);
|
||||
QJsonObject jsonObject = doc.object();
|
||||
this->fromJsonObject(jsonObject);
|
||||
return this;
|
||||
}
|
||||
|
||||
void
|
||||
SWGDeviceState::fromJsonObject(QJsonObject &pJson) {
|
||||
::SWGSDRangel::setValue(&state, pJson["state"], "QString", "QString");
|
||||
}
|
||||
|
||||
QString
|
||||
SWGDeviceState::asJson ()
|
||||
{
|
||||
QJsonObject* obj = this->asJsonObject();
|
||||
|
||||
QJsonDocument doc(*obj);
|
||||
QByteArray bytes = doc.toJson();
|
||||
return QString(bytes);
|
||||
}
|
||||
|
||||
QJsonObject*
|
||||
SWGDeviceState::asJsonObject() {
|
||||
QJsonObject* obj = new QJsonObject();
|
||||
|
||||
toJsonValue(QString("state"), state, obj, QString("QString"));
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
QString*
|
||||
SWGDeviceState::getState() {
|
||||
return state;
|
||||
}
|
||||
void
|
||||
SWGDeviceState::setState(QString* state) {
|
||||
this->state = state;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
55
swagger/sdrangel/code/qt5/client/SWGDeviceState.h
Normal file
55
swagger/sdrangel/code/qt5/client/SWGDeviceState.h
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
* SDRangel
|
||||
* This is the web API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* SWGDeviceState.h
|
||||
*
|
||||
* Device running state
|
||||
*/
|
||||
|
||||
#ifndef SWGDeviceState_H_
|
||||
#define SWGDeviceState_H_
|
||||
|
||||
#include <QJsonObject>
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "SWGObject.h"
|
||||
|
||||
|
||||
namespace SWGSDRangel {
|
||||
|
||||
class SWGDeviceState: public SWGObject {
|
||||
public:
|
||||
SWGDeviceState();
|
||||
SWGDeviceState(QString* json);
|
||||
virtual ~SWGDeviceState();
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
QString asJson ();
|
||||
QJsonObject* asJsonObject();
|
||||
void fromJsonObject(QJsonObject &json);
|
||||
SWGDeviceState* fromJson(QString &jsonString);
|
||||
|
||||
QString* getState();
|
||||
void setState(QString* state);
|
||||
|
||||
|
||||
private:
|
||||
QString* state;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SWGDeviceState_H_ */
|
@ -25,6 +25,7 @@
|
||||
#include "SWGDeviceSet.h"
|
||||
#include "SWGDeviceSetList.h"
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGErrorResponse.h"
|
||||
#include "SWGFileSourceSettings.h"
|
||||
#include "SWGInstanceChannelsResponse.h"
|
||||
@ -78,6 +79,9 @@ namespace SWGSDRangel {
|
||||
if(QString("SWGDeviceSettings").compare(type) == 0) {
|
||||
return new SWGDeviceSettings();
|
||||
}
|
||||
if(QString("SWGDeviceState").compare(type) == 0) {
|
||||
return new SWGDeviceState();
|
||||
}
|
||||
if(QString("SWGErrorResponse").compare(type) == 0) {
|
||||
return new SWGErrorResponse();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user