1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-03-06 19:38:47 -05:00

REST API: config: added PATCH and fixes

This commit is contained in:
f4exb 2019-08-11 01:27:19 +02:00
parent af6218611a
commit b980a92995
19 changed files with 1055 additions and 55 deletions

View File

@ -155,6 +155,7 @@ int ChannelAnalyzerWebAPIAdapter::webapiSettingsPutPatch(
(void) force;
(void) errorMessage;
webapiUpdateChannelSettings(m_settings, m_glScopeSettings, m_glSpectrumSettings, channelSettingsKeys, response);
return 200;
}
void ChannelAnalyzerWebAPIAdapter::webapiUpdateChannelSettings(

View File

@ -75,7 +75,7 @@ QByteArray GLScopeSettings::serialize() const
std::vector<TriggerData>::const_iterator triggerDataIt = m_triggersData.begin();
i = 0;
for (; triggerDataIt != m_triggersData.end(); i++)
for (; triggerDataIt != m_triggersData.end(); ++triggerDataIt, i++)
{
s.writeS32(210 + 16*i, (int) triggerDataIt->m_projectionType);
s.writeS32(211 + 16*i, triggerDataIt->m_triggerRepeat);
@ -96,7 +96,6 @@ QByteArray GLScopeSettings::serialize() const
bool GLScopeSettings::deserialize(const QByteArray& data)
{
qDebug("GLScopeGUI::deserialize");
SimpleDeserializer d(data);
if(!d.isValid()) {

View File

@ -53,6 +53,7 @@ void GLSpectrumSettings::resetToDefaults()
QByteArray GLSpectrumSettings::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_fftSize);
s.writeS32(2, m_fftOverlap);
s.writeS32(3, m_fftWindow);
@ -74,6 +75,7 @@ QByteArray GLSpectrumSettings::serialize() const
s.writeS32(19, (int) m_averagingMode);
s.writeS32(20, (qint32) getAveragingValue(m_averagingIndex, m_averagingMode));
s.writeBool(21, m_linear);
return s.final();
}
@ -88,7 +90,8 @@ bool GLSpectrumSettings::deserialize(const QByteArray& data)
int tmp;
if(d.getVersion() == 1) {
if (d.getVersion() == 1)
{
d.readS32(1, &m_fftSize, 1024);
d.readS32(2, &m_fftOverlap, 0);
d.readS32(3, &m_fftWindow, FFTWindow::Hamming);
@ -115,7 +118,9 @@ bool GLSpectrumSettings::deserialize(const QByteArray& data)
d.readBool(21, &m_linear, false);
return true;
} else {
}
else
{
resetToDefaults();
return false;
}

View File

@ -1805,7 +1805,7 @@ margin-bottom: 20px;
},
"inputType" : {
"type" : "integer",
"description" : "see ChannelAnalyzer::InputType"
"description" : "see ChannelAnalyzerSettings::InputType"
},
"rgbColor" : {
"type" : "integer"
@ -6779,6 +6779,9 @@ margin-bottom: 20px;
<li data-group="Instance" data-name="instanceConfigGet" class="">
<a href="#api-Instance-instanceConfigGet">instanceConfigGet</a>
</li>
<li data-group="Instance" data-name="instanceConfigPatch" class="">
<a href="#api-Instance-instanceConfigPatch">instanceConfigPatch</a>
</li>
<li data-group="Instance" data-name="instanceConfigPut" class="">
<a href="#api-Instance-instanceConfigPut">instanceConfigPut</a>
</li>
@ -21074,6 +21077,393 @@ except ApiException as e:
</article>
</div>
<hr>
<div id="api-Instance-instanceConfigPatch">
<article id="api-Instance-instanceConfigPatch-0" data-group="User" data-name="instanceConfigPatch" data-version="0">
<div class="pull-left">
<h1>instanceConfigPatch</h1>
<p></p>
</div>
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
<p class="marked">Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Presets and Commands if available in the payload are added. Channels in the working preset are added. Devices in the working preset are patched or added (upsert).</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="patch"><code><span class="pln">/sdrangel/config</span></code></pre>
<p>
<h3>Usage and SDK Samples</h3>
</p>
<ul class="nav nav-tabs nav-tabs-examples">
<li class="active"><a href="#examples-Instance-instanceConfigPatch-0-curl">Curl</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-java">Java</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-android">Android</a></li>
<!--<li class=""><a href="#examples-Instance-instanceConfigPatch-0-groovy">Groovy</a></li>-->
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-objc">Obj-C</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-javascript">JavaScript</a></li>
<!--<li class=""><a href="#examples-Instance-instanceConfigPatch-0-angular">Angular</a></li>-->
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-csharp">C#</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-php">PHP</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-perl">Perl</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="examples-Instance-instanceConfigPatch-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X PATCH "http://localhost/sdrangel/config"</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-java">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.*;
import SWGSDRangel.auth.*;
import SWGSDRangel.model.*;
import SWGSDRangel.api.InstanceApi;
import java.io.File;
import java.util.*;
public class InstanceApiExample {
public static void main(String[] args) {
InstanceApi apiInstance = new InstanceApi();
InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
try {
SuccessResponse result = apiInstance.instanceConfigPatch(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling InstanceApi#instanceConfigPatch");
e.printStackTrace();
}
}
}</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-android">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.api.InstanceApi;
public class InstanceApiExample {
public static void main(String[] args) {
InstanceApi apiInstance = new InstanceApi();
InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
try {
SuccessResponse result = apiInstance.instanceConfigPatch(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling InstanceApi#instanceConfigPatch");
e.printStackTrace();
}
}
}</code></pre>
</div>
<!--
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-groovy">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div> -->
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-objc">
<pre class="prettyprint"><code class="language-cpp">InstanceConfigResponse *body = ; // Config information
InstanceApi *apiInstance = [[InstanceApi alloc] init];
[apiInstance instanceConfigPatchWith:body
completionHandler: ^(SuccessResponse output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-javascript">
<pre class="prettyprint"><code class="language-js">var SdRangel = require('sd_rangel');
var api = new SdRangel.InstanceApi()
var body = ; // {InstanceConfigResponse} Config information
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.instanceConfigPatch(body, callback);
</code></pre>
</div>
<!--<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-angular">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div>-->
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-csharp">
<pre class="prettyprint"><code class="language-cs">using System;
using System.Diagnostics;
using SWGSDRangel.Api;
using SWGSDRangel.Client;
using SWGSDRangel.Model;
namespace Example
{
public class instanceConfigPatchExample
{
public void main()
{
var apiInstance = new InstanceApi();
var body = new InstanceConfigResponse(); // InstanceConfigResponse | Config information
try
{
SuccessResponse result = apiInstance.instanceConfigPatch(body);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling InstanceApi.instanceConfigPatch: " + e.Message );
}
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-php">
<pre class="prettyprint"><code class="language-php"><&#63;php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\InstanceApi();
$body = ; // InstanceConfigResponse | Config information
try {
$result = $api_instance->instanceConfigPatch($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling InstanceApi->instanceConfigPatch: ', $e->getMessage(), PHP_EOL;
}
?></code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-perl">
<pre class="prettyprint"><code class="language-perl">use Data::Dumper;
use SWGSDRangel::Configuration;
use SWGSDRangel::InstanceApi;
my $api_instance = SWGSDRangel::InstanceApi->new();
my $body = SWGSDRangel::Object::InstanceConfigResponse->new(); # InstanceConfigResponse | Config information
eval {
my $result = $api_instance->instanceConfigPatch(body => $body);
print Dumper($result);
};
if ($@) {
warn "Exception when calling InstanceApi->instanceConfigPatch: $@\n";
}</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-python">
<pre class="prettyprint"><code class="language-python">from __future__ import print_statement
import time
import swagger_sdrangel
from swagger_sdrangel.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = swagger_sdrangel.InstanceApi()
body = # InstanceConfigResponse | Config information
try:
api_response = api_instance.instance_config_patch(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling InstanceApi->instanceConfigPatch: %s\n" % e)</code></pre>
</div>
</div>
<h2>Parameters</h2>
<div class="methodsubtabletitle">Body parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<tr><td style="width:150px;">body <span style="color:red;">*</span></td>
<td>
<script>
$(document).ready(function() {
var schemaWrapper = {
"in" : "body",
"name" : "body",
"description" : "Config information",
"required" : true,
"schema" : {
"$ref" : "#/definitions/InstanceConfigResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
var view = new JSONSchemaView(schema,2,{isBodyParam: true});
var result = $('#d2e199_instanceConfigPatch_body');
result.empty();
result.append(view.render());
});
</script>
<div id="d2e199_instanceConfigPatch_body"></div>
</td>
</tr>
</table>
<h2>Responses</h2>
<h3> Status: 200 - Success </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-200-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-200-schema">
<div id='responses-instanceConfigPatch-200-schema-200' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Success",
"schema" : {
"$ref" : "#/definitions/SuccessResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-200-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-200-schema-200');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-200-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 500 - Error </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-500-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-500-schema">
<div id='responses-instanceConfigPatch-500-schema-500' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Error",
"schema" : {
"$ref" : "#/definitions/ErrorResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-500-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-500-schema-500');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-500-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 501 - Function not implemented </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-501-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-501-schema">
<div id='responses-instanceConfigPatch-501-schema-501' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Function not implemented",
"schema" : {
"$ref" : "#/definitions/ErrorResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-501-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-501-schema-501');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-501-schema-data' type='hidden' value=''></input>
</div>
</div>
</article>
</div>
<hr>
<div id="api-Instance-instanceConfigPut">
<article id="api-Instance-instanceConfigPut-0" data-group="User" data-name="instanceConfigPut" data-version="0">
<div class="pull-left">
@ -21083,7 +21473,7 @@ except ApiException as e:
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
<p class="marked">Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.</p>
<p class="marked">Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="put"><code><span class="pln">/sdrangel/config</span></code></pre>
@ -27607,7 +27997,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2019-08-08T13:54:12.590+02:00
Generated 2019-08-10T05:46:27.219+02:00
</div>
</div>
</div>

View File

@ -32,7 +32,7 @@ ChannelAnalyzerSettings:
pllPskOrder:
type: integer
inputType:
description: see ChannelAnalyzer::InputType
description: see ChannelAnalyzerSettings::InputType
type: integer
rgbColor:
type: integer

View File

@ -93,7 +93,7 @@ paths:
"501":
$ref: "#/responses/Response_501"
put:
description: Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.
description: Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.
operationId: instanceConfigPut
tags:
- Instance
@ -115,6 +115,29 @@ paths:
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
patch:
description: Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Presets and Commands if available in the payload are added. Channels in the working preset are added. Devices in the working preset are patched or added (upsert).
operationId: instanceConfigPatch
tags:
- Instance
consumes:
- application/json
parameters:
- name: body
in: body
description: Config information
required: true
schema:
$ref: "#/definitions/InstanceConfigResponse"
responses:
"200":
description: Success
schema:
$ref: "#/definitions/SuccessResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/devices:
x-swagger-router-controller: instance

View File

@ -181,30 +181,108 @@ void WebAPIAdapterBase::webapiUpdatePreset(
bool force,
SWGSDRangel::SWGPreset *apiPreset,
const WebAPIAdapterInterface::PresetKeys& presetKeys,
Preset& preset
Preset *preset
)
{
if (presetKeys.m_keys.contains("centerFrequency")) {
preset.setCenterFrequency(apiPreset->getCenterFrequency());
preset->setCenterFrequency(apiPreset->getCenterFrequency());
}
if (presetKeys.m_keys.contains("dcOffsetCorrection")) {
preset.setDCOffsetCorrection(apiPreset->getDcOffsetCorrection() != 0);
preset->setDCOffsetCorrection(apiPreset->getDcOffsetCorrection() != 0);
}
if (presetKeys.m_keys.contains("iqImbalanceCorrection")) {
preset.setIQImbalanceCorrection(apiPreset->getIqImbalanceCorrection() != 0);
preset->setIQImbalanceCorrection(apiPreset->getIqImbalanceCorrection() != 0);
}
if (presetKeys.m_keys.contains("sourcePreset")) {
preset.setSourcePreset(apiPreset->getSourcePreset() != 0);
preset->setSourcePreset(apiPreset->getSourcePreset() != 0);
}
if (presetKeys.m_keys.contains("description")) {
preset.setDescription(*apiPreset->getDescription());
preset->setDescription(*apiPreset->getDescription());
}
if (presetKeys.m_keys.contains("group")) {
preset.setGroup(*apiPreset->getGroup());
preset->setGroup(*apiPreset->getGroup());
}
GLSpectrumSettings spectrumSettings;
if (!force) {
spectrumSettings.deserialize(preset->getSpectrumConfig());
}
QStringList::const_iterator spectrumIt = presetKeys.m_spectrumKeys.begin();
for (; spectrumIt != presetKeys.m_spectrumKeys.end(); ++spectrumIt)
{
if (spectrumIt->contains("averagingMode")) {
spectrumSettings.m_averagingMode = (GLSpectrumSettings::AveragingMode) apiPreset->getSpectrumConfig()->getAveragingMode();
}
if (spectrumIt->contains("averagingValue"))
{
spectrumSettings.m_averagingNb = apiPreset->getSpectrumConfig()->getAveragingValue();
spectrumSettings.m_averagingIndex = GLSpectrumSettings::getAveragingIndex(spectrumSettings.m_averagingNb, spectrumSettings.m_averagingMode);
}
if (spectrumIt->contains("decay")) {
spectrumSettings.m_decay = apiPreset->getSpectrumConfig()->getDecay();
}
if (spectrumIt->contains("decayDivisor")) {
spectrumSettings.m_decayDivisor = apiPreset->getSpectrumConfig()->getDecayDivisor();
}
if (spectrumIt->contains("displayCurrent")) {
spectrumSettings.m_displayCurrent = apiPreset->getSpectrumConfig()->getDisplayCurrent() != 0;
}
if (spectrumIt->contains("displayGrid")) {
spectrumSettings.m_displayGrid = apiPreset->getSpectrumConfig()->getDisplayGrid() != 0;
}
if (spectrumIt->contains("displayGridIntensity")) {
spectrumSettings.m_displayGridIntensity = apiPreset->getSpectrumConfig()->getDisplayGridIntensity();
}
if (spectrumIt->contains("displayHistogram")) {
spectrumSettings.m_displayHistogram = apiPreset->getSpectrumConfig()->getDisplayHistogram() != 0;
}
if (spectrumIt->contains("displayMaxHold")) {
spectrumSettings.m_displayMaxHold = apiPreset->getSpectrumConfig()->getDisplayMaxHold() != 0;
}
if (spectrumIt->contains("displayTraceIntensity")) {
spectrumSettings.m_displayTraceIntensity = apiPreset->getSpectrumConfig()->getDisplayTraceIntensity();
}
if (spectrumIt->contains("displayWaterfall")) {
spectrumSettings.m_displayWaterfall = apiPreset->getSpectrumConfig()->getDisplayWaterfall();
}
if (spectrumIt->contains("fftOverlap")) {
spectrumSettings.m_fftOverlap = apiPreset->getSpectrumConfig()->getFftOverlap();
}
if (spectrumIt->contains("fftSize")) {
spectrumSettings.m_fftSize = apiPreset->getSpectrumConfig()->getFftSize();
}
if (spectrumIt->contains("fftWindow")) {
spectrumSettings.m_fftWindow = apiPreset->getSpectrumConfig()->getFftWindow();
}
if (spectrumIt->contains("histogramStroke")) {
spectrumSettings.m_histogramStroke = apiPreset->getSpectrumConfig()->getHistogramStroke();
}
if (spectrumIt->contains("invert")) {
spectrumSettings.m_invert = apiPreset->getSpectrumConfig()->getInvert() != 0;
}
if (spectrumIt->contains("invertedWaterfall")) {
spectrumSettings.m_invertedWaterfall = apiPreset->getSpectrumConfig()->getInvertedWaterfall() != 0;
}
if (spectrumIt->contains("linear")) {
spectrumSettings.m_linear = apiPreset->getSpectrumConfig()->getLinear() != 0;
}
if (spectrumIt->contains("powerRange")) {
spectrumSettings.m_powerRange = apiPreset->getSpectrumConfig()->getPowerRange();
}
if (spectrumIt->contains("refLevel")) {
spectrumSettings.m_refLevel = apiPreset->getSpectrumConfig()->getRefLevel();
}
if (spectrumIt->contains("waterfallShare")) {
spectrumSettings.m_waterfallShare = apiPreset->getSpectrumConfig()->getWaterfallShare();
}
}
preset->setSpectrumConfig(spectrumSettings.serialize());
if (force) { // PUT replaces devices list possibly erasing it if no devices are given
preset.clearDevices();
preset->clearDevices();
}
QString errorMessage;
@ -237,7 +315,7 @@ void WebAPIAdapterBase::webapiUpdatePreset(
{
if (!force) // In PATCH mode you must find the exact device and deserialize its current settings to be able to patch it
{
const QByteArray *config = preset.findDeviceConfig(deviceId, deviceSerial, deviceSequence);
const QByteArray *config = preset->findDeviceConfig(deviceId, deviceSerial, deviceSequence);
if (!config) {
continue;
@ -256,12 +334,12 @@ void WebAPIAdapterBase::webapiUpdatePreset(
);
QByteArray config = deviceWebAPIAdapter->serialize();
preset.setDeviceConfig(deviceId, deviceSerial, deviceSequence, config); // add or update device
preset->setDeviceConfig(deviceId, deviceSerial, deviceSequence, config); // add or update device
}
}
if (force) { // PUT replaces channel list possibly erasing it if no channels are given
preset.clearChannels();
preset->clearChannels();
}
QList<WebAPIAdapterInterface::ChannelKeys>::const_iterator channelKeysIt = presetKeys.m_channelsKeys.begin();
@ -285,15 +363,17 @@ void WebAPIAdapterBase::webapiUpdatePreset(
continue;
}
SWGSDRangel::SWGChannelSettings *channelSettings = swgChannelConfig->getConfig();
channelWebAPIAdapter->webapiSettingsPutPatch(
true, // channels are always appended
channelKeysIt->m_channelKeys,
*swgChannelConfig->getConfig(),
*channelSettings,
errorMessage
);
QByteArray config = channelWebAPIAdapter->serialize();
preset.addChannel(*channelIdURI, config);
preset->addChannel(*channelIdURI, config);
}
}
}

View File

@ -70,7 +70,7 @@ public:
bool force,
SWGSDRangel::SWGPreset *apiPreset,
const WebAPIAdapterInterface::PresetKeys& presetKeys,
Preset& preset
Preset *preset
);
static void webapiUpdateCommand(
SWGSDRangel::SWGCommand *apiCommand,

View File

@ -76,6 +76,10 @@ void WebAPIAdapterInterface::ConfigKeys::debug() const
foreach(QString presetKey, presetKeys.m_keys) {
qDebug(" %s", qPrintable(presetKey));
}
qDebug(" spectrumConfig:");
foreach(QString spectrumKey, presetKeys.m_spectrumKeys) {
qDebug(" %s", qPrintable(spectrumKey));
}
qDebug(" deviceConfigs:");
foreach(DeviceKeys deviceKeys, presetKeys.m_devicesKeys)
{
@ -103,6 +107,10 @@ void WebAPIAdapterInterface::ConfigKeys::debug() const
foreach(QString presetKey, m_workingPresetKeys.m_keys) {
qDebug(" %s", qPrintable(presetKey));
}
qDebug(" spectrumConfig:");
foreach(QString spectrumKey, m_workingPresetKeys.m_spectrumKeys) {
qDebug(" %s", qPrintable(spectrumKey));
}
qDebug(" deviceConfigs:");
foreach(DeviceKeys deviceKeys, m_workingPresetKeys.m_devicesKeys)
{

View File

@ -364,7 +364,7 @@ void WebAPIRequestMapper::instanceConfigService(qtwebapp::HttpRequest& request,
response.write(errorResponse.asJson().toUtf8());
}
}
else if (request.getMethod() == "PUT")
else if ((request.getMethod() == "PUT") || (request.getMethod() == "PATCH"))
{
QString jsonStr = request.getBody();
QJsonObject jsonObject;
@ -379,14 +379,15 @@ void WebAPIRequestMapper::instanceConfigService(qtwebapp::HttpRequest& request,
if (validateConfig(query, jsonObject, configKeys))
{
int status = m_adapter->instanceConfigPutPatch(
true,
request.getMethod() == "PUT",
query,
configKeys,
normalResponse,
errorResponse
);
response.setStatus(status);
qDebug("WebAPIRequestMapper::instanceConfigService: PUT: %d", status);
qDebug("WebAPIRequestMapper::instanceConfigService: %s: %d",
request.getMethod() == "PUT" ? "PUT" : "PATCH", status);
if (status/100 == 2)
{
@ -2311,7 +2312,7 @@ bool WebAPIRequestMapper::appendPresetKeys(
}
if (presetJson.contains("iqImbalanceCorrection"))
{
preset->setIqImbalanceCorrection(presetJson["sourcePreset"].toInt());
preset->setSourcePreset(presetJson["sourcePreset"].toInt());
presetKeys.m_keys.append("sourcePreset");
}
if (presetJson.contains("description"))
@ -2390,6 +2391,7 @@ bool WebAPIRequestMapper::appendPresetChannelKeys(
if (channelSettingsJson.contains("config") && m_channelURIToSettingsKey.contains(*channelURI))
{
SWGSDRangel::SWGChannelSettings *channelSettings = new SWGSDRangel::SWGChannelSettings();
channel->setConfig(channelSettings);
return getChannel(m_channelURIToSettingsKey[*channelURI], channelSettings, channelSettingsJson["config"].toObject(), channelKeys.m_channelKeys);
}
else
@ -2561,6 +2563,7 @@ bool WebAPIRequestMapper::appendPresetDeviceKeys(
if (deviceSettngsJson.contains("config") && m_deviceIdToSettingsKey.contains(*deviceId))
{
SWGSDRangel::SWGDeviceSettings *deviceSettings = new SWGSDRangel::SWGDeviceSettings();
device->setConfig(deviceSettings);
return getDevice(m_deviceIdToSettingsKey[*deviceId], deviceSettings, deviceSettngsJson["config"].toObject(), devicelKeys.m_deviceKeys);
}
else
@ -2763,7 +2766,6 @@ void WebAPIRequestMapper::appendSettingsSubKeys(
QStringList childSettingsKeys = childSettingsJsonObject.keys();
for (int i = 0; i < childSettingsKeys.size(); i++) {
qDebug("WebAPIRequestMapper::appendSettingsSubKeys: %s", qPrintable(childSettingsKeys.at(i)));
keyList.append(parentKey + QString(".") + childSettingsKeys.at(i));
}
}

View File

@ -229,7 +229,6 @@ QByteArray GLScopeGUI::serialize() const
bool GLScopeGUI::deserialize(const QByteArray& data)
{
qDebug("GLScopeGUI::deserialize");
SimpleDeserializer d(data);
if(!d.isValid()) {

View File

@ -85,6 +85,7 @@ void GLSpectrumGUI::resetToDefaults()
QByteArray GLSpectrumGUI::serialize() const
{
SimpleSerializer s(1);
s.writeS32(1, m_fftSize);
s.writeS32(2, m_fftOverlap);
s.writeS32(3, m_fftWindow);
@ -106,7 +107,8 @@ QByteArray GLSpectrumGUI::serialize() const
s.writeS32(19, (int) m_averagingMode);
s.writeS32(20, (qint32) getAveragingValue(m_averagingIndex));
s.writeBool(21, m_linear);
return s.final();
return s.final();
}
bool GLSpectrumGUI::deserialize(const QByteArray& data)
@ -120,7 +122,8 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
int tmp;
if(d.getVersion() == 1) {
if (d.getVersion() == 1)
{
d.readS32(1, &m_fftSize, 1024);
d.readS32(2, &m_fftOverlap, 0);
d.readS32(3, &m_fftWindow, FFTWindow::Hamming);
@ -147,10 +150,12 @@ bool GLSpectrumGUI::deserialize(const QByteArray& data)
m_averagingNb = getAveragingValue(m_averagingIndex);
d.readBool(21, &m_linear, false);
m_glSpectrum->setWaterfallShare(waterfallShare);
applySettings();
m_glSpectrum->setWaterfallShare(waterfallShare);
applySettings();
return true;
} else {
}
else
{
resetToDefaults();
return false;
}

View File

@ -89,6 +89,7 @@ MESSAGE_CLASS_DEFINITION(MainWindow::MsgSetDevice, Message)
MESSAGE_CLASS_DEFINITION(MainWindow::MsgAddChannel, Message)
MESSAGE_CLASS_DEFINITION(MainWindow::MsgDeleteChannel, Message)
MESSAGE_CLASS_DEFINITION(MainWindow::MsgDeviceSetFocus, Message)
MESSAGE_CLASS_DEFINITION(MainWindow::MsgApplySettings, Message)
MainWindow *MainWindow::m_instance = 0;
@ -204,11 +205,6 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
loadPresetSettings(m_settings.getWorkingPreset(), 0);
splash->showStatusMessage("apply settings...", Qt::white);
qDebug() << "MainWindow::MainWindow: apply settings...";
applySettings();
splash->showStatusMessage("update preset controls...", Qt::white);
qDebug() << "MainWindow::MainWindow: update preset controls...";
@ -742,17 +738,12 @@ void MainWindow::loadPresetSettings(const Preset* preset, int tabIndex)
if (tabIndex >= 0)
{
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_deviceAPI->loadSamplingDeviceSettings(preset);
if (deviceUI->m_deviceSourceEngine) // source device
{
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_deviceAPI->loadSamplingDeviceSettings(preset);
if (deviceUI->m_deviceSourceEngine) { // source device
deviceUI->loadRxChannelSettings(preset, m_pluginManager->getPluginAPI());
}
else if (deviceUI->m_deviceSinkEngine) // sink device
{
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_deviceAPI->loadSamplingDeviceSettings(preset);
} else if (deviceUI->m_deviceSinkEngine) { // sink device
deviceUI->loadTxChannelSettings(preset, m_pluginManager->getPluginAPI());
}
}
@ -920,6 +911,7 @@ QTreeWidgetItem* MainWindow::addCommandToTree(const Command* command)
void MainWindow::applySettings()
{
loadPresetSettings(m_settings.getWorkingPreset(), 0);
}
bool MainWindow::handleMessage(const Message& cmd)
@ -1034,6 +1026,11 @@ bool MainWindow::handleMessage(const Message& cmd)
ui->tabInputsView->setCurrentIndex(index);
}
}
else if (MsgApplySettings::match(cmd))
{
applySettings();
return true;
}
return false;
}
@ -1552,7 +1549,6 @@ void MainWindow::on_presetLoad_clicked()
}
loadPresetSettings(preset, ui->tabInputsView->currentIndex());
applySettings();
}
void MainWindow::on_presetDelete_clicked()

View File

@ -302,6 +302,20 @@ private:
{ }
};
class MsgApplySettings : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgApplySettings* create() {
return new MsgApplySettings();
}
private:
MsgApplySettings() :
Message()
{ }
};
static MainWindow *m_instance;
Ui::MainWindow* ui;
MessageQueue m_inputMessageQueue;

View File

@ -173,7 +173,7 @@ int WebAPIAdapterGUI::instanceConfigPutPatch(
m_mainWindow.m_settings.setPreferences(newPreferences);
Preset *workingPreset = m_mainWindow.m_settings.getWorkingPreset();
webAPIAdapterBase.webapiUpdatePreset(force, query.getWorkingPreset(), configKeys.m_workingPresetKeys, *workingPreset);
webAPIAdapterBase.webapiUpdatePreset(force, query.getWorkingPreset(), configKeys.m_workingPresetKeys, workingPreset);
QList<PresetKeys>::const_iterator presetKeysIt = configKeys.m_presetKeys.begin();
int i = 0;
@ -181,7 +181,7 @@ int WebAPIAdapterGUI::instanceConfigPutPatch(
{
Preset *newPreset = new Preset(); // created with default values
SWGSDRangel::SWGPreset *swgPreset = query.getPresets()->at(i);
webAPIAdapterBase.webapiUpdatePreset(force, swgPreset, *presetKeysIt, *newPreset);
webAPIAdapterBase.webapiUpdatePreset(force, swgPreset, *presetKeysIt, newPreset);
m_mainWindow.m_settings.addPreset(newPreset);
}
@ -194,6 +194,11 @@ int WebAPIAdapterGUI::instanceConfigPutPatch(
webAPIAdapterBase.webapiUpdateCommand(swgCommand, *commandKeysIt, *newCommand);
m_mainWindow.m_settings.addCommand(newCommand);
}
MainWindow::MsgApplySettings *msg = MainWindow::MsgApplySettings::create();
m_mainWindow.m_inputMessageQueue.push(msg);
return 200;
}
int WebAPIAdapterGUI::instanceDevices(

View File

@ -93,7 +93,7 @@ paths:
"501":
$ref: "#/responses/Response_501"
put:
description: Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.
description: Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.
operationId: instanceConfigPut
tags:
- Instance
@ -115,6 +115,29 @@ paths:
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
patch:
description: Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Presets and Commands if available in the payload are added. Channels in the working preset are added. Devices in the working preset are patched or added (upsert).
operationId: instanceConfigPatch
tags:
- Instance
consumes:
- application/json
parameters:
- name: body
in: body
description: Config information
required: true
schema:
$ref: "#/definitions/InstanceConfigResponse"
responses:
"200":
description: Success
schema:
$ref: "#/definitions/SuccessResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/devices:
x-swagger-router-controller: instance

View File

@ -1805,7 +1805,7 @@ margin-bottom: 20px;
},
"inputType" : {
"type" : "integer",
"description" : "see ChannelAnalyzer::InputType"
"description" : "see ChannelAnalyzerSettings::InputType"
},
"rgbColor" : {
"type" : "integer"
@ -6779,6 +6779,9 @@ margin-bottom: 20px;
<li data-group="Instance" data-name="instanceConfigGet" class="">
<a href="#api-Instance-instanceConfigGet">instanceConfigGet</a>
</li>
<li data-group="Instance" data-name="instanceConfigPatch" class="">
<a href="#api-Instance-instanceConfigPatch">instanceConfigPatch</a>
</li>
<li data-group="Instance" data-name="instanceConfigPut" class="">
<a href="#api-Instance-instanceConfigPut">instanceConfigPut</a>
</li>
@ -21074,6 +21077,393 @@ except ApiException as e:
</article>
</div>
<hr>
<div id="api-Instance-instanceConfigPatch">
<article id="api-Instance-instanceConfigPatch-0" data-group="User" data-name="instanceConfigPatch" data-version="0">
<div class="pull-left">
<h1>instanceConfigPatch</h1>
<p></p>
</div>
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
<p class="marked">Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Presets and Commands if available in the payload are added. Channels in the working preset are added. Devices in the working preset are patched or added (upsert).</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="patch"><code><span class="pln">/sdrangel/config</span></code></pre>
<p>
<h3>Usage and SDK Samples</h3>
</p>
<ul class="nav nav-tabs nav-tabs-examples">
<li class="active"><a href="#examples-Instance-instanceConfigPatch-0-curl">Curl</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-java">Java</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-android">Android</a></li>
<!--<li class=""><a href="#examples-Instance-instanceConfigPatch-0-groovy">Groovy</a></li>-->
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-objc">Obj-C</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-javascript">JavaScript</a></li>
<!--<li class=""><a href="#examples-Instance-instanceConfigPatch-0-angular">Angular</a></li>-->
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-csharp">C#</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-php">PHP</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-perl">Perl</a></li>
<li class=""><a href="#examples-Instance-instanceConfigPatch-0-python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="examples-Instance-instanceConfigPatch-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X PATCH "http://localhost/sdrangel/config"</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-java">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.*;
import SWGSDRangel.auth.*;
import SWGSDRangel.model.*;
import SWGSDRangel.api.InstanceApi;
import java.io.File;
import java.util.*;
public class InstanceApiExample {
public static void main(String[] args) {
InstanceApi apiInstance = new InstanceApi();
InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
try {
SuccessResponse result = apiInstance.instanceConfigPatch(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling InstanceApi#instanceConfigPatch");
e.printStackTrace();
}
}
}</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-android">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.api.InstanceApi;
public class InstanceApiExample {
public static void main(String[] args) {
InstanceApi apiInstance = new InstanceApi();
InstanceConfigResponse body = ; // InstanceConfigResponse | Config information
try {
SuccessResponse result = apiInstance.instanceConfigPatch(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling InstanceApi#instanceConfigPatch");
e.printStackTrace();
}
}
}</code></pre>
</div>
<!--
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-groovy">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div> -->
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-objc">
<pre class="prettyprint"><code class="language-cpp">InstanceConfigResponse *body = ; // Config information
InstanceApi *apiInstance = [[InstanceApi alloc] init];
[apiInstance instanceConfigPatchWith:body
completionHandler: ^(SuccessResponse output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-javascript">
<pre class="prettyprint"><code class="language-js">var SdRangel = require('sd_rangel');
var api = new SdRangel.InstanceApi()
var body = ; // {InstanceConfigResponse} Config information
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.instanceConfigPatch(body, callback);
</code></pre>
</div>
<!--<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-angular">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div>-->
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-csharp">
<pre class="prettyprint"><code class="language-cs">using System;
using System.Diagnostics;
using SWGSDRangel.Api;
using SWGSDRangel.Client;
using SWGSDRangel.Model;
namespace Example
{
public class instanceConfigPatchExample
{
public void main()
{
var apiInstance = new InstanceApi();
var body = new InstanceConfigResponse(); // InstanceConfigResponse | Config information
try
{
SuccessResponse result = apiInstance.instanceConfigPatch(body);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling InstanceApi.instanceConfigPatch: " + e.Message );
}
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-php">
<pre class="prettyprint"><code class="language-php"><&#63;php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\InstanceApi();
$body = ; // InstanceConfigResponse | Config information
try {
$result = $api_instance->instanceConfigPatch($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling InstanceApi->instanceConfigPatch: ', $e->getMessage(), PHP_EOL;
}
?></code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-perl">
<pre class="prettyprint"><code class="language-perl">use Data::Dumper;
use SWGSDRangel::Configuration;
use SWGSDRangel::InstanceApi;
my $api_instance = SWGSDRangel::InstanceApi->new();
my $body = SWGSDRangel::Object::InstanceConfigResponse->new(); # InstanceConfigResponse | Config information
eval {
my $result = $api_instance->instanceConfigPatch(body => $body);
print Dumper($result);
};
if ($@) {
warn "Exception when calling InstanceApi->instanceConfigPatch: $@\n";
}</code></pre>
</div>
<div class="tab-pane" id="examples-Instance-instanceConfigPatch-0-python">
<pre class="prettyprint"><code class="language-python">from __future__ import print_statement
import time
import swagger_sdrangel
from swagger_sdrangel.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = swagger_sdrangel.InstanceApi()
body = # InstanceConfigResponse | Config information
try:
api_response = api_instance.instance_config_patch(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling InstanceApi->instanceConfigPatch: %s\n" % e)</code></pre>
</div>
</div>
<h2>Parameters</h2>
<div class="methodsubtabletitle">Body parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<tr><td style="width:150px;">body <span style="color:red;">*</span></td>
<td>
<script>
$(document).ready(function() {
var schemaWrapper = {
"in" : "body",
"name" : "body",
"description" : "Config information",
"required" : true,
"schema" : {
"$ref" : "#/definitions/InstanceConfigResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
var view = new JSONSchemaView(schema,2,{isBodyParam: true});
var result = $('#d2e199_instanceConfigPatch_body');
result.empty();
result.append(view.render());
});
</script>
<div id="d2e199_instanceConfigPatch_body"></div>
</td>
</tr>
</table>
<h2>Responses</h2>
<h3> Status: 200 - Success </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-200-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-200-schema">
<div id='responses-instanceConfigPatch-200-schema-200' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Success",
"schema" : {
"$ref" : "#/definitions/SuccessResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-200-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-200-schema-200');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-200-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 500 - Error </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-500-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-500-schema">
<div id='responses-instanceConfigPatch-500-schema-500' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Error",
"schema" : {
"$ref" : "#/definitions/ErrorResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-500-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-500-schema-500');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-500-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 501 - Function not implemented </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-instanceConfigPatch-501-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-instanceConfigPatch-501-schema">
<div id='responses-instanceConfigPatch-501-schema-501' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "Function not implemented",
"schema" : {
"$ref" : "#/definitions/ErrorResponse"
}
};
var schema = schemaWrapper.schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.definitions = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-instanceConfigPatch-501-schema-data').val(stringify(schema));
var result = $('#responses-instanceConfigPatch-501-schema-501');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-instanceConfigPatch-501-schema-data' type='hidden' value=''></input>
</div>
</div>
</article>
</div>
<hr>
<div id="api-Instance-instanceConfigPut">
<article id="api-Instance-instanceConfigPut-0" data-group="User" data-name="instanceConfigPut" data-version="0">
<div class="pull-left">
@ -21083,7 +21473,7 @@ except ApiException as e:
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
<p class="marked">Replace the Preferences, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.</p>
<p class="marked">Replace the Preferences, Working preset, Presets and Commands of the MainSettings object with the contents of the payload. Supports config restore.</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="put"><code><span class="pln">/sdrangel/config</span></code></pre>
@ -27607,7 +27997,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2019-08-08T13:54:12.590+02:00
Generated 2019-08-10T05:46:27.219+02:00
</div>
</div>
</div>

View File

@ -782,6 +782,61 @@ SWGInstanceApi::instanceConfigGetCallback(SWGHttpRequestWorker * worker) {
}
}
void
SWGInstanceApi::instanceConfigPatch(SWGInstanceConfigResponse& body) {
QString fullPath;
fullPath.append(this->host).append(this->basePath).append("/sdrangel/config");
SWGHttpRequestWorker *worker = new SWGHttpRequestWorker();
SWGHttpRequestInput 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,
&SWGHttpRequestWorker::on_execution_finished,
this,
&SWGInstanceApi::instanceConfigPatchCallback);
worker->execute(&input);
}
void
SWGInstanceApi::instanceConfigPatchCallback(SWGHttpRequestWorker * 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);
SWGSuccessResponse* output = static_cast<SWGSuccessResponse*>(create(json, QString("SWGSuccessResponse")));
worker->deleteLater();
if (worker->error_type == QNetworkReply::NoError) {
emit instanceConfigPatchSignal(output);
} else {
emit instanceConfigPatchSignalE(output, error_type, error_str);
emit instanceConfigPatchSignalEFull(worker, error_type, error_str);
}
}
void
SWGInstanceApi::instanceConfigPut(SWGInstanceConfigResponse& body) {
QString fullPath;

View File

@ -65,6 +65,7 @@ public:
void instanceAudioOutputPatch(SWGAudioOutputDevice& body);
void instanceChannels(qint32 direction);
void instanceConfigGet();
void instanceConfigPatch(SWGInstanceConfigResponse& body);
void instanceConfigPut(SWGInstanceConfigResponse& body);
void instanceDelete();
void instanceDeviceSetsGet();
@ -97,6 +98,7 @@ private:
void instanceAudioOutputPatchCallback (SWGHttpRequestWorker * worker);
void instanceChannelsCallback (SWGHttpRequestWorker * worker);
void instanceConfigGetCallback (SWGHttpRequestWorker * worker);
void instanceConfigPatchCallback (SWGHttpRequestWorker * worker);
void instanceConfigPutCallback (SWGHttpRequestWorker * worker);
void instanceDeleteCallback (SWGHttpRequestWorker * worker);
void instanceDeviceSetsGetCallback (SWGHttpRequestWorker * worker);
@ -129,6 +131,7 @@ signals:
void instanceAudioOutputPatchSignal(SWGAudioOutputDevice* summary);
void instanceChannelsSignal(SWGInstanceChannelsResponse* summary);
void instanceConfigGetSignal(SWGInstanceConfigResponse* summary);
void instanceConfigPatchSignal(SWGSuccessResponse* summary);
void instanceConfigPutSignal(SWGSuccessResponse* summary);
void instanceDeleteSignal(SWGInstanceSummaryResponse* summary);
void instanceDeviceSetsGetSignal(SWGDeviceSetList* summary);
@ -160,6 +163,7 @@ signals:
void instanceAudioOutputPatchSignalE(SWGAudioOutputDevice* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceChannelsSignalE(SWGInstanceChannelsResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigGetSignalE(SWGInstanceConfigResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigPatchSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigPutSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeleteSignalE(SWGInstanceSummaryResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeviceSetsGetSignalE(SWGDeviceSetList* summary, QNetworkReply::NetworkError error_type, QString& error_str);
@ -191,6 +195,7 @@ signals:
void instanceAudioOutputPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceChannelsSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceConfigPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);
void instanceDeviceSetsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str);