Web API: implemented device report interface. Applied to Airspy

This commit is contained in:
f4exb
2018-05-26 01:43:28 +02:00
parent ae07298387
commit f8f976fd50
26 changed files with 1905 additions and 2 deletions
+6
View File
@@ -29,6 +29,7 @@ namespace SWGSDRangel
{
class SWGDeviceSettings;
class SWGDeviceState;
class SWGDeviceReport;
}
class SDRBASE_API DeviceSampleSink : public QObject {
@@ -74,6 +75,11 @@ public:
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }
virtual int webapiReportGet(
SWGSDRangel::SWGDeviceReport& response __attribute__((unused)),
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setMessageQueueToGUI(MessageQueue *queue) = 0; // pure virtual so that child classes must have to deal with this
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
+6
View File
@@ -30,6 +30,7 @@ namespace SWGSDRangel
{
class SWGDeviceSettings;
class SWGDeviceState;
class SWGDeviceReport;
}
class SDRBASE_API DeviceSampleSource : public QObject {
@@ -81,6 +82,11 @@ public:
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }
virtual int webapiReportGet(
SWGSDRangel::SWGDeviceReport& response __attribute__((unused)),
QString& errorMessage)
{ errorMessage = "Not implemented"; return 501; }
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual void setMessageQueueToGUI(MessageQueue *queue) = 0; // pure virtual so that child classes must have to deal with this
MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; }
+3
View File
@@ -3,6 +3,7 @@
<file>webapi/doc/html2/index.html</file>
<file>webapi/doc/swagger/swagger.yaml</file>
<file>webapi/doc/swagger/include/CWKeyer.yaml</file>
<file>webapi/doc/swagger/include/Airspy.yaml</file>
<file>webapi/doc/swagger/include/AirspyHF.yaml</file>
<file>webapi/doc/swagger/include/BladeRF.yaml</file>
<file>webapi/doc/swagger/include/FileSource.yaml</file>
@@ -17,6 +18,8 @@
<file>webapi/doc/swagger/include/NFMMod.yaml</file>
<file>webapi/doc/swagger/include/SSBMod.yaml</file>
<file>webapi/doc/swagger/include/UDPSink.yaml</file>
<file>webapi/doc/swagger/include/UDPSrc.yaml</file>
<file>webapi/doc/swagger/include/WFMDemod.yaml</file>
<file>webapi/doc/swagger/include/WFMMod.yaml</file>
<file>webapi/doc/swagger/include/RtlSdr.yaml</file>
<file>webapi/doc/swagger-ui/swagger-ui.js.map</file>
+502 -1
View File
@@ -942,6 +942,25 @@ margin-bottom: 20px;
}
},
"description" : "AirspyHF"
};
defs.AirspyReport = {
"properties" : {
"sampleRates" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/AirspyReport_sampleRates"
}
}
},
"description" : "Airspy"
};
defs.AirspyReport_sampleRates = {
"properties" : {
"sampleRate" : {
"type" : "integer",
"description" : "sample rate in S/s"
}
}
};
defs.AirspySettings = {
"properties" : {
@@ -1663,6 +1682,24 @@ margin-bottom: 20px;
}
},
"description" : "Summarized information about attached hardware device"
};
defs.DeviceReport = {
"required" : [ "deviceHwType", "tx" ],
"discriminator" : "deviceHwType",
"properties" : {
"deviceHwType" : {
"type" : "string",
"description" : "Device hardware type code"
},
"tx" : {
"type" : "integer",
"description" : "Not zero if it is a tx device else it is a rx device"
},
"airspyReport" : {
"$ref" : "#/definitions/AirspyReport"
}
},
"description" : "Base device report. The specific device report present depeds on deviceHwType"
};
defs.DeviceSet = {
"required" : [ "channelcount", "samplingDevice" ],
@@ -2988,6 +3025,9 @@ margin-bottom: 20px;
<li data-group="DeviceSet" data-name="devicesetDevicePut" class="">
<a href="#api-DeviceSet-devicesetDevicePut">devicesetDevicePut</a>
</li>
<li data-group="DeviceSet" data-name="devicesetDeviceReportGet" class="">
<a href="#api-DeviceSet-devicesetDeviceReportGet">devicesetDeviceReportGet</a>
</li>
<li data-group="DeviceSet" data-name="devicesetDeviceRunDelete" class="">
<a href="#api-DeviceSet-devicesetDeviceRunDelete">devicesetDeviceRunDelete</a>
</li>
@@ -7189,6 +7229,467 @@ $(document).ready(function() {
</article>
</div>
<hr>
<div id="api-DeviceSet-devicesetDeviceReportGet">
<article id="api-DeviceSet-devicesetDeviceReportGet-0" data-group="User" data-name="devicesetDeviceReportGet" data-version="0">
<div class="pull-left">
<h1>devicesetDeviceReportGet</h1>
<p></p>
</div>
<div class="pull-right"></div>
<div class="clearfix"></div>
<p></p>
<p class="marked">get the device report</p>
<p></p>
<br />
<pre class="prettyprint language-html prettyprinted" data-type="get"><code><span class="pln">/sdrangel/deviceset/{deviceSetIndex}/device/report</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-DeviceSet-devicesetDeviceReportGet-0-curl">Curl</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-java">Java</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-android">Android</a></li>
<!--<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-groovy">Groovy</a></li>-->
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-objc">Obj-C</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-javascript">JavaScript</a></li>
<!--<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-angular">Angular</a></li>-->
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-csharp">C#</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-php">PHP</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-perl">Perl</a></li>
<li class=""><a href="#examples-DeviceSet-devicesetDeviceReportGet-0-python">Python</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="examples-DeviceSet-devicesetDeviceReportGet-0-curl">
<pre class="prettyprint"><code class="language-bsh">curl -X GET "http://localhost/sdrangel/deviceset/{deviceSetIndex}/device/report"</code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-java">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.*;
import SWGSDRangel.auth.*;
import SWGSDRangel.model.*;
import SWGSDRangel.api.DeviceSetApi;
import java.io.File;
import java.util.*;
public class DeviceSetApiExample {
public static void main(String[] args) {
DeviceSetApi apiInstance = new DeviceSetApi();
Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list
try {
DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
e.printStackTrace();
}
}
}</code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-android">
<pre class="prettyprint"><code class="language-java">import SWGSDRangel.api.DeviceSetApi;
public class DeviceSetApiExample {
public static void main(String[] args) {
DeviceSetApi apiInstance = new DeviceSetApi();
Integer deviceSetIndex = 56; // Integer | Index of device set in the device set list
try {
DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
e.printStackTrace();
}
}
}</code></pre>
</div>
<!--
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-groovy">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div> -->
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-objc">
<pre class="prettyprint"><code class="language-cpp">Integer *deviceSetIndex = 56; // Index of device set in the device set list
DeviceSetApi *apiInstance = [[DeviceSetApi alloc] init];
[apiInstance devicesetDeviceReportGetWith:deviceSetIndex
completionHandler: ^(DeviceReport output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
</code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-javascript">
<pre class="prettyprint"><code class="language-js">var SdRangel = require('sd_rangel');
var api = new SdRangel.DeviceSetApi()
var deviceSetIndex = 56; // {Integer} Index of device set in the device set list
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.devicesetDeviceReportGet(deviceSetIndex, callback);
</code></pre>
</div>
<!--<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-angular">
<pre class="prettyprint language-json prettyprinted" data-type="json"><code>Coming Soon!</code></pre>
</div>-->
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-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 devicesetDeviceReportGetExample
{
public void main()
{
var apiInstance = new DeviceSetApi();
var deviceSetIndex = 56; // Integer | Index of device set in the device set list
try
{
DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling DeviceSetApi.devicesetDeviceReportGet: " + e.Message );
}
}
}
}
</code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-php">
<pre class="prettyprint"><code class="language-php"><&#63;php
require_once(__DIR__ . '/vendor/autoload.php');
$api_instance = new Swagger\Client\Api\DeviceSetApi();
$deviceSetIndex = 56; // Integer | Index of device set in the device set list
try {
$result = $api_instance->devicesetDeviceReportGet($deviceSetIndex);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DeviceSetApi->devicesetDeviceReportGet: ', $e->getMessage(), PHP_EOL;
}
?></code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-0-perl">
<pre class="prettyprint"><code class="language-perl">use Data::Dumper;
use SWGSDRangel::Configuration;
use SWGSDRangel::DeviceSetApi;
my $api_instance = SWGSDRangel::DeviceSetApi->new();
my $deviceSetIndex = 56; # Integer | Index of device set in the device set list
eval {
my $result = $api_instance->devicesetDeviceReportGet(deviceSetIndex => $deviceSetIndex);
print Dumper($result);
};
if ($@) {
warn "Exception when calling DeviceSetApi->devicesetDeviceReportGet: $@\n";
}</code></pre>
</div>
<div class="tab-pane" id="examples-DeviceSet-devicesetDeviceReportGet-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.DeviceSetApi()
deviceSetIndex = 56 # Integer | Index of device set in the device set list
try:
api_response = api_instance.deviceset_device_report_get(deviceSetIndex)
pprint(api_response)
except ApiException as e:
print("Exception when calling DeviceSetApi->devicesetDeviceReportGet: %s\n" % e)</code></pre>
</div>
</div>
<h2>Parameters</h2>
<div class="methodsubtabletitle">Path parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<tr><td style="width:150px;">deviceSetIndex*</td>
<td>
<div id="d2e199_devicesetDeviceReportGet_deviceSetIndex">
<div class="json-schema-view">
<div class="primitive">
<span class="type">
Integer
</span>
<div class="inner description">
Index of device set in the device set list
</div>
</div>
<div class="inner required">
Required
</div>
</div>
</div>
</td>
</tr>
</table>
<h2>Responses</h2>
<h3> Status: 200 - On success return device report </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-devicesetDeviceReportGet-200-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-devicesetDeviceReportGet-200-schema">
<div id='responses-devicesetDeviceReportGet-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" : "On success return device report",
"schema" : {
"$ref" : "#/definitions/DeviceReport"
}
};
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-devicesetDeviceReportGet-200-schema-data').val(stringify(schema));
var result = $('#responses-devicesetDeviceReportGet-200-schema-200');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-devicesetDeviceReportGet-200-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 400 - Invalid device set </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-devicesetDeviceReportGet-400-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-devicesetDeviceReportGet-400-schema">
<div id='responses-devicesetDeviceReportGet-400-schema-400' 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" : "Invalid device set",
"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-devicesetDeviceReportGet-400-schema-data').val(stringify(schema));
var result = $('#responses-devicesetDeviceReportGet-400-schema-400');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-devicesetDeviceReportGet-400-schema-data' type='hidden' value=''></input>
</div>
</div>
<h3> Status: 404 - Device not found </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-devicesetDeviceReportGet-404-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-devicesetDeviceReportGet-404-schema">
<div id='responses-devicesetDeviceReportGet-404-schema-404' 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" : "Device not found",
"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-devicesetDeviceReportGet-404-schema-data').val(stringify(schema));
var result = $('#responses-devicesetDeviceReportGet-404-schema-404');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-devicesetDeviceReportGet-404-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-devicesetDeviceReportGet-500-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-devicesetDeviceReportGet-500-schema">
<div id='responses-devicesetDeviceReportGet-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-devicesetDeviceReportGet-500-schema-data').val(stringify(schema));
var result = $('#responses-devicesetDeviceReportGet-500-schema-500');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-devicesetDeviceReportGet-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-devicesetDeviceReportGet-501-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-devicesetDeviceReportGet-501-schema">
<div id='responses-devicesetDeviceReportGet-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-devicesetDeviceReportGet-501-schema-data').val(stringify(schema));
var result = $('#responses-devicesetDeviceReportGet-501-schema-501');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-devicesetDeviceReportGet-501-schema-data' type='hidden' value=''></input>
</div>
</div>
</article>
</div>
<hr>
<div id="api-DeviceSet-devicesetDeviceRunDelete">
<article id="api-DeviceSet-devicesetDeviceRunDelete-0" data-group="User" data-name="devicesetDeviceRunDelete" data-version="0">
<div class="pull-left">
@@ -21180,7 +21681,7 @@ except ApiException as e:
</div>
<div id="generator">
<div class="content">
Generated 2018-05-25T18:55:39.036+02:00
Generated 2018-05-26T00:44:20.967+02:00
</div>
</div>
</div>
@@ -39,4 +39,16 @@ AirspySettings:
format: int64
fileRecordName:
type: string
AirspyReport:
description: Airspy
properties:
sampleRates:
type: array
items:
properties:
sampleRate:
description: sample rate in S/s
type: integer
@@ -936,6 +936,38 @@ paths:
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/deviceset/{deviceSetIndex}/device/report:
x-swagger-router-controller: deviceset
get:
description: get the device report
operationId: devicesetDeviceReportGet
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 device report
schema:
$ref: "#/definitions/DeviceReport"
"400":
description: Invalid device set
schema:
$ref: "#/definitions/ErrorResponse"
"404":
description: Device not found
schema:
$ref: "#/definitions/ErrorResponse"
"500":
$ref: "#/responses/Response_500"
"501":
$ref: "#/responses/Response_501"
/sdrangel/deviceset/{deviceSetIndex}/channels/report:
x-swagger-router-controller: deviceset
@@ -1734,6 +1766,22 @@ definitions:
rtlSdrSettings:
$ref: "/doc/swagger/include/RtlSdr.yaml#/RtlSdrSettings"
DeviceReport:
description: Base device report. The specific device report present depeds on deviceHwType
discriminator: deviceHwType
required:
- deviceHwType
- tx
properties:
deviceHwType:
description: Device hardware type code
type: string
tx:
description: Not zero if it is a tx device else it is a rx device
type: integer
airspyReport:
$ref: "/doc/swagger/include/Airspy.yaml#/AirspyReport"
ChannelSettings:
description: Base channel settings. The specific channel settings present depends on channelType.
discriminator: channelType
@@ -40,6 +40,7 @@ std::regex WebAPIAdapterInterface::devicesetFocusURLRe("^/sdrangel/deviceset/([0
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");
std::regex WebAPIAdapterInterface::devicesetDeviceReportURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device/report$");
std::regex WebAPIAdapterInterface::devicesetChannelsReportURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channels/report$");
std::regex WebAPIAdapterInterface::devicesetChannelURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel$");
std::regex WebAPIAdapterInterface::devicesetChannelIndexURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})$");
+16
View File
@@ -47,6 +47,7 @@ namespace SWGSDRangel
class SWGDeviceListItem;
class SWGDeviceSettings;
class SWGDeviceState;
class SWGDeviceReport;
class SWGChannelsDetail;
class SWGChannelSettings;
class SWGChannelReport;
@@ -523,6 +524,20 @@ public:
return 501;
}
/**
* Handler of /sdrangel/deviceset/{devicesetIndex}/device/report (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
*/
virtual int devicesetDeviceReportGet(
int deviceSetIndex __attribute__((unused)),
SWGSDRangel::SWGDeviceReport& response __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error)
{
error.init();
*error.getMessage() = QString("Function not implemented");
return 501;
}
/**
* Handler of /sdrangel/deviceset/{devicesetIndex}/channels/report (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
@@ -636,6 +651,7 @@ public:
static std::regex devicesetDeviceURLRe;
static std::regex devicesetDeviceSettingsURLRe;
static std::regex devicesetDeviceRunURLRe;
static std::regex devicesetDeviceReportURLRe;
static std::regex devicesetChannelURLRe;
static std::regex devicesetChannelIndexURLRe;
static std::regex devicesetChannelSettingsURLRe;
+40
View File
@@ -38,6 +38,7 @@
#include "SWGPresetExport.h"
#include "SWGDeviceSettings.h"
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGChannelsDetail.h"
#include "SWGChannelSettings.h"
#include "SWGChannelReport.h"
@@ -122,6 +123,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
devicesetDeviceSettingsService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceRunURLRe)) {
devicesetDeviceRunService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceReportURLRe)) {
devicesetDeviceReportService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelsReportURLRe)) {
devicesetChannelsReportService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelURLRe)) {
@@ -1241,6 +1244,43 @@ void WebAPIRequestMapper::devicesetDeviceRunService(const std::string& indexStr,
}
}
void WebAPIRequestMapper::devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
response.setHeader("Content-Type", "application/json");
if (request.getMethod() == "GET")
{
try
{
SWGSDRangel::SWGDeviceReport normalResponse;
int deviceSetIndex = boost::lexical_cast<int>(indexStr);
int status = m_adapter->devicesetDeviceReportGet(deviceSetIndex, normalResponse, errorResponse);
response.setStatus(status);
if (status/100 == 2) {
response.write(normalResponse.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
catch (const boost::bad_lexical_cast &e)
{
errorResponse.init();
*errorResponse.getMessage() = "Wrong integer conversion on device set index";
response.setStatus(400,"Invalid data");
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(405,"Invalid HTTP method");
errorResponse.init();
*errorResponse.getMessage() = "Invalid HTTP method";
response.write(errorResponse.asJson().toUtf8());
}
}
void WebAPIRequestMapper::devicesetChannelsReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
+1
View File
@@ -69,6 +69,7 @@ private:
void devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetDeviceSettingsService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetDeviceRunService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetDeviceReportService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetChannelsReportService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetChannelService(const std::string& deviceSetIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void devicesetChannelIndexService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);