diff --git a/plugins/samplesource/airspy/airspyinput.cpp b/plugins/samplesource/airspy/airspyinput.cpp index b6ceca4b9..27f2875b7 100644 --- a/plugins/samplesource/airspy/airspyinput.cpp +++ b/plugins/samplesource/airspy/airspyinput.cpp @@ -17,9 +17,12 @@ #include #include #include +#include #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" +#include "SWGDeviceReport.h" +#include "SWGAirspyReport.h" #include "airspygui.h" #include "airspyinput.h" @@ -699,6 +702,17 @@ int AirspyInput::webapiSettingsPutPatch( return 200; } +int AirspyInput::webapiReportGet( + SWGSDRangel::SWGDeviceReport& response, + QString& errorMessage __attribute__((unused))) +{ + response.setAirspyReport(new SWGSDRangel::SWGAirspyReport()); + response.getAirspyReport()->init(); + webapiFormatDeviceReport(response); + return 200; +} + + void AirspyInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const AirspySettings& settings) { response.getAirspySettings()->setCenterFrequency(settings.m_centerFrequency); @@ -723,3 +737,15 @@ void AirspyInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& res response.getAirspySettings()->setFileRecordName(new QString(settings.m_fileRecordName)); } } + +void AirspyInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response) +{ + response.setAirspyReport(new SWGSDRangel::SWGAirspyReport()); + response.getAirspyReport()->setSampleRates(new QList); + + for (std::vector::const_iterator it = getSampleRates().begin(); it != getSampleRates().end(); ++it) + { + response.getAirspyReport()->getSampleRates()->append(new SWGSDRangel::SWGAirspyReport_sampleRates); + response.getAirspyReport()->getSampleRates()->back()->setSampleRate(*it); + } +} diff --git a/plugins/samplesource/airspy/airspyinput.h b/plugins/samplesource/airspy/airspyinput.h index 33bf6552e..f6d4788f2 100644 --- a/plugins/samplesource/airspy/airspyinput.h +++ b/plugins/samplesource/airspy/airspyinput.h @@ -130,6 +130,10 @@ public: SWGSDRangel::SWGDeviceState& response, QString& errorMessage); + virtual int webapiReportGet( + SWGSDRangel::SWGDeviceReport& response, + QString& errorMessage); + static const qint64 loLowLimitFreq; static const qint64 loHighLimitFreq; @@ -140,6 +144,7 @@ private: struct airspy_device *open_airspy_from_sequence(int sequence); void setDeviceCenterFrequency(quint64 freq); void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const AirspySettings& settings); + void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response); DeviceSourceAPI *m_deviceAPI; QMutex m_mutex; diff --git a/sdrbase/dsp/devicesamplesink.h b/sdrbase/dsp/devicesamplesink.h index 8ed05e8b2..5666f5e8c 100644 --- a/sdrbase/dsp/devicesamplesink.h +++ b/sdrbase/dsp/devicesamplesink.h @@ -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; } diff --git a/sdrbase/dsp/devicesamplesource.h b/sdrbase/dsp/devicesamplesource.h index 40d1ecd9f..60c541d8a 100644 --- a/sdrbase/dsp/devicesamplesource.h +++ b/sdrbase/dsp/devicesamplesource.h @@ -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; } diff --git a/sdrbase/resources/res.qrc b/sdrbase/resources/res.qrc index 4646fb380..7c837c5ce 100644 --- a/sdrbase/resources/res.qrc +++ b/sdrbase/resources/res.qrc @@ -3,6 +3,7 @@ webapi/doc/html2/index.html webapi/doc/swagger/swagger.yaml webapi/doc/swagger/include/CWKeyer.yaml + webapi/doc/swagger/include/Airspy.yaml webapi/doc/swagger/include/AirspyHF.yaml webapi/doc/swagger/include/BladeRF.yaml webapi/doc/swagger/include/FileSource.yaml @@ -17,6 +18,8 @@ webapi/doc/swagger/include/NFMMod.yaml webapi/doc/swagger/include/SSBMod.yaml webapi/doc/swagger/include/UDPSink.yaml + webapi/doc/swagger/include/UDPSrc.yaml + webapi/doc/swagger/include/WFMDemod.yaml webapi/doc/swagger/include/WFMMod.yaml webapi/doc/swagger/include/RtlSdr.yaml webapi/doc/swagger-ui/swagger-ui.js.map diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index 1a93cd249..78e660702 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -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;
  • devicesetDevicePut
  • +
  • + devicesetDeviceReportGet +
  • devicesetDeviceRunDelete
  • @@ -7189,6 +7229,467 @@ $(document).ready(function() {
    +
    +
    +
    +

    devicesetDeviceReportGet

    +

    +
    +
    +
    +

    +

    get the device report

    +

    +
    +
    /sdrangel/deviceset/{deviceSetIndex}/device/report
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/deviceset/{deviceSetIndex}/device/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
    +        try {
    +            DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
    +            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
    +        try {
    +            DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    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);
    +                            }
    +                        }];
    +
    +
    + +
    +
    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);
    +
    +
    + + +
    +
    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 );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?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;
    +}
    +?>
    +
    + +
    +
    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";
    +}
    +
    + +
    +
    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)
    +
    +
    + +

    Parameters

    + +
    Path parameters
    + + + + + + + + + +
    NameDescription
    deviceSetIndex* + + +
    +
    +
    + + Integer + + +
    + Index of device set in the device set list +
    +
    +
    + Required +
    +
    +
    +
    + + + + + +

    Responses

    +

    Status: 200 - On success return device report

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

    Status: 400 - Invalid device set

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

    Status: 404 - Device not found

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

    Status: 500 - Error

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

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -21180,7 +21681,7 @@ except ApiException as e:
    - Generated 2018-05-25T18:55:39.036+02:00 + Generated 2018-05-26T00:44:20.967+02:00
    diff --git a/sdrbase/resources/webapi/doc/swagger/include/Airspy.yaml b/sdrbase/resources/webapi/doc/swagger/include/Airspy.yaml index f3c28a03c..ebb14bd7d 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/Airspy.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/Airspy.yaml @@ -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 + \ 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 bb7a84212..746cffbe1 100644 --- a/sdrbase/resources/webapi/doc/swagger/swagger.yaml +++ b/sdrbase/resources/webapi/doc/swagger/swagger.yaml @@ -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 diff --git a/sdrbase/webapi/webapiadapterinterface.cpp b/sdrbase/webapi/webapiadapterinterface.cpp index 7fdf79c9a..4019e90f9 100644 --- a/sdrbase/webapi/webapiadapterinterface.cpp +++ b/sdrbase/webapi/webapiadapterinterface.cpp @@ -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})$"); diff --git a/sdrbase/webapi/webapiadapterinterface.h b/sdrbase/webapi/webapiadapterinterface.h index d76dd8492..b7a5ab8ea 100644 --- a/sdrbase/webapi/webapiadapterinterface.h +++ b/sdrbase/webapi/webapiadapterinterface.h @@ -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; diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp index 6a149d513..8fea23fbd 100644 --- a/sdrbase/webapi/webapirequestmapper.cpp +++ b/sdrbase/webapi/webapirequestmapper.cpp @@ -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(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; diff --git a/sdrbase/webapi/webapirequestmapper.h b/sdrbase/webapi/webapirequestmapper.h index 0abb90913..d56aaf451 100644 --- a/sdrbase/webapi/webapirequestmapper.h +++ b/sdrbase/webapi/webapirequestmapper.h @@ -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); diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp index 53246a3b8..c78e32d5e 100644 --- a/sdrgui/webapi/webapiadaptergui.cpp +++ b/sdrgui/webapi/webapiadaptergui.cpp @@ -53,6 +53,7 @@ #include "SWGPresetIdentifier.h" #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" +#include "SWGDeviceReport.h" #include "SWGChannelsDetail.h" #include "SWGChannelSettings.h" #include "SWGChannelReport.h" @@ -1169,6 +1170,45 @@ int WebAPIAdapterGUI::devicesetDeviceRunDelete( } } + +int WebAPIAdapterGUI::devicesetDeviceReportGet( + int deviceSetIndex, + SWGSDRangel::SWGDeviceReport& 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 + { + response.setDeviceHwType(new QString(deviceSet->m_deviceSourceAPI->getHardwareId())); + response.setTx(0); + DeviceSampleSource *source = deviceSet->m_deviceSourceAPI->getSampleSource(); + return source->webapiReportGet(response, *error.getMessage()); + } + else if (deviceSet->m_deviceSinkEngine) // Tx + { + response.setDeviceHwType(new QString(deviceSet->m_deviceSinkAPI->getHardwareId())); + response.setTx(1); + DeviceSampleSink *sink = deviceSet->m_deviceSinkAPI->getSampleSink(); + return sink->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::devicesetChannelsReportGet( int deviceSetIndex, SWGSDRangel::SWGChannelsDetail& response, diff --git a/sdrgui/webapi/webapiadaptergui.h b/sdrgui/webapi/webapiadaptergui.h index 0f8fde22e..82cff5749 100644 --- a/sdrgui/webapi/webapiadaptergui.h +++ b/sdrgui/webapi/webapiadaptergui.h @@ -181,6 +181,11 @@ public: SWGSDRangel::SWGDeviceState& response, SWGSDRangel::SWGErrorResponse& error); + virtual int devicesetDeviceReportGet( + int deviceSetIndex, + SWGSDRangel::SWGDeviceReport& response, + SWGSDRangel::SWGErrorResponse& error); + virtual int devicesetChannelsReportGet( int deviceSetIndex, SWGSDRangel::SWGChannelsDetail& response, diff --git a/swagger/sdrangel/api/swagger/include/Airspy.yaml b/swagger/sdrangel/api/swagger/include/Airspy.yaml index f3c28a03c..ebb14bd7d 100644 --- a/swagger/sdrangel/api/swagger/include/Airspy.yaml +++ b/swagger/sdrangel/api/swagger/include/Airspy.yaml @@ -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 + \ No newline at end of file diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml index e31ea9c19..9408a65c8 100644 --- a/swagger/sdrangel/api/swagger/swagger.yaml +++ b/swagger/sdrangel/api/swagger/swagger.yaml @@ -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: "http://localhost:8081/api/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: "http://localhost:8081/api/swagger/include/Airspy.yaml#/AirspyReport" + ChannelSettings: description: Base channel settings. The specific channel settings present depends on channelType. discriminator: channelType diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index 1a93cd249..78e660702 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -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;
  • devicesetDevicePut
  • +
  • + devicesetDeviceReportGet +
  • devicesetDeviceRunDelete
  • @@ -7189,6 +7229,467 @@ $(document).ready(function() {
    +
    +
    +
    +

    devicesetDeviceReportGet

    +

    +
    +
    +
    +

    +

    get the device report

    +

    +
    +
    /sdrangel/deviceset/{deviceSetIndex}/device/report
    +

    +

    Usage and SDK Samples

    +

    + + +
    +
    +
    curl -X GET "http://localhost/sdrangel/deviceset/{deviceSetIndex}/device/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
    +        try {
    +            DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
    +            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
    +        try {
    +            DeviceReport result = apiInstance.devicesetDeviceReportGet(deviceSetIndex);
    +            System.out.println(result);
    +        } catch (ApiException e) {
    +            System.err.println("Exception when calling DeviceSetApi#devicesetDeviceReportGet");
    +            e.printStackTrace();
    +        }
    +    }
    +}
    +
    + +
    +
    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);
    +                            }
    +                        }];
    +
    +
    + +
    +
    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);
    +
    +
    + + +
    +
    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 );
    +            }
    +        }
    +    }
    +}
    +
    +
    + +
    +
    <?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;
    +}
    +?>
    +
    + +
    +
    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";
    +}
    +
    + +
    +
    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)
    +
    +
    + +

    Parameters

    + +
    Path parameters
    + + + + + + + + + +
    NameDescription
    deviceSetIndex* + + +
    +
    +
    + + Integer + + +
    + Index of device set in the device set list +
    +
    +
    + Required +
    +
    +
    +
    + + + + + +

    Responses

    +

    Status: 200 - On success return device report

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

    Status: 400 - Invalid device set

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

    Status: 404 - Device not found

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

    Status: 500 - Error

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

    Status: 501 - Function not implemented

    + + + +
    +
    +
    + +
    + +
    +
    + +
    +
    +
    @@ -21180,7 +21681,7 @@ except ApiException as e:
    - Generated 2018-05-25T18:55:39.036+02:00 + Generated 2018-05-26T00:44:20.967+02:00
    diff --git a/swagger/sdrangel/code/qt5/client/SWGAirspyReport.cpp b/swagger/sdrangel/code/qt5/client/SWGAirspyReport.cpp new file mode 100644 index 000000000..21bd1abf5 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGAirspyReport.cpp @@ -0,0 +1,112 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +#include "SWGAirspyReport.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGAirspyReport::SWGAirspyReport(QString* json) { + init(); + this->fromJson(*json); +} + +SWGAirspyReport::SWGAirspyReport() { + sample_rates = nullptr; + m_sample_rates_isSet = false; +} + +SWGAirspyReport::~SWGAirspyReport() { + this->cleanup(); +} + +void +SWGAirspyReport::init() { + sample_rates = new QList(); + m_sample_rates_isSet = false; +} + +void +SWGAirspyReport::cleanup() { + if(sample_rates != nullptr) { + auto arr = sample_rates; + for(auto o: *arr) { + delete o; + } + delete sample_rates; + } +} + +SWGAirspyReport* +SWGAirspyReport::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGAirspyReport::fromJsonObject(QJsonObject &pJson) { + + ::SWGSDRangel::setValue(&sample_rates, pJson["sampleRates"], "QList", "SWGAirspyReport_sampleRates"); +} + +QString +SWGAirspyReport::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGAirspyReport::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(sample_rates->size() > 0){ + toJsonArray((QList*)sample_rates, obj, "sampleRates", "SWGAirspyReport_sampleRates"); + } + + return obj; +} + +QList* +SWGAirspyReport::getSampleRates() { + return sample_rates; +} +void +SWGAirspyReport::setSampleRates(QList* sample_rates) { + this->sample_rates = sample_rates; + this->m_sample_rates_isSet = true; +} + + +bool +SWGAirspyReport::isSet(){ + bool isObjectUpdated = false; + do{ + if(sample_rates->size() > 0){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGAirspyReport.h b/swagger/sdrangel/code/qt5/client/SWGAirspyReport.h new file mode 100644 index 000000000..290307372 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGAirspyReport.h @@ -0,0 +1,60 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGAirspyReport.h + * + * Airspy + */ + +#ifndef SWGAirspyReport_H_ +#define SWGAirspyReport_H_ + +#include + + +#include "SWGAirspyReport_sampleRates.h" +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGAirspyReport: public SWGObject { +public: + SWGAirspyReport(); + SWGAirspyReport(QString* json); + virtual ~SWGAirspyReport(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGAirspyReport* fromJson(QString &jsonString) override; + + QList* getSampleRates(); + void setSampleRates(QList* sample_rates); + + + virtual bool isSet() override; + +private: + QList* sample_rates; + bool m_sample_rates_isSet; + +}; + +} + +#endif /* SWGAirspyReport_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.cpp b/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.cpp new file mode 100644 index 000000000..66dcde762 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.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 "SWGAirspyReport_sampleRates.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGAirspyReport_sampleRates::SWGAirspyReport_sampleRates(QString* json) { + init(); + this->fromJson(*json); +} + +SWGAirspyReport_sampleRates::SWGAirspyReport_sampleRates() { + sample_rate = 0; + m_sample_rate_isSet = false; +} + +SWGAirspyReport_sampleRates::~SWGAirspyReport_sampleRates() { + this->cleanup(); +} + +void +SWGAirspyReport_sampleRates::init() { + sample_rate = 0; + m_sample_rate_isSet = false; +} + +void +SWGAirspyReport_sampleRates::cleanup() { + +} + +SWGAirspyReport_sampleRates* +SWGAirspyReport_sampleRates::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGAirspyReport_sampleRates::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&sample_rate, pJson["sampleRate"], "qint32", ""); + +} + +QString +SWGAirspyReport_sampleRates::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGAirspyReport_sampleRates::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(m_sample_rate_isSet){ + obj->insert("sampleRate", QJsonValue(sample_rate)); + } + + return obj; +} + +qint32 +SWGAirspyReport_sampleRates::getSampleRate() { + return sample_rate; +} +void +SWGAirspyReport_sampleRates::setSampleRate(qint32 sample_rate) { + this->sample_rate = sample_rate; + this->m_sample_rate_isSet = true; +} + + +bool +SWGAirspyReport_sampleRates::isSet(){ + bool isObjectUpdated = false; + do{ + if(m_sample_rate_isSet){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.h b/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.h new file mode 100644 index 000000000..47c080614 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGAirspyReport_sampleRates.h @@ -0,0 +1,58 @@ +/** + * SDRangel + * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Stopping instance i.e. /sdrangel with DELETE method is a server only feature. It allows stopping the instance nicely. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV demodulator, Channel Analyzer, Channel Analyzer NG, LoRa demodulator, TCP source * The content type returned is always application/json except in the following cases: * An incorrect URL was specified: this document is returned as text/html with a status 400 --- + * + * OpenAPI spec version: 4.0.0 + * Contact: f4exb06@gmail.com + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/* + * SWGAirspyReport_sampleRates.h + * + * + */ + +#ifndef SWGAirspyReport_sampleRates_H_ +#define SWGAirspyReport_sampleRates_H_ + +#include + + + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGAirspyReport_sampleRates: public SWGObject { +public: + SWGAirspyReport_sampleRates(); + SWGAirspyReport_sampleRates(QString* json); + virtual ~SWGAirspyReport_sampleRates(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGAirspyReport_sampleRates* fromJson(QString &jsonString) override; + + qint32 getSampleRate(); + void setSampleRate(qint32 sample_rate); + + + virtual bool isSet() override; + +private: + qint32 sample_rate; + bool m_sample_rate_isSet; + +}; + +} + +#endif /* SWGAirspyReport_sampleRates_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceReport.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceReport.cpp new file mode 100644 index 000000000..f1212ae30 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceReport.cpp @@ -0,0 +1,152 @@ +/** + * 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 "SWGDeviceReport.h" + +#include "SWGHelpers.h" + +#include +#include +#include +#include + +namespace SWGSDRangel { + +SWGDeviceReport::SWGDeviceReport(QString* json) { + init(); + this->fromJson(*json); +} + +SWGDeviceReport::SWGDeviceReport() { + device_hw_type = nullptr; + m_device_hw_type_isSet = false; + tx = 0; + m_tx_isSet = false; + airspy_report = nullptr; + m_airspy_report_isSet = false; +} + +SWGDeviceReport::~SWGDeviceReport() { + this->cleanup(); +} + +void +SWGDeviceReport::init() { + device_hw_type = new QString(""); + m_device_hw_type_isSet = false; + tx = 0; + m_tx_isSet = false; + airspy_report = new SWGAirspyReport(); + m_airspy_report_isSet = false; +} + +void +SWGDeviceReport::cleanup() { + if(device_hw_type != nullptr) { + delete device_hw_type; + } + + if(airspy_report != nullptr) { + delete airspy_report; + } +} + +SWGDeviceReport* +SWGDeviceReport::fromJson(QString &json) { + QByteArray array (json.toStdString().c_str()); + QJsonDocument doc = QJsonDocument::fromJson(array); + QJsonObject jsonObject = doc.object(); + this->fromJsonObject(jsonObject); + return this; +} + +void +SWGDeviceReport::fromJsonObject(QJsonObject &pJson) { + ::SWGSDRangel::setValue(&device_hw_type, pJson["deviceHwType"], "QString", "QString"); + + ::SWGSDRangel::setValue(&tx, pJson["tx"], "qint32", ""); + + ::SWGSDRangel::setValue(&airspy_report, pJson["airspyReport"], "SWGAirspyReport", "SWGAirspyReport"); + +} + +QString +SWGDeviceReport::asJson () +{ + QJsonObject* obj = this->asJsonObject(); + + QJsonDocument doc(*obj); + QByteArray bytes = doc.toJson(); + delete obj; + return QString(bytes); +} + +QJsonObject* +SWGDeviceReport::asJsonObject() { + QJsonObject* obj = new QJsonObject(); + if(device_hw_type != nullptr && *device_hw_type != QString("")){ + toJsonValue(QString("deviceHwType"), device_hw_type, obj, QString("QString")); + } + if(m_tx_isSet){ + obj->insert("tx", QJsonValue(tx)); + } + if((airspy_report != nullptr) && (airspy_report->isSet())){ + toJsonValue(QString("airspyReport"), airspy_report, obj, QString("SWGAirspyReport")); + } + + return obj; +} + +QString* +SWGDeviceReport::getDeviceHwType() { + return device_hw_type; +} +void +SWGDeviceReport::setDeviceHwType(QString* device_hw_type) { + this->device_hw_type = device_hw_type; + this->m_device_hw_type_isSet = true; +} + +qint32 +SWGDeviceReport::getTx() { + return tx; +} +void +SWGDeviceReport::setTx(qint32 tx) { + this->tx = tx; + this->m_tx_isSet = true; +} + +SWGAirspyReport* +SWGDeviceReport::getAirspyReport() { + return airspy_report; +} +void +SWGDeviceReport::setAirspyReport(SWGAirspyReport* airspy_report) { + this->airspy_report = airspy_report; + this->m_airspy_report_isSet = true; +} + + +bool +SWGDeviceReport::isSet(){ + bool isObjectUpdated = false; + do{ + if(device_hw_type != nullptr && *device_hw_type != QString("")){ isObjectUpdated = true; break;} + if(m_tx_isSet){ isObjectUpdated = true; break;} + if(airspy_report != nullptr && airspy_report->isSet()){ isObjectUpdated = true; break;} + }while(false); + return isObjectUpdated; +} +} + diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceReport.h b/swagger/sdrangel/code/qt5/client/SWGDeviceReport.h new file mode 100644 index 000000000..7f9bb02f0 --- /dev/null +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceReport.h @@ -0,0 +1,72 @@ +/** + * 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. + */ + +/* + * SWGDeviceReport.h + * + * Base device report. The specific device report present depeds on deviceHwType + */ + +#ifndef SWGDeviceReport_H_ +#define SWGDeviceReport_H_ + +#include + + +#include "SWGAirspyReport.h" +#include + +#include "SWGObject.h" +#include "export.h" + +namespace SWGSDRangel { + +class SWG_API SWGDeviceReport: public SWGObject { +public: + SWGDeviceReport(); + SWGDeviceReport(QString* json); + virtual ~SWGDeviceReport(); + void init(); + void cleanup(); + + virtual QString asJson () override; + virtual QJsonObject* asJsonObject() override; + virtual void fromJsonObject(QJsonObject &json) override; + virtual SWGDeviceReport* fromJson(QString &jsonString) override; + + QString* getDeviceHwType(); + void setDeviceHwType(QString* device_hw_type); + + qint32 getTx(); + void setTx(qint32 tx); + + SWGAirspyReport* getAirspyReport(); + void setAirspyReport(SWGAirspyReport* airspy_report); + + + virtual bool isSet() override; + +private: + QString* device_hw_type; + bool m_device_hw_type_isSet; + + qint32 tx; + bool m_tx_isSet; + + SWGAirspyReport* airspy_report; + bool m_airspy_report_isSet; + +}; + +} + +#endif /* SWGDeviceReport_H_ */ diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp index bb41cf948..44a4418b8 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.cpp @@ -482,6 +482,60 @@ SWGDeviceSetApi::devicesetDevicePutCallback(SWGHttpRequestWorker * worker) { } } +void +SWGDeviceSetApi::devicesetDeviceReportGet(qint32 device_set_index) { + QString fullPath; + fullPath.append(this->host).append(this->basePath).append("/sdrangel/deviceset/{deviceSetIndex}/device/report"); + + QString device_set_indexPathParam("{"); device_set_indexPathParam.append("deviceSetIndex").append("}"); + fullPath.replace(device_set_indexPathParam, stringValue(device_set_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::devicesetDeviceReportGetCallback); + + worker->execute(&input); +} + +void +SWGDeviceSetApi::devicesetDeviceReportGetCallback(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); + SWGDeviceReport* output = static_cast(create(json, QString("SWGDeviceReport"))); + worker->deleteLater(); + + if (worker->error_type == QNetworkReply::NoError) { + emit devicesetDeviceReportGetSignal(output); + } else { + emit devicesetDeviceReportGetSignalE(output, error_type, error_str); + emit devicesetDeviceReportGetSignalEFull(worker, error_type, error_str); + } +} + void SWGDeviceSetApi::devicesetDeviceRunDelete(qint32 device_set_index) { QString fullPath; diff --git a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h index 678114871..d42e88e5c 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h +++ b/swagger/sdrangel/code/qt5/client/SWGDeviceSetApi.h @@ -19,6 +19,7 @@ #include "SWGChannelSettings.h" #include "SWGChannelsDetail.h" #include "SWGDeviceListItem.h" +#include "SWGDeviceReport.h" #include "SWGDeviceSet.h" #include "SWGDeviceSettings.h" #include "SWGDeviceState.h" @@ -49,6 +50,7 @@ public: void devicesetChannelSettingsPut(qint32 device_set_index, qint32 channel_index, SWGChannelSettings& body); void devicesetChannelsReportGet(qint32 device_set_index); void devicesetDevicePut(qint32 device_set_index, SWGDeviceListItem& body); + void devicesetDeviceReportGet(qint32 device_set_index); void devicesetDeviceRunDelete(qint32 device_set_index); void devicesetDeviceRunGet(qint32 device_set_index); void devicesetDeviceRunPost(qint32 device_set_index); @@ -69,6 +71,7 @@ private: void devicesetChannelSettingsPutCallback (SWGHttpRequestWorker * worker); void devicesetChannelsReportGetCallback (SWGHttpRequestWorker * worker); void devicesetDevicePutCallback (SWGHttpRequestWorker * worker); + void devicesetDeviceReportGetCallback (SWGHttpRequestWorker * worker); void devicesetDeviceRunDeleteCallback (SWGHttpRequestWorker * worker); void devicesetDeviceRunGetCallback (SWGHttpRequestWorker * worker); void devicesetDeviceRunPostCallback (SWGHttpRequestWorker * worker); @@ -89,6 +92,7 @@ signals: void devicesetChannelSettingsPutSignal(SWGChannelSettings* summary); void devicesetChannelsReportGetSignal(SWGChannelsDetail* summary); void devicesetDevicePutSignal(SWGDeviceListItem* summary); + void devicesetDeviceReportGetSignal(SWGDeviceReport* summary); void devicesetDeviceRunDeleteSignal(SWGDeviceState* summary); void devicesetDeviceRunGetSignal(SWGDeviceState* summary); void devicesetDeviceRunPostSignal(SWGDeviceState* summary); @@ -108,6 +112,7 @@ signals: void devicesetChannelSettingsPutSignalE(SWGChannelSettings* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelsReportGetSignalE(SWGChannelsDetail* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDevicePutSignalE(SWGDeviceListItem* summary, QNetworkReply::NetworkError error_type, QString& error_str); + void devicesetDeviceReportGetSignalE(SWGDeviceReport* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunDeleteSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunGetSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunPostSignalE(SWGDeviceState* summary, QNetworkReply::NetworkError error_type, QString& error_str); @@ -127,6 +132,7 @@ signals: void devicesetChannelSettingsPutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetChannelsReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDevicePutSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); + void devicesetDeviceReportGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunDeleteSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunGetSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); void devicesetDeviceRunPostSignalEFull(SWGHttpRequestWorker* worker, QNetworkReply::NetworkError error_type, QString& error_str); diff --git a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h index c8f0a18b1..6aae27271 100644 --- a/swagger/sdrangel/code/qt5/client/SWGModelFactory.h +++ b/swagger/sdrangel/code/qt5/client/SWGModelFactory.h @@ -21,6 +21,8 @@ #include "SWGATVModReport.h" #include "SWGATVModSettings.h" #include "SWGAirspyHFSettings.h" +#include "SWGAirspyReport.h" +#include "SWGAirspyReport_sampleRates.h" #include "SWGAirspySettings.h" #include "SWGAudioDevices.h" #include "SWGAudioInputDevice.h" @@ -40,6 +42,7 @@ #include "SWGDVSeralDevices.h" #include "SWGDVSerialDevice.h" #include "SWGDeviceListItem.h" +#include "SWGDeviceReport.h" #include "SWGDeviceSet.h" #include "SWGDeviceSetList.h" #include "SWGDeviceSettings.h" @@ -106,6 +109,12 @@ namespace SWGSDRangel { if(QString("SWGAirspyHFSettings").compare(type) == 0) { return new SWGAirspyHFSettings(); } + if(QString("SWGAirspyReport").compare(type) == 0) { + return new SWGAirspyReport(); + } + if(QString("SWGAirspyReport_sampleRates").compare(type) == 0) { + return new SWGAirspyReport_sampleRates(); + } if(QString("SWGAirspySettings").compare(type) == 0) { return new SWGAirspySettings(); } @@ -163,6 +172,9 @@ namespace SWGSDRangel { if(QString("SWGDeviceListItem").compare(type) == 0) { return new SWGDeviceListItem(); } + if(QString("SWGDeviceReport").compare(type) == 0) { + return new SWGDeviceReport(); + } if(QString("SWGDeviceSet").compare(type) == 0) { return new SWGDeviceSet(); }