From d4e1521c903b0e271bbf45fc5629303b492f8448 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 18 Mar 2018 20:17:11 +0100 Subject: [PATCH] Web API: new entry point to get a channel report. Applied to NFM mod and demod --- plugins/channelrx/demodnfm/nfmdemod.cpp | 23 + plugins/channelrx/demodnfm/nfmdemod.h | 5 + plugins/channeltx/modnfm/nfmmod.cpp | 18 + plugins/channeltx/modnfm/nfmmod.h | 5 + sdrbase/channel/channelsinkapi.h | 6 + sdrbase/channel/channelsourceapi.h | 6 + sdrbase/resources/webapi/doc/html2/index.html | 553 +++++++++++++++++- .../webapi/doc/swagger/include/NFMDemod.yaml | 16 +- .../webapi/doc/swagger/include/NFMMod.yaml | 8 + .../resources/webapi/doc/swagger/swagger.yaml | 59 +- sdrbase/webapi/webapiadapterinterface.cpp | 1 + sdrbase/webapi/webapiadapterinterface.h | 18 + sdrbase/webapi/webapirequestmapper.cpp | 100 ++++ sdrbase/webapi/webapirequestmapper.h | 3 + sdrgui/webapi/webapiadaptergui.cpp | 61 ++ sdrgui/webapi/webapiadaptergui.h | 6 + .../api/swagger/include/NFMDemod.yaml | 16 +- .../sdrangel/api/swagger/include/NFMMod.yaml | 8 + swagger/sdrangel/api/swagger/swagger.yaml | 59 +- swagger/sdrangel/code/html2/index.html | 553 +++++++++++++++++- .../code/qt5/client/SWGChannelReport.cpp | 175 ++++++ .../code/qt5/client/SWGChannelReport.h | 78 +++ .../code/qt5/client/SWGChannelSettings.h | 2 +- .../code/qt5/client/SWGDeviceSetApi.cpp | 56 ++ .../code/qt5/client/SWGDeviceSetApi.h | 6 + .../code/qt5/client/SWGDeviceSettings.h | 2 +- .../code/qt5/client/SWGModelFactory.h | 12 + .../code/qt5/client/SWGNFMDemodReport.cpp | 148 +++++ .../code/qt5/client/SWGNFMDemodReport.h | 69 +++ .../code/qt5/client/SWGNFMModReport.cpp | 106 ++++ .../code/qt5/client/SWGNFMModReport.h | 57 ++ 31 files changed, 2221 insertions(+), 14 deletions(-) create mode 100644 swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGChannelReport.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.h create mode 100644 swagger/sdrangel/code/qt5/client/SWGNFMModReport.cpp create mode 100644 swagger/sdrangel/code/qt5/client/SWGNFMModReport.h diff --git a/plugins/channelrx/demodnfm/nfmdemod.cpp b/plugins/channelrx/demodnfm/nfmdemod.cpp index e252d8ef6..93f91cf98 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.cpp +++ b/plugins/channelrx/demodnfm/nfmdemod.cpp @@ -22,9 +22,12 @@ #include "SWGChannelSettings.h" #include "SWGNFMDemodSettings.h" +#include "SWGChannelReport.h" +#include "SWGNFMDemodReport.h" #include "dsp/downchannelizer.h" #include "util/stepfunctions.h" +#include "util/db.h" #include "audio/audiooutput.h" #include "dsp/dspengine.h" #include "dsp/threadedbasebandsamplesink.h" @@ -643,6 +646,16 @@ int NFMDemod::webapiSettingsPutPatch( return 200; } +int NFMDemod::webapiReportGet( + SWGSDRangel::SWGChannelReport& response, + QString& errorMessage __attribute__((unused))) +{ + response.setNfmDemodReport(new SWGSDRangel::SWGNFMDemodReport()); + response.getNfmDemodReport()->init(); + webapiFormatChannelReport(response); + return 200; +} + void NFMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings) { response.getNfmDemodSettings()->setAfBandwidth(settings.m_afBandwidth); @@ -675,3 +688,13 @@ void NFMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& resp } } +void NFMDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) +{ + double magsqAvg, magsqPeak; + int nbMagsqSamples; + getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); + + response.getNfmDemodReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); + response.getNfmDemodReport()->setCtcssTone(m_settings.m_ctcssOn ? (m_ctcssIndex ? 0 : m_ctcssDetector.getToneSet()[m_ctcssIndex-1]) : 0); + response.getNfmDemodReport()->setSquelch(m_squelchOpen ? 1 : 0); +} diff --git a/plugins/channelrx/demodnfm/nfmdemod.h b/plugins/channelrx/demodnfm/nfmdemod.h index eea637641..54e397495 100644 --- a/plugins/channelrx/demodnfm/nfmdemod.h +++ b/plugins/channelrx/demodnfm/nfmdemod.h @@ -136,6 +136,10 @@ public: SWGSDRangel::SWGChannelSettings& response, QString& errorMessage); + virtual int webapiReportGet( + SWGSDRangel::SWGChannelReport& response, + QString& errorMessage); + const Real *getCtcssToneSet(int& nbTones) const { nbTones = m_ctcssDetector.getNTones(); return m_ctcssDetector.getToneSet(); @@ -220,6 +224,7 @@ private: void applyChannelSettings(int inputSampleRate, int inputFrequencyOffset, bool force = false); void applySettings(const NFMDemodSettings& settings, bool force = false); void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMDemodSettings& settings); + void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); }; #endif // INCLUDE_NFMDEMOD_H diff --git a/plugins/channeltx/modnfm/nfmmod.cpp b/plugins/channeltx/modnfm/nfmmod.cpp index 9f68c2a10..8648cb257 100644 --- a/plugins/channeltx/modnfm/nfmmod.cpp +++ b/plugins/channeltx/modnfm/nfmmod.cpp @@ -20,6 +20,8 @@ #include "SWGChannelSettings.h" #include "SWGCWKeyerSettings.h" +#include "SWGChannelReport.h" +#include "SWGNFMModReport.h" #include #include @@ -30,6 +32,7 @@ #include "dsp/dspcommands.h" #include "device/devicesinkapi.h" #include "dsp/threadedbasebandsamplesource.h" +#include "util/db.h" #include "nfmmod.h" @@ -625,6 +628,16 @@ int NFMMod::webapiSettingsPutPatch( return 200; } +int NFMMod::webapiReportGet( + SWGSDRangel::SWGChannelReport& response, + QString& errorMessage __attribute__((unused))) +{ + response.setNfmModReport(new SWGSDRangel::SWGNFMModReport()); + response.getNfmModReport()->init(); + webapiFormatChannelReport(response); + return 200; +} + void NFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMModSettings& settings) { response.getNfmModSettings()->setAfBandwidth(settings.m_afBandwidth); @@ -666,3 +679,8 @@ void NFMMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respon apiCwKeyerSettings->setWpm(cwKeyerSettings.m_wpm); } + +void NFMMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) +{ + response.getNfmModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq())); +} diff --git a/plugins/channeltx/modnfm/nfmmod.h b/plugins/channeltx/modnfm/nfmmod.h index 9276b10b1..4cfcdf70d 100644 --- a/plugins/channeltx/modnfm/nfmmod.h +++ b/plugins/channeltx/modnfm/nfmmod.h @@ -227,6 +227,10 @@ public: SWGSDRangel::SWGChannelSettings& response, QString& errorMessage); + virtual int webapiReportGet( + SWGSDRangel::SWGChannelReport& response, + QString& errorMessage); + double getMagSq() const { return m_magsq; } CWKeyer *getCWKeyer() { return &m_cwKeyer; } @@ -302,6 +306,7 @@ private: void openFileStream(); void seekFileStream(int seekPercentage); void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& response, const NFMModSettings& settings); + void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); }; diff --git a/sdrbase/channel/channelsinkapi.h b/sdrbase/channel/channelsinkapi.h index a2c2f9b1b..fab5bc276 100644 --- a/sdrbase/channel/channelsinkapi.h +++ b/sdrbase/channel/channelsinkapi.h @@ -28,6 +28,7 @@ namespace SWGSDRangel { class SWGChannelSettings; + class SWGChannelReport; } class SDRBASE_API ChannelSinkAPI { @@ -57,6 +58,11 @@ public: QString& errorMessage) { errorMessage = "Not implemented"; return 501; } + virtual int webapiReportGet( + SWGSDRangel::SWGChannelReport& response __attribute__((unused)), + QString& errorMessage) + { errorMessage = "Not implemented"; return 501; } + int getIndexInDeviceSet() const { return m_indexInDeviceSet; } void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; } uint64_t getUID() const { return m_uid; } diff --git a/sdrbase/channel/channelsourceapi.h b/sdrbase/channel/channelsourceapi.h index 18734b8f1..5d943ed6d 100644 --- a/sdrbase/channel/channelsourceapi.h +++ b/sdrbase/channel/channelsourceapi.h @@ -27,6 +27,7 @@ namespace SWGSDRangel { class SWGChannelSettings; + class SWGChannelReport; } class SDRBASE_API ChannelSourceAPI { @@ -56,6 +57,11 @@ public: QString& errorMessage) { errorMessage = "Not implemented"; return 501; } + virtual int webapiReportGet( + SWGSDRangel::SWGChannelReport& response __attribute__((unused)), + QString& errorMessage) + { errorMessage = "Not implemented"; return 501; } + int getIndexInDeviceSet() const { return m_indexInDeviceSet; } void setIndexInDeviceSet(int indexInDeviceSet) { m_indexInDeviceSet = indexInDeviceSet; } uint64_t getUID() const { return m_uid; } diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index faedb146f..8f924b78d 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -840,6 +840,27 @@ margin-bottom: 20px; } }, "description" : "Summarized information about channel plugin" +}; + defs.ChannelReport = { + "required" : [ "channelType", "tx" ], + "discriminator" : "channelType", + "properties" : { + "channelType" : { + "type" : "string", + "description" : "Channel type code" + }, + "tx" : { + "type" : "integer", + "description" : "Not zero if it is a tx channel else it is a rx channel" + }, + "NFMDemodReport" : { + "$ref" : "#/definitions/NFMDemodReport" + }, + "NFMModReport" : { + "$ref" : "#/definitions/NFMModReport" + } + }, + "description" : "Base channel report. The specific channel report present depends on channelType." }; defs.ChannelSettings = { "required" : [ "channelType", "tx" ], @@ -860,7 +881,7 @@ margin-bottom: 20px; "$ref" : "#/definitions/NFMModSettings" } }, - "description" : "Base channel settings" + "description" : "Base channel settings. The specific channel settings present depends on channelType." }; defs.DVSeralDevices = { "required" : [ "nbDevices" ], @@ -1000,7 +1021,7 @@ margin-bottom: 20px; "$ref" : "#/definitions/RtlSdrSettings" } }, - "description" : "Base device settings" + "description" : "Base device settings. The specific device settings present depends on deviceHwType." }; defs.DeviceState = { "required" : [ "state" ], @@ -1325,6 +1346,25 @@ margin-bottom: 20px; } }, "description" : "Logging parameters setting" +}; + defs.NFMDemodReport = { + "properties" : { + "channelPowerDB" : { + "type" : "number", + "format" : "float", + "description" : "power received in channel (dB)" + }, + "ctcssTone" : { + "type" : "number", + "format" : "float", + "description" : "CTCSS tone frequency if detected else 0" + }, + "squelch" : { + "type" : "integer", + "description" : "squelch status (1 if open else 0)" + } + }, + "description" : "NFMDemod" }; defs.NFMDemodSettings = { "properties" : { @@ -1389,6 +1429,16 @@ margin-bottom: 20px; } }, "description" : "NFMDemod" +}; + defs.NFMModReport = { + "properties" : { + "channelPowerDB" : { + "type" : "number", + "format" : "float", + "description" : "power transmitted in channel (dB)" + } + }, + "description" : "NFMMod" }; defs.NFMModSettings = { "properties" : { @@ -1694,6 +1744,9 @@ margin-bottom: 20px;
  • devicesetChannelPost
  • +
  • + devicesetChannelReportGet +
  • devicesetChannelSettingsGet
  • @@ -2838,6 +2891,500 @@ $(document).ready(function() {
    +
    +
    +
    +

    devicesetChannelReportGet

    +

    +
    +
    +
    +

    +

    get a channel report

    +

    +
    +
    /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report"
    +
    +
    +
    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
    +        Integer channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +        try {
    +            ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetChannelReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    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
    +        Integer channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +        try {
    +            ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetChannelReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    Integer *deviceSetIndex = 56; // Index of device set in the device set list
    +Integer *channelIndex = 56; // Index of the channel in the channels list for this device set
    +
    +DeviceSetApi *apiInstance = [[DeviceSetApi alloc] init];
    +
    +[apiInstance devicesetChannelReportGetWith:deviceSetIndex
    +    channelIndex:channelIndex
    +              completionHandler: ^(ChannelReport output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.DeviceSetApi()
    +
    +var deviceSetIndex = 56; // {Integer} Index of device set in the device set list
    +
    +var channelIndex = 56; // {Integer} Index of the channel in the channels list for this device set
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.devicesetChannelReportGet(deviceSetIndex, channelIndex, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class devicesetChannelReportGetExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new DeviceSetApi();
    +            var deviceSetIndex = 56;  // Integer | Index of device set in the device set list
    +            var channelIndex = 56;  // Integer | Index of the channel in the channels list for this device set
    +
    +            try
    +            {
    +                ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling DeviceSetApi.devicesetChannelReportGet: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?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
    +$channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +
    +try {
    +    $result = $api_instance->devicesetChannelReportGet($deviceSetIndex, $channelIndex);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling DeviceSetApi->devicesetChannelReportGet: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    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
    +my $channelIndex = 56; # Integer | Index of the channel in the channels list for this device set
    +
    +eval { 
    +    my $result = $api_instance->devicesetChannelReportGet(deviceSetIndex => $deviceSetIndex, channelIndex => $channelIndex);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling DeviceSetApi->devicesetChannelReportGet: $@\n";
    +}
    +
    + +
    +
    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
    +channelIndex = 56 # Integer | Index of the channel in the channels list for this device set
    +
    +try: 
    +    api_response = api_instance.deviceset_channel_report_get(deviceSetIndex, channelIndex)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling DeviceSetApi->devicesetChannelReportGet: %s\n" % e)
    +
    +
    + +

    Parameters

    + +
    Path parameters
    + + + + + + + + + + + + + +
    NameDescription
    deviceSetIndex* + + +
    +
    +
    + + Integer + + +
    + Index of device set in the device set list +
    +
    +
    + Required +
    +
    +
    +
    channelIndex* + + +
    +
    +
    + + Integer + + +
    + Index of the channel in the channels list for this device set +
    +
    +
    + Required +
    +
    +
    +
    + + + + + +

    Responses

    +

    Status: 200 - On success return channel report

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 400 - Invalid device set or channel index

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 404 - Device or channel not found

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -16925,7 +17472,7 @@ except ApiException as e:
    - Generated 2018-03-03T23:35:13.013+01:00 + Generated 2018-03-18T11:03:22.829+01:00
    diff --git a/sdrbase/resources/webapi/doc/swagger/include/NFMDemod.yaml b/sdrbase/resources/webapi/doc/swagger/include/NFMDemod.yaml index c83d72e4e..5a66f9127 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/NFMDemod.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/NFMDemod.yaml @@ -42,4 +42,18 @@ NFMDemodSettings: type: integer title: type: string - \ No newline at end of file + +NFMDemodReport: + description: NFMDemod + properties: + channelPowerDB: + description: power received in channel (dB) + type: number + format: float + ctcssTone: + description: CTCSS tone frequency if detected else 0 + type: number + format: float + squelch: + description: squelch status (1 if open else 0) + type: integer diff --git a/sdrbase/resources/webapi/doc/swagger/include/NFMMod.yaml b/sdrbase/resources/webapi/doc/swagger/include/NFMMod.yaml index e41bb718f..3148c36dc 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/NFMMod.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/NFMMod.yaml @@ -37,4 +37,12 @@ NFMModSettings: type: integer cwKeyer: $ref: "/doc/swagger/include/CWKeyer.yaml#/CWKeyerSettings" + +NFMModReport: + description: NFMMod + properties: + channelPowerDB: + description: power transmitted in channel (dB) + type: number + format: float \ No newline at end of file diff --git a/sdrbase/resources/webapi/doc/swagger/swagger.yaml b/sdrbase/resources/webapi/doc/swagger/swagger.yaml index adba3902f..64af08125 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -997,6 +997,43 @@ paths: "501": $ref: "#/responses/Response_501" + /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report: + x-swagger-router-controller: deviceset + get: + description: get a channel report + operationId: devicesetChannelReportGet + tags: + - DeviceSet + parameters: + - in: path + name: deviceSetIndex + type: integer + required: true + description: Index of device set in the device set list + - in: path + name: channelIndex + type: integer + required: true + description: Index of the channel in the channels list for this device set + responses: + "200": + description: On success return channel report + schema: + $ref: "#/definitions/ChannelReport" + "400": + description: Invalid device set or channel index + schema: + $ref: "#/definitions/ErrorResponse" + "404": + description: Device or channel not found + schema: + $ref: "#/definitions/ErrorResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + + /swagger: x-swagger-pipe: swagger_raw @@ -1470,7 +1507,7 @@ definitions: $ref: "#/definitions/PresetIdentifier" DeviceSettings: - description: Base device settings + description: Base device settings. The specific device settings present depends on deviceHwType. discriminator: deviceHwType required: - deviceHwType @@ -1496,7 +1533,7 @@ definitions: $ref: "/doc/swagger/include/RtlSdr.yaml#/RtlSdrSettings" ChannelSettings: - description: Base channel settings + description: Base channel settings. The specific channel settings present depends on channelType. discriminator: channelType required: - channelType @@ -1513,6 +1550,24 @@ definitions: NFMModSettings: $ref: "/doc/swagger/include/NFMMod.yaml#/NFMModSettings" + ChannelReport: + description: Base channel report. The specific channel report present depends on channelType. + discriminator: channelType + required: + - channelType + - tx + properties: + channelType: + description: Channel type code + type: string + tx: + description: Not zero if it is a tx channel else it is a rx channel + type: integer + NFMDemodReport: + $ref: "/doc/swagger/include/NFMDemod.yaml#/NFMDemodReport" + NFMModReport: + $ref: "/doc/swagger/include/NFMMod.yaml#/NFMModReport" + responses: Response_500: diff --git a/sdrbase/webapi/webapiadapterinterface.cpp b/sdrbase/webapi/webapiadapterinterface.cpp index d8a1935b8..9e2b2af3c 100644 --- a/sdrbase/webapi/webapiadapterinterface.cpp +++ b/sdrbase/webapi/webapiadapterinterface.cpp @@ -39,3 +39,4 @@ std::regex WebAPIAdapterInterface::devicesetDeviceRunURLRe("^/sdrangel/deviceset 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})$"); std::regex WebAPIAdapterInterface::devicesetChannelSettingsURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/settings$"); +std::regex WebAPIAdapterInterface::devicesetChannelReportURLRe("^/sdrangel/deviceset/([0-9]{1,2})/channel/([0-9]{1,2})/report"); diff --git a/sdrbase/webapi/webapiadapterinterface.h b/sdrbase/webapi/webapiadapterinterface.h index ac8f559c3..ca16f738e 100644 --- a/sdrbase/webapi/webapiadapterinterface.h +++ b/sdrbase/webapi/webapiadapterinterface.h @@ -47,6 +47,7 @@ namespace SWGSDRangel class SWGDeviceSettings; class SWGDeviceState; class SWGChannelSettings; + class SWGChannelReport; class SWGSuccessResponse; } @@ -515,6 +516,22 @@ public: return 501; } + + /** + * Handler of /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/settings (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels + * returns the Http status code (default 501: not implemented) + */ + virtual int devicesetChannelReportGet( + int deviceSetIndex __attribute__((unused)), + int channelIndex __attribute__((unused)), + SWGSDRangel::SWGChannelReport& response __attribute__((unused)), + SWGSDRangel::SWGErrorResponse& error) + { + error.init(); + *error.getMessage() = QString("Function not implemented"); + return 501; + } + static QString instanceSummaryURL; static QString instanceDevicesURL; static QString instanceChannelsURL; @@ -535,6 +552,7 @@ public: static std::regex devicesetChannelURLRe; static std::regex devicesetChannelIndexURLRe; static std::regex devicesetChannelSettingsURLRe; + static std::regex devicesetChannelReportURLRe; }; diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 5e4399da2..ad43613b8 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -39,6 +39,7 @@ #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" #include "SWGChannelSettings.h" +#include "SWGChannelReport.h" #include "SWGSuccessResponse.h" #include "SWGErrorResponse.h" @@ -118,6 +119,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http devicesetChannelIndexService(std::string(desc_match[1]), std::string(desc_match[2]), request, response); } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelSettingsURLRe)) { devicesetChannelSettingsService(std::string(desc_match[1]), std::string(desc_match[2]), request, response); + } else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetChannelReportURLRe)) { + devicesetChannelReportService(std::string(desc_match[1]), std::string(desc_match[2]), request, response); } else // serve static documentation pages { @@ -1270,6 +1273,43 @@ void WebAPIRequestMapper::devicesetChannelSettingsService( } } +void WebAPIRequestMapper::devicesetChannelReportService( + const std::string& deviceSetIndexStr, + const std::string& channelIndexStr, + qtwebapp::HttpRequest& request, + qtwebapp::HttpResponse& response) +{ + SWGSDRangel::SWGErrorResponse errorResponse; + response.setHeader("Content-Type", "application/json"); + + try + { + int deviceSetIndex = boost::lexical_cast(deviceSetIndexStr); + int channelIndex = boost::lexical_cast(channelIndexStr); + + if (request.getMethod() == "GET") + { + SWGSDRangel::SWGChannelReport normalResponse; + resetChannelReport(normalResponse); + int status = m_adapter->devicesetChannelReportGet(deviceSetIndex, channelIndex, 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 index"; + response.setStatus(400,"Invalid data"); + response.write(errorResponse.asJson().toUtf8()); + } +} + bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, QJsonObject& jsonObject, qtwebapp::HttpResponse& response) { SWGSDRangel::SWGErrorResponse errorResponse; @@ -1569,6 +1609,59 @@ bool WebAPIRequestMapper::validateChannelSettings( } } +bool WebAPIRequestMapper::validateChannelReport( + SWGSDRangel::SWGChannelReport& channelReport, + QJsonObject& jsonObject, + QStringList& channelReportKeys) +{ + if (jsonObject.contains("tx")) { + channelReport.setTx(jsonObject["tx"].toInt()); + } else { + channelReport.setTx(0); // assume Rx + } + + if (jsonObject.contains("channelType") && jsonObject["channelType"].isString()) { + channelReport.setChannelType(new QString(jsonObject["channelType"].toString())); + } else { + return false; + } + + QString *channelType = channelReport.getChannelType(); + + if (*channelType == "NFMDemod") + { + if (channelReport.getTx() == 0) + { + QJsonObject nfmDemodReportJsonObject = jsonObject["NFMDemodReport"].toObject(); + channelReportKeys = nfmDemodReportJsonObject.keys(); + channelReport.setNfmDemodReport(new SWGSDRangel::SWGNFMDemodReport()); + channelReport.getNfmDemodReport()->fromJsonObject(nfmDemodReportJsonObject); + return true; + } + else { + return false; + } + } + else if (*channelType == "NFMMod") + { + if (channelReport.getTx() != 0) + { + QJsonObject nfmModReportJsonObject = jsonObject["NFMModReport"].toObject(); + channelReportKeys = nfmModReportJsonObject.keys(); + channelReport.setNfmModReport(new SWGSDRangel::SWGNFMModReport()); + channelReport.getNfmModReport()->fromJsonObject(nfmModReportJsonObject); + return true; + } + else { + return false; + } + } + else + { + return false; + } +} + void WebAPIRequestMapper::appendSettingsSubKeys( const QJsonObject& parentSettingsJsonObject, QJsonObject& childSettingsJsonObject, @@ -1603,3 +1696,10 @@ void WebAPIRequestMapper::resetChannelSettings(SWGSDRangel::SWGChannelSettings& channelSettings.setNfmModSettings(0); } +void WebAPIRequestMapper::resetChannelReport(SWGSDRangel::SWGChannelReport& channelReport) +{ + channelReport.cleanup(); + channelReport.setChannelType(0); + channelReport.setNfmDemodReport(0); + channelReport.setNfmModReport(0); +} diff --git a/sdrbase/webapi/webapirequestmapper.h b/sdrbase/webapi/webapirequestmapper.h index bb95aa1fc..3c5aa8d07 100644 --- a/sdrbase/webapi/webapirequestmapper.h +++ b/sdrbase/webapi/webapirequestmapper.h @@ -68,6 +68,7 @@ private: 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); void devicesetChannelSettingsService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); + void devicesetChannelReportService(const std::string& deviceSetIndexStr, const std::string& channelIndexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response); bool validatePresetTransfer(SWGSDRangel::SWGPresetTransfer& presetTransfer); bool validatePresetIdentifer(SWGSDRangel::SWGPresetIdentifier& presetIdentifier); @@ -75,6 +76,7 @@ private: bool validateDeviceListItem(SWGSDRangel::SWGDeviceListItem& deviceListItem, QJsonObject& jsonObject); bool validateDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings, QJsonObject& jsonObject, QStringList& deviceSettingsKeys); bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys); + bool validateChannelReport(SWGSDRangel::SWGChannelReport& deviceReport, QJsonObject& jsonObject, QStringList& channelReportKeys); void appendSettingsSubKeys( const QJsonObject& parentSettingsJsonObject, @@ -86,6 +88,7 @@ private: void resetDeviceSettings(SWGSDRangel::SWGDeviceSettings& deviceSettings); void resetChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings); + void resetChannelReport(SWGSDRangel::SWGChannelReport& deviceSettings); }; #endif /* SDRBASE_WEBAPI_WEBAPIREQUESTMAPPER_H_ */ diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index 0869cb82c..fa9144c95 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -54,6 +54,7 @@ #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" #include "SWGChannelSettings.h" +#include "SWGChannelReport.h" #include "SWGSuccessResponse.h" #include "SWGErrorResponse.h" #include "SWGDeviceState.h" @@ -1199,6 +1200,66 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet( } } + +int WebAPIAdapterGUI::devicesetChannelReportGet( + int deviceSetIndex, + int channelIndex, + SWGSDRangel::SWGChannelReport& response, + SWGSDRangel::SWGErrorResponse& error) +{ + error.init(); + + if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size())) + { + DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex]; + + if (deviceSet->m_deviceSourceEngine) // Rx + { + ChannelSinkAPI *channelAPI = deviceSet->m_deviceSourceAPI->getChanelAPIAt(channelIndex); + + if (channelAPI == 0) + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + else + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + response.setTx(0); + return channelAPI->webapiReportGet(response, *error.getMessage()); + } + } + else if (deviceSet->m_deviceSinkEngine) // Tx + { + ChannelSourceAPI *channelAPI = deviceSet->m_deviceSinkAPI->getChanelAPIAt(channelIndex); + + if (channelAPI == 0) + { + *error.getMessage() = QString("There is no channel with index %1").arg(channelIndex); + return 404; + } + else + { + response.setChannelType(new QString()); + channelAPI->getIdentifier(*response.getChannelType()); + response.setTx(1); + return channelAPI->webapiReportGet(response, *error.getMessage()); + } + } + else + { + *error.getMessage() = QString("DeviceSet error"); + return 500; + } + } + else + { + *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex); + return 404; + } +} + int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch( int deviceSetIndex, int channelIndex, diff --git a/sdrgui/webapi/webapiadaptergui.h b/sdrgui/webapi/webapiadaptergui.h index b82124fff..37be03994 100644 --- a/sdrgui/webapi/webapiadaptergui.h +++ b/sdrgui/webapi/webapiadaptergui.h @@ -185,6 +185,12 @@ public: SWGSDRangel::SWGChannelSettings& response, SWGSDRangel::SWGErrorResponse& error); + virtual int devicesetChannelReportGet( + int deviceSetIndex, + int channelIndex, + SWGSDRangel::SWGChannelReport& response, + SWGSDRangel::SWGErrorResponse& error); + private: MainWindow& m_mainWindow; diff --git a/swagger/sdrangel/api/swagger/include/NFMDemod.yaml b/swagger/sdrangel/api/swagger/include/NFMDemod.yaml index c83d72e4e..5a66f9127 100644 --- a/swagger/sdrangel/api/swagger/include/NFMDemod.yaml +++ b/swagger/sdrangel/api/swagger/include/NFMDemod.yaml @@ -42,4 +42,18 @@ NFMDemodSettings: type: integer title: type: string - \ No newline at end of file + +NFMDemodReport: + description: NFMDemod + properties: + channelPowerDB: + description: power received in channel (dB) + type: number + format: float + ctcssTone: + description: CTCSS tone frequency if detected else 0 + type: number + format: float + squelch: + description: squelch status (1 if open else 0) + type: integer diff --git a/swagger/sdrangel/api/swagger/include/NFMMod.yaml b/swagger/sdrangel/api/swagger/include/NFMMod.yaml index 0ce05274b..e121798f8 100644 --- a/swagger/sdrangel/api/swagger/include/NFMMod.yaml +++ b/swagger/sdrangel/api/swagger/include/NFMMod.yaml @@ -37,4 +37,12 @@ NFMModSettings: type: integer cwKeyer: $ref: "http://localhost:8081/api/swagger/include/CWKeyer.yaml#/CWKeyerSettings" + +NFMModReport: + description: NFMMod + properties: + channelPowerDB: + description: power transmitted in channel (dB) + type: number + format: float \ No newline at end of file diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index 3a0cc6387..e1ae42dc5 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -997,6 +997,43 @@ paths: "501": $ref: "#/responses/Response_501" + /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report: + x-swagger-router-controller: deviceset + get: + description: get a channel report + operationId: devicesetChannelReportGet + tags: + - DeviceSet + parameters: + - in: path + name: deviceSetIndex + type: integer + required: true + description: Index of device set in the device set list + - in: path + name: channelIndex + type: integer + required: true + description: Index of the channel in the channels list for this device set + responses: + "200": + description: On success return channel report + schema: + $ref: "#/definitions/ChannelReport" + "400": + description: Invalid device set or channel index + schema: + $ref: "#/definitions/ErrorResponse" + "404": + description: Device or channel not found + schema: + $ref: "#/definitions/ErrorResponse" + "500": + $ref: "#/responses/Response_500" + "501": + $ref: "#/responses/Response_501" + + /swagger: x-swagger-pipe: swagger_raw @@ -1470,7 +1507,7 @@ definitions: $ref: "#/definitions/PresetIdentifier" DeviceSettings: - description: Base device settings + description: Base device settings. The specific device settings present depends on deviceHwType. discriminator: deviceHwType required: - deviceHwType @@ -1496,7 +1533,7 @@ definitions: $ref: "http://localhost:8081/api/swagger/include/RtlSdr.yaml#/RtlSdrSettings" ChannelSettings: - description: Base channel settings + description: Base channel settings. The specific channel settings present depends on channelType. discriminator: channelType required: - channelType @@ -1513,6 +1550,24 @@ definitions: NFMModSettings: $ref: "http://localhost:8081/api/swagger/include/NFMMod.yaml#/NFMModSettings" + ChannelReport: + description: Base channel report. The specific channel report present depends on channelType. + discriminator: channelType + required: + - channelType + - tx + properties: + channelType: + description: Channel type code + type: string + tx: + description: Not zero if it is a tx channel else it is a rx channel + type: integer + NFMDemodReport: + $ref: "http://localhost:8081/api/swagger/include/NFMDemod.yaml#/NFMDemodReport" + NFMModReport: + $ref: "http://localhost:8081/api/swagger/include/NFMMod.yaml#/NFMModReport" + responses: Response_500: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index faedb146f..8f924b78d 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -840,6 +840,27 @@ margin-bottom: 20px; } }, "description" : "Summarized information about channel plugin" +}; + defs.ChannelReport = { + "required" : [ "channelType", "tx" ], + "discriminator" : "channelType", + "properties" : { + "channelType" : { + "type" : "string", + "description" : "Channel type code" + }, + "tx" : { + "type" : "integer", + "description" : "Not zero if it is a tx channel else it is a rx channel" + }, + "NFMDemodReport" : { + "$ref" : "#/definitions/NFMDemodReport" + }, + "NFMModReport" : { + "$ref" : "#/definitions/NFMModReport" + } + }, + "description" : "Base channel report. The specific channel report present depends on channelType." }; defs.ChannelSettings = { "required" : [ "channelType", "tx" ], @@ -860,7 +881,7 @@ margin-bottom: 20px; "$ref" : "#/definitions/NFMModSettings" } }, - "description" : "Base channel settings" + "description" : "Base channel settings. The specific channel settings present depends on channelType." }; defs.DVSeralDevices = { "required" : [ "nbDevices" ], @@ -1000,7 +1021,7 @@ margin-bottom: 20px; "$ref" : "#/definitions/RtlSdrSettings" } }, - "description" : "Base device settings" + "description" : "Base device settings. The specific device settings present depends on deviceHwType." }; defs.DeviceState = { "required" : [ "state" ], @@ -1325,6 +1346,25 @@ margin-bottom: 20px; } }, "description" : "Logging parameters setting" +}; + defs.NFMDemodReport = { + "properties" : { + "channelPowerDB" : { + "type" : "number", + "format" : "float", + "description" : "power received in channel (dB)" + }, + "ctcssTone" : { + "type" : "number", + "format" : "float", + "description" : "CTCSS tone frequency if detected else 0" + }, + "squelch" : { + "type" : "integer", + "description" : "squelch status (1 if open else 0)" + } + }, + "description" : "NFMDemod" }; defs.NFMDemodSettings = { "properties" : { @@ -1389,6 +1429,16 @@ margin-bottom: 20px; } }, "description" : "NFMDemod" +}; + defs.NFMModReport = { + "properties" : { + "channelPowerDB" : { + "type" : "number", + "format" : "float", + "description" : "power transmitted in channel (dB)" + } + }, + "description" : "NFMMod" }; defs.NFMModSettings = { "properties" : { @@ -1694,6 +1744,9 @@ margin-bottom: 20px;
  • devicesetChannelPost
  • +
  • + devicesetChannelReportGet +
  • devicesetChannelSettingsGet
  • @@ -2838,6 +2891,500 @@ $(document).ready(function() {
    +
    +
    +
    +

    devicesetChannelReportGet

    +

    +
    +
    +
    +

    +

    get a channel report

    +

    +
    +
    /sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report"
    +
    +
    +
    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
    +        Integer channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +        try {
    +            ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetChannelReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    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
    +        Integer channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +        try {
    +            ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetChannelReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    Integer *deviceSetIndex = 56; // Index of device set in the device set list
    +Integer *channelIndex = 56; // Index of the channel in the channels list for this device set
    +
    +DeviceSetApi *apiInstance = [[DeviceSetApi alloc] init];
    +
    +[apiInstance devicesetChannelReportGetWith:deviceSetIndex
    +    channelIndex:channelIndex
    +              completionHandler: ^(ChannelReport output, NSError* error) {
    +                            if (output) {
    +                                NSLog(@"%@", output);
    +                            }
    +                            if (error) {
    +                                NSLog(@"Error: %@", error);
    +                            }
    +                        }];
    +
    +
    + +
    +
    var SdRangel = require('sd_rangel');
    +
    +var api = new SdRangel.DeviceSetApi()
    +
    +var deviceSetIndex = 56; // {Integer} Index of device set in the device set list
    +
    +var channelIndex = 56; // {Integer} Index of the channel in the channels list for this device set
    +
    +
    +var callback = function(error, data, response) {
    +  if (error) {
    +    console.error(error);
    +  } else {
    +    console.log('API called successfully. Returned data: ' + data);
    +  }
    +};
    +api.devicesetChannelReportGet(deviceSetIndex, channelIndex, callback);
    +
    +
    + + +
    +
    using System;
    +using System.Diagnostics;
    +using SWGSDRangel.Api;
    +using SWGSDRangel.Client;
    +using SWGSDRangel.Model;
    +
    +namespace Example
    +{
    +    public class devicesetChannelReportGetExample
    +    {
    +        public void main()
    +        {
    +            
    +            var apiInstance = new DeviceSetApi();
    +            var deviceSetIndex = 56;  // Integer | Index of device set in the device set list
    +            var channelIndex = 56;  // Integer | Index of the channel in the channels list for this device set
    +
    +            try
    +            {
    +                ChannelReport result = apiInstance.devicesetChannelReportGet(deviceSetIndex, channelIndex);
    +                Debug.WriteLine(result);
    +            }
    +            catch (Exception e)
    +            {
    +                Debug.Print("Exception when calling DeviceSetApi.devicesetChannelReportGet: " + e.Message );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?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
    +$channelIndex = 56; // Integer | Index of the channel in the channels list for this device set
    +
    +try {
    +    $result = $api_instance->devicesetChannelReportGet($deviceSetIndex, $channelIndex);
    +    print_r($result);
    +} catch (Exception $e) {
    +    echo 'Exception when calling DeviceSetApi->devicesetChannelReportGet: ', $e->getMessage(), PHP_EOL;
    +}
    +?>
    +
    + +
    +
    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
    +my $channelIndex = 56; # Integer | Index of the channel in the channels list for this device set
    +
    +eval { 
    +    my $result = $api_instance->devicesetChannelReportGet(deviceSetIndex => $deviceSetIndex, channelIndex => $channelIndex);
    +    print Dumper($result);
    +};
    +if ($@) {
    +    warn "Exception when calling DeviceSetApi->devicesetChannelReportGet: $@\n";
    +}
    +
    + +
    +
    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
    +channelIndex = 56 # Integer | Index of the channel in the channels list for this device set
    +
    +try: 
    +    api_response = api_instance.deviceset_channel_report_get(deviceSetIndex, channelIndex)
    +    pprint(api_response)
    +except ApiException as e:
    +    print("Exception when calling DeviceSetApi->devicesetChannelReportGet: %s\n" % e)
    +
    +
    + +

    Parameters

    + +
    Path parameters
    + + + + + + + + + + + + + +
    NameDescription
    deviceSetIndex* + + +
    +
    +
    + + Integer + + +
    + Index of device set in the device set list +
    +
    +
    + Required +
    +
    +
    +
    channelIndex* + + +
    +
    +
    + + Integer + + +
    + Index of the channel in the channels list for this device set +
    +
    +
    + Required +
    +
    +
    +
    + + + + + +

    Responses

    +

    Status: 200 - On success return channel report

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 400 - Invalid device set or channel index

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 404 - Device or channel not found

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 500 - Error

    + + + +
    +
    +
    + +
    + +
    +
    + +

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -16925,7 +17472,7 @@ except ApiException as e:
    - Generated 2018-03-03T23:35:13.013+01:00 + Generated 2018-03-18T11:03:22.829+01:00
    diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp b/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp new file mode 100644 index 000000000..345541aec --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChannelReport.cpp @@ -0,0 +1,175 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGChannelReport.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGChannelReport::SWGChannelReport(QString* json) { + init(); + this->fromJson(*json); +} + +SWGChannelReport::SWGChannelReport() { + channel_type = nullptr; + m_channel_type_isSet = false; + tx = 0; + m_tx_isSet = false; + nfm_demod_report = nullptr; + m_nfm_demod_report_isSet = false; + nfm_mod_report = nullptr; + m_nfm_mod_report_isSet = false; +} + +SWGChannelReport::~SWGChannelReport() { + this->cleanup(); +} + +void +SWGChannelReport::init() { + channel_type = new QString(""); + m_channel_type_isSet = false; + tx = 0; + m_tx_isSet = false; + nfm_demod_report = new SWGNFMDemodReport(); + m_nfm_demod_report_isSet = false; + nfm_mod_report = new SWGNFMModReport(); + m_nfm_mod_report_isSet = false; +} + +void +SWGChannelReport::cleanup() { + if(channel_type != nullptr) { + delete channel_type; + } + + if(nfm_demod_report != nullptr) { + delete nfm_demod_report; + } + if(nfm_mod_report != nullptr) { + delete nfm_mod_report; + } +} + +SWGChannelReport* +SWGChannelReport::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGChannelReport::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&channel_type, pJson["channelType"], "QString", "QString"); + + ::SWGSDRangel::setValue(&tx, pJson["tx"], "qint32", ""); + + ::SWGSDRangel::setValue(&nfm_demod_report, pJson["NFMDemodReport"], "SWGNFMDemodReport", "SWGNFMDemodReport"); + + ::SWGSDRangel::setValue(&nfm_mod_report, pJson["NFMModReport"], "SWGNFMModReport", "SWGNFMModReport"); + +} + +QString +SWGChannelReport::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGChannelReport::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(channel_type != nullptr && *channel_type != QString("")){ + toJsonValue(QString("channelType"), channel_type, obj, QString("QString")); + } + if(m_tx_isSet){ + obj->insert("tx", QJsonValue(tx)); + } + if((nfm_demod_report != nullptr) && (nfm_demod_report->isSet())){ + toJsonValue(QString("NFMDemodReport"), nfm_demod_report, obj, QString("SWGNFMDemodReport")); + } + if((nfm_mod_report != nullptr) && (nfm_mod_report->isSet())){ + toJsonValue(QString("NFMModReport"), nfm_mod_report, obj, QString("SWGNFMModReport")); + } + + return obj; +} + +QString* +SWGChannelReport::getChannelType() { + return channel_type; +} +void +SWGChannelReport::setChannelType(QString* channel_type) { + this->channel_type = channel_type; + this->m_channel_type_isSet = true; +} + +qint32 +SWGChannelReport::getTx() { + return tx; +} +void +SWGChannelReport::setTx(qint32 tx) { + this->tx = tx; + this->m_tx_isSet = true; +} + +SWGNFMDemodReport* +SWGChannelReport::getNfmDemodReport() { + return nfm_demod_report; +} +void +SWGChannelReport::setNfmDemodReport(SWGNFMDemodReport* nfm_demod_report) { + this->nfm_demod_report = nfm_demod_report; + this->m_nfm_demod_report_isSet = true; +} + +SWGNFMModReport* +SWGChannelReport::getNfmModReport() { + return nfm_mod_report; +} +void +SWGChannelReport::setNfmModReport(SWGNFMModReport* nfm_mod_report) { + this->nfm_mod_report = nfm_mod_report; + this->m_nfm_mod_report_isSet = true; +} + + +bool +SWGChannelReport::isSet(){ + bool isObjectUpdated = false; + do{ + if(channel_type != nullptr && *channel_type != QString("")){ isObjectUpdated = true; break;} + if(m_tx_isSet){ isObjectUpdated = true; break;} + if(nfm_demod_report != nullptr && nfm_demod_report->isSet()){ isObjectUpdated = true; break;} + if(nfm_mod_report != nullptr && nfm_mod_report->isSet()){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelReport.h b/swagger/sdrangel/code/qt5/client/SWGChannelReport.h new file mode 100644 index 000000000..10ed20952 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGChannelReport.h @@ -0,0 +1,78 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGChannelReport.h + * + * Base channel report. The specific channel report present depends on channelType. + */ + +#ifndef SWGChannelReport_H_ +#define SWGChannelReport_H_ + +#include + + +#include "SWGNFMDemodReport.h" +#include "SWGNFMModReport.h" +#include + +#include "SWGObject.h" + +namespace SWGSDRangel { + +class SWGChannelReport: public SWGObject { +public: + SWGChannelReport(); + SWGChannelReport(QString* json); + virtual ~SWGChannelReport(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGChannelReport* fromJson(QString &jsonString) override; + + QString* getChannelType(); + void setChannelType(QString* channel_type); + + qint32 getTx(); + void setTx(qint32 tx); + + SWGNFMDemodReport* getNfmDemodReport(); + void setNfmDemodReport(SWGNFMDemodReport* nfm_demod_report); + + SWGNFMModReport* getNfmModReport(); + void setNfmModReport(SWGNFMModReport* nfm_mod_report); + + + virtual bool isSet() override; + +private: + QString* channel_type; + bool m_channel_type_isSet; + + qint32 tx; + bool m_tx_isSet; + + SWGNFMDemodReport* nfm_demod_report; + bool m_nfm_demod_report_isSet; + + SWGNFMModReport* nfm_mod_report; + bool m_nfm_mod_report_isSet; + +}; + +} + +#endif /* SWGChannelReport_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h index d1c9efec9..31d5b5c5e 100644 --- a/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGChannelSettings.h @@ -13,7 +13,7 @@ /* * SWGChannelSettings.h * - * Base channel settings + * Base channel settings. The specific channel settings present depends on channelType. */ #ifndef SWGChannelSettings_H_ diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp index 3767e05cf..99afc3eb0 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp @@ -141,6 +141,62 @@ SWGDeviceSetApi::devicesetChannelPostCallback(SWGHttpRequestWorker * worker) { } } +void +SWGDeviceSetApi::devicesetChannelReportGet(qint32 device_set_index, qint32 channel_index) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/channel/{channelIndex}/report"); + + QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}"); + fullPath.replace(device_set_indexPathParam, stringValue(device_set_index)); + QString channel_indexPathParam("{"); channel_indexPathParam.append("channelIndex").append("}"); + fullPath.replace(channel_indexPathParam, stringValue(channel_index)); + + + SWGHttpRequestWorker *worker = new SWGHttpRequestWorker(); + SWGHttpRequestInput input(fullPath, "GET"); + + + + + + foreach(QString key, this->defaultHeaders.keys()) { + input.headers.insert(key, this->defaultHeaders.value(key)); + } + + connect(worker, + &SWGHttpRequestWorker::on_execution_finished, + this, + &SWGDeviceSetApi::devicesetChannelReportGetCallback); + + worker->execute(&input); +} + +void +SWGDeviceSetApi::devicesetChannelReportGetCallback(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); + SWGChannelReport* output = static_cast(create(json, QString("SWGChannelReport"))); + worker->deleteLater(); + + if (worker->error_type == QNetworkReply::NoError) { + emit devicesetChannelReportGetSignal(output); + } else { + emit devicesetChannelReportGetSignalE(output, error_type, error_str); + emit devicesetChannelReportGetSignalEFull(worker, error_type, error_str); + } +} + void SWGDeviceSetApi::devicesetChannelSettingsGet(qint32 device_set_index, qint32 channel_index) { QString fullPath; diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h index c8fb702a3..9a552e786 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h @@ -15,6 +15,7 @@ #include "SWGHttpRequest.h" +#include "SWGChannelReport.h" #include "SWGChannelSettings.h" #include "SWGDeviceListItem.h" #include "SWGDeviceSet.h" @@ -41,6 +42,7 @@ public: void devicesetChannelDelete(qint32 device_set_index, qint32 channel_index); void devicesetChannelPost(qint32 device_set_index, SWGChannelSettings& body); + void devicesetChannelReportGet(qint32 device_set_index, qint32 channel_index); void devicesetChannelSettingsGet(qint32 device_set_index, qint32 channel_index); void devicesetChannelSettingsPatch(qint32 device_set_index, qint32 channel_index, SWGChannelSettings& body); void devicesetChannelSettingsPut(qint32 device_set_index, qint32 channel_index, SWGChannelSettings& body); @@ -59,6 +61,7 @@ public: private: void devicesetChannelDeleteCallback (SWGHttpRequestWorker * worker); void devicesetChannelPostCallback (SWGHttpRequestWorker * worker); + void devicesetChannelReportGetCallback (SWGHttpRequestWorker * worker); void devicesetChannelSettingsGetCallback (SWGHttpRequestWorker * worker); void devicesetChannelSettingsPatchCallback (SWGHttpRequestWorker * worker); void devicesetChannelSettingsPutCallback (SWGHttpRequestWorker * worker); @@ -77,6 +80,7 @@ private: signals: void devicesetChannelDeleteSignal(SWGChannelSettings* summary); void devicesetChannelPostSignal(SWGSuccessResponse* summary); + void devicesetChannelReportGetSignal(SWGChannelReport* summary); void devicesetChannelSettingsGetSignal(SWGChannelSettings* summary); void devicesetChannelSettingsPatchSignal(SWGChannelSettings* summary); void devicesetChannelSettingsPutSignal(SWGChannelSettings* summary); @@ -94,6 +98,7 @@ signals: void devicesetChannelDeleteSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelPostSignalE(SWGSuccessResponse* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void devicesetChannelReportGetSignalE(SWGChannelReport* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsGetSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsPatchSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsPutSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); @@ -111,6 +116,7 @@ signals: void devicesetChannelDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void devicesetChannelReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsPatchSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelSettingsPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h index 1f926232b..460062ac6 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSettings.h @@ -13,7 +13,7 @@ /* * SWGDeviceSettings.h * - * Base device settings + * Base device settings. The specific device settings present depends on deviceHwType. */ #ifndef SWGDeviceSettings_H_ diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index e8cc0a960..4e59ed8b6 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -20,6 +20,7 @@ #include "SWGCWKeyerSettings.h" #include "SWGChannel.h" #include "SWGChannelListItem.h" +#include "SWGChannelReport.h" #include "SWGChannelSettings.h" #include "SWGDVSeralDevices.h" #include "SWGDVSerialDevice.h" @@ -39,7 +40,9 @@ #include "SWGLimeSdrOutputSettings.h" #include "SWGLocationInformation.h" #include "SWGLoggingInfo.h" +#include "SWGNFMDemodReport.h" #include "SWGNFMDemodSettings.h" +#include "SWGNFMModReport.h" #include "SWGNFMModSettings.h" #include "SWGPresetExport.h" #include "SWGPresetGroup.h" @@ -73,6 +76,9 @@ namespace SWGSDRangel { if(QString("SWGChannelListItem").compare(type) == 0) { return new SWGChannelListItem(); } + if(QString("SWGChannelReport").compare(type) == 0) { + return new SWGChannelReport(); + } if(QString("SWGChannelSettings").compare(type) == 0) { return new SWGChannelSettings(); } @@ -130,9 +136,15 @@ namespace SWGSDRangel { if(QString("SWGLoggingInfo").compare(type) == 0) { return new SWGLoggingInfo(); } + if(QString("SWGNFMDemodReport").compare(type) == 0) { + return new SWGNFMDemodReport(); + } if(QString("SWGNFMDemodSettings").compare(type) == 0) { return new SWGNFMDemodSettings(); } + if(QString("SWGNFMModReport").compare(type) == 0) { + return new SWGNFMModReport(); + } if(QString("SWGNFMModSettings").compare(type) == 0) { return new SWGNFMModSettings(); } diff --git a/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.cpp b/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.cpp new file mode 100644 index 000000000..0e252580e --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.cpp @@ -0,0 +1,148 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGNFMDemodReport.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGNFMDemodReport::SWGNFMDemodReport(QString* json) { + init(); + this->fromJson(*json); +} + +SWGNFMDemodReport::SWGNFMDemodReport() { + channel_power_db = 0.0f; + m_channel_power_db_isSet = false; + ctcss_tone = 0.0f; + m_ctcss_tone_isSet = false; + squelch = 0; + m_squelch_isSet = false; +} + +SWGNFMDemodReport::~SWGNFMDemodReport() { + this->cleanup(); +} + +void +SWGNFMDemodReport::init() { + channel_power_db = 0.0f; + m_channel_power_db_isSet = false; + ctcss_tone = 0.0f; + m_ctcss_tone_isSet = false; + squelch = 0; + m_squelch_isSet = false; +} + +void +SWGNFMDemodReport::cleanup() { + + + +} + +SWGNFMDemodReport* +SWGNFMDemodReport::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGNFMDemodReport::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", ""); + + ::SWGSDRangel::setValue(&ctcss_tone, pJson["ctcssTone"], "float", ""); + + ::SWGSDRangel::setValue(&squelch, pJson["squelch"], "qint32", ""); + +} + +QString +SWGNFMDemodReport::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGNFMDemodReport::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_channel_power_db_isSet){ + obj->insert("channelPowerDB", QJsonValue(channel_power_db)); + } + if(m_ctcss_tone_isSet){ + obj->insert("ctcssTone", QJsonValue(ctcss_tone)); + } + if(m_squelch_isSet){ + obj->insert("squelch", QJsonValue(squelch)); + } + + return obj; +} + +float +SWGNFMDemodReport::getChannelPowerDb() { + return channel_power_db; +} +void +SWGNFMDemodReport::setChannelPowerDb(float channel_power_db) { + this->channel_power_db = channel_power_db; + this->m_channel_power_db_isSet = true; +} + +float +SWGNFMDemodReport::getCtcssTone() { + return ctcss_tone; +} +void +SWGNFMDemodReport::setCtcssTone(float ctcss_tone) { + this->ctcss_tone = ctcss_tone; + this->m_ctcss_tone_isSet = true; +} + +qint32 +SWGNFMDemodReport::getSquelch() { + return squelch; +} +void +SWGNFMDemodReport::setSquelch(qint32 squelch) { + this->squelch = squelch; + this->m_squelch_isSet = true; +} + + +bool +SWGNFMDemodReport::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_channel_power_db_isSet){ isObjectUpdated = true; break;} + if(m_ctcss_tone_isSet){ isObjectUpdated = true; break;} + if(m_squelch_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.h b/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.h new file mode 100644 index 000000000..9b5fed600 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNFMDemodReport.h @@ -0,0 +1,69 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGNFMDemodReport.h + * + * NFMDemod + */ + +#ifndef SWGNFMDemodReport_H_ +#define SWGNFMDemodReport_H_ + +#include + + + +#include "SWGObject.h" + +namespace SWGSDRangel { + +class SWGNFMDemodReport: public SWGObject { +public: + SWGNFMDemodReport(); + SWGNFMDemodReport(QString* json); + virtual ~SWGNFMDemodReport(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGNFMDemodReport* fromJson(QString &jsonString) override; + + float getChannelPowerDb(); + void setChannelPowerDb(float channel_power_db); + + float getCtcssTone(); + void setCtcssTone(float ctcss_tone); + + qint32 getSquelch(); + void setSquelch(qint32 squelch); + + + virtual bool isSet() override; + +private: + float channel_power_db; + bool m_channel_power_db_isSet; + + float ctcss_tone; + bool m_ctcss_tone_isSet; + + qint32 squelch; + bool m_squelch_isSet; + +}; + +} + +#endif /* SWGNFMDemodReport_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGNFMModReport.cpp b/swagger/sdrangel/code/qt5/client/SWGNFMModReport.cpp new file mode 100644 index 000000000..c1a97558b --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNFMModReport.cpp @@ -0,0 +1,106 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGNFMModReport.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGNFMModReport::SWGNFMModReport(QString* json) { + init(); + this->fromJson(*json); +} + +SWGNFMModReport::SWGNFMModReport() { + channel_power_db = 0.0f; + m_channel_power_db_isSet = false; +} + +SWGNFMModReport::~SWGNFMModReport() { + this->cleanup(); +} + +void +SWGNFMModReport::init() { + channel_power_db = 0.0f; + m_channel_power_db_isSet = false; +} + +void +SWGNFMModReport::cleanup() { + +} + +SWGNFMModReport* +SWGNFMModReport::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGNFMModReport::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&channel_power_db, pJson["channelPowerDB"], "float", ""); + +} + +QString +SWGNFMModReport::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGNFMModReport::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_channel_power_db_isSet){ + obj->insert("channelPowerDB", QJsonValue(channel_power_db)); + } + + return obj; +} + +float +SWGNFMModReport::getChannelPowerDb() { + return channel_power_db; +} +void +SWGNFMModReport::setChannelPowerDb(float channel_power_db) { + this->channel_power_db = channel_power_db; + this->m_channel_power_db_isSet = true; +} + + +bool +SWGNFMModReport::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_channel_power_db_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGNFMModReport.h b/swagger/sdrangel/code/qt5/client/SWGNFMModReport.h new file mode 100644 index 000000000..fc68fcef3 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGNFMModReport.h @@ -0,0 +1,57 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGNFMModReport.h + * + * NFMMod + */ + +#ifndef SWGNFMModReport_H_ +#define SWGNFMModReport_H_ + +#include + + + +#include "SWGObject.h" + +namespace SWGSDRangel { + +class SWGNFMModReport: public SWGObject { +public: + SWGNFMModReport(); + SWGNFMModReport(QString* json); + virtual ~SWGNFMModReport(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGNFMModReport* fromJson(QString &jsonString) override; + + float getChannelPowerDb(); + void setChannelPowerDb(float channel_power_db); + + + virtual bool isSet() override; + +private: + float channel_power_db; + bool m_channel_power_db_isSet; + +}; + +} + +#endif /* SWGNFMModReport_H_ */