mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 13:51:47 -05:00
New AMBE engine REST API support
This commit is contained in:
parent
144b0db196
commit
4ef1f011cb
@ -431,7 +431,7 @@ paths:
|
||||
x-swagger-router-controller: instance
|
||||
get:
|
||||
description: get the list of AMBE devices (serial or address) used for AMBE frames decoding in digital voice modes
|
||||
operationId: InstanceAMBEDevicesGet
|
||||
operationId: instanceAMBEDevicesGet
|
||||
tags:
|
||||
- Instance
|
||||
responses:
|
||||
@ -445,7 +445,7 @@ paths:
|
||||
$ref: "#/responses/Response_501"
|
||||
put:
|
||||
description: Replace the list of active devices
|
||||
operationId: InstanceAMBEDevicesPut
|
||||
operationId: instanceAMBEDevicesPut
|
||||
tags:
|
||||
- Instance
|
||||
consumes:
|
||||
@ -468,7 +468,7 @@ paths:
|
||||
$ref: "#/responses/Response_501"
|
||||
delete:
|
||||
description: Emtpy the active devices thus effectively closing down AMBE devices support
|
||||
operationId: InstanceAMBEDevicesDelete
|
||||
operationId: instanceAMBEDevicesDelete
|
||||
tags:
|
||||
- Instance
|
||||
responses:
|
||||
@ -482,7 +482,7 @@ paths:
|
||||
$ref: "#/responses/Response_501"
|
||||
patch:
|
||||
description: Add and/or delete devices to/from the active list
|
||||
operationId: InstanceAMBEDevicesPatch
|
||||
operationId: instanceAMBEDevicesPatch
|
||||
tags:
|
||||
- Instance
|
||||
consumes:
|
||||
|
@ -30,6 +30,8 @@ QString WebAPIAdapterInterface::instanceAudioInputCleanupURL = "/sdrangel/audio/
|
||||
QString WebAPIAdapterInterface::instanceAudioOutputCleanupURL = "/sdrangel/audio/output/cleanup";
|
||||
QString WebAPIAdapterInterface::instanceLocationURL = "/sdrangel/location";
|
||||
QString WebAPIAdapterInterface::instanceDVSerialURL = "/sdrangel/dvserial";
|
||||
QString WebAPIAdapterInterface::instanceAMBESerialURL = "/sdrangel/ambe/serial";
|
||||
QString WebAPIAdapterInterface::instanceAMBEDevicesURL = "/sdrangel/ambe/devices";
|
||||
QString WebAPIAdapterInterface::instancePresetsURL = "/sdrangel/presets";
|
||||
QString WebAPIAdapterInterface::instancePresetURL = "/sdrangel/preset";
|
||||
QString WebAPIAdapterInterface::instancePresetFileURL = "/sdrangel/preset/file";
|
||||
|
@ -38,6 +38,7 @@ namespace SWGSDRangel
|
||||
class SWGAudioOutputDevice;
|
||||
class SWGLocationInformation;
|
||||
class SWGDVSeralDevices;
|
||||
class SWGAMBEDevices;
|
||||
class SWGPresets;
|
||||
class SWGPresetTransfer;
|
||||
class SWGPresetIdentifier;
|
||||
@ -310,6 +311,80 @@ public:
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/ambe/serial (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceAMBESerialGet(
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/ambe/devices (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceAMBEDevicesGet(
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/ambe/devices (PUT) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceAMBEDevicesPut(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) query;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/ambe/devices (PATCH) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceAMBEDevicesPatch(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) query;
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/ambe/devices (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceAMBEDevicesDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) response;
|
||||
error.init();
|
||||
*error.getMessage() = QString("Function not implemented");
|
||||
return 501;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/presets (GET) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
@ -735,6 +810,8 @@ public:
|
||||
static QString instanceAudioOutputCleanupURL;
|
||||
static QString instanceLocationURL;
|
||||
static QString instanceDVSerialURL;
|
||||
static QString instanceAMBESerialURL;
|
||||
static QString instanceAMBEDevicesURL;
|
||||
static QString instancePresetsURL;
|
||||
static QString instancePresetURL;
|
||||
static QString instancePresetFileURL;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "SWGAudioDevices.h"
|
||||
#include "SWGLocationInformation.h"
|
||||
#include "SWGDVSeralDevices.h"
|
||||
#include "SWGAMBEDevices.h"
|
||||
#include "SWGPresets.h"
|
||||
#include "SWGPresetTransfer.h"
|
||||
#include "SWGPresetIdentifier.h"
|
||||
@ -115,6 +116,10 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
||||
instanceLocationService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceDVSerialURL) {
|
||||
instanceDVSerialService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceAMBESerialURL) {
|
||||
instanceAMBESerialService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceAMBEDevicesURL) {
|
||||
instanceAMBEDevicesService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instancePresetsURL) {
|
||||
instancePresetsService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instancePresetURL) {
|
||||
@ -664,6 +669,118 @@ void WebAPIRequestMapper::instanceDVSerialService(qtwebapp::HttpRequest& request
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::instanceAMBESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGDVSeralDevices normalResponse;
|
||||
|
||||
int status = m_adapter->instanceAMBESerialGet(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
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::instanceAMBEDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
if (request.getMethod() == "GET")
|
||||
{
|
||||
SWGSDRangel::SWGAMBEDevices normalResponse;
|
||||
|
||||
int status = m_adapter->instanceAMBEDevicesGet(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else if ((request.getMethod() == "PATCH") || (request.getMethod() == "PUT"))
|
||||
{
|
||||
SWGSDRangel::SWGAMBEDevices query;
|
||||
SWGSDRangel::SWGAMBEDevices normalResponse;
|
||||
QString jsonStr = request.getBody();
|
||||
QJsonObject jsonObject;
|
||||
|
||||
if (parseJsonBody(jsonStr, jsonObject, response))
|
||||
{
|
||||
if (validateAMBEDevices(query, jsonObject))
|
||||
{
|
||||
int status;
|
||||
|
||||
if (request.getMethod() == "PATCH") {
|
||||
status = m_adapter->instanceAMBEDevicesPatch(query, normalResponse, errorResponse);
|
||||
} else {
|
||||
status = m_adapter->instanceAMBEDevicesPut(query, normalResponse, errorResponse);
|
||||
}
|
||||
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(400,"Invalid JSON request");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid JSON request";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response.setStatus(400,"Invalid JSON format");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid JSON format";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else if (request.getMethod() == "DELETE")
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
|
||||
int status = m_adapter->instanceAMBEDevicesDelete(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
response.write(normalResponse.asJson().toUtf8());
|
||||
} else {
|
||||
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::instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
@ -2637,6 +2754,51 @@ bool WebAPIRequestMapper::validateAudioOutputDevice(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebAPIRequestMapper::validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject)
|
||||
{
|
||||
if (jsonObject.contains("nbDevices"))
|
||||
{
|
||||
int nbDevices = jsonObject["nbDevices"].toInt();
|
||||
|
||||
if (jsonObject.contains("ambeDevices"))
|
||||
{
|
||||
QJsonArray ambeDevicesJson = jsonObject["ambeDevices"].toArray();
|
||||
|
||||
if (nbDevices != ambeDevicesJson.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ambeDevices.init();
|
||||
ambeDevices.setNbDevices(nbDevices);
|
||||
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = ambeDevices.getAmbeDevices();
|
||||
|
||||
for (int i = 0; i < nbDevices; i++)
|
||||
{
|
||||
QJsonObject ambeDeviceJson = ambeDevicesJson.at(i).toObject();
|
||||
if (ambeDeviceJson.contains("deviceRef") && ambeDeviceJson.contains("delete"))
|
||||
{
|
||||
ambeList->push_back(new SWGSDRangel::SWGAMBEDevice());
|
||||
ambeList->back()->init();
|
||||
ambeList->back()->setDeviceRef(new QString(ambeDeviceJson["deviceRef"].toString()));
|
||||
ambeList->back()->setDelete(ambeDeviceJson["delete"].toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::appendSettingsSubKeys(
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
QJsonObject& childSettingsJsonObject,
|
||||
|
@ -59,6 +59,8 @@ private:
|
||||
void instanceAudioOutputCleanupService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceLocationService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceDVSerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceAMBESerialService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceAMBEDevicesService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instancePresetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
@ -85,6 +87,7 @@ private:
|
||||
bool validateChannelSettings(SWGSDRangel::SWGChannelSettings& deviceSettings, QJsonObject& jsonObject, QStringList& channelSettingsKeys);
|
||||
bool validateAudioInputDevice(SWGSDRangel::SWGAudioInputDevice& audioInputDevice, QJsonObject& jsonObject, QStringList& audioInputDeviceKeys);
|
||||
bool validateAudioOutputDevice(SWGSDRangel::SWGAudioOutputDevice& audioOutputDevice, QJsonObject& jsonObject, QStringList& audioOutputDeviceKeys);
|
||||
bool validateAMBEDevices(SWGSDRangel::SWGAMBEDevices& ambeDevices, QJsonObject& jsonObject);
|
||||
|
||||
void appendSettingsSubKeys(
|
||||
const QJsonObject& parentSettingsJsonObject,
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "SWGLocationInformation.h"
|
||||
#include "SWGDVSeralDevices.h"
|
||||
#include "SWGDVSerialDevice.h"
|
||||
#include "SWGAMBEDevices.h"
|
||||
#include "SWGPresets.h"
|
||||
#include "SWGPresetGroup.h"
|
||||
#include "SWGPresetItem.h"
|
||||
@ -626,6 +627,113 @@ int WebAPIAdapterGUI::instanceDVSerialPatch(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceAMBESerialGet(
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
|
||||
std::vector<std::string> deviceNames;
|
||||
std::vector<QString> qDeviceNames;
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->scan(qDeviceNames);
|
||||
|
||||
for (std::vector<QString>::const_iterator it = qDeviceNames.begin(); it != qDeviceNames.end(); ++it) {
|
||||
deviceNames.push_back(it->toStdString());
|
||||
}
|
||||
|
||||
response.setNbDevices((int) deviceNames.size());
|
||||
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
|
||||
|
||||
std::vector<std::string>::iterator it = deviceNames.begin();
|
||||
|
||||
while (it != deviceNames.end())
|
||||
{
|
||||
deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice);
|
||||
deviceNamesList->back()->init();
|
||||
*deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it);
|
||||
++it;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceAMBEDevicesGet(
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
|
||||
std::vector<std::string> deviceNames;
|
||||
m_mainWindow.m_dspEngine->getDVSerialNames(deviceNames);
|
||||
response.setNbDevices((int) deviceNames.size());
|
||||
QList<SWGSDRangel::SWGAMBEDevice*> *deviceNamesList = response.getAmbeDevices();
|
||||
|
||||
std::vector<std::string>::iterator it = deviceNames.begin();
|
||||
|
||||
while (it != deviceNames.end())
|
||||
{
|
||||
deviceNamesList->append(new SWGSDRangel::SWGAMBEDevice);
|
||||
deviceNamesList->back()->init();
|
||||
*deviceNamesList->back()->getDeviceRef() = QString::fromStdString(*it);
|
||||
deviceNamesList->back()->setDelete(0);
|
||||
++it;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceAMBEDevicesDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->releaseAll();
|
||||
|
||||
response.init();
|
||||
*response.getMessage() = QString("All AMBE devices released");
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceAMBEDevicesPut(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->releaseAll();
|
||||
|
||||
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
|
||||
|
||||
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) {
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
|
||||
}
|
||||
|
||||
instanceAMBEDevicesGet(response, error);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceAMBEDevicesPatch(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
|
||||
|
||||
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it)
|
||||
{
|
||||
if ((*it)->getDelete()) {
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString());
|
||||
} else {
|
||||
m_mainWindow.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
instanceAMBEDevicesGet(response, error);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instancePresetsGet(
|
||||
SWGSDRangel::SWGPresets& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
|
@ -107,6 +107,28 @@ public:
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBESerialGet(
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesGet(
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesPut(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesPatch(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instancePresetsGet(
|
||||
SWGSDRangel::SWGPresets& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "SWGAudioDevices.h"
|
||||
#include "SWGLocationInformation.h"
|
||||
#include "SWGDVSeralDevices.h"
|
||||
#include "SWGAMBEDevices.h"
|
||||
#include "SWGPresetImport.h"
|
||||
#include "SWGPresetExport.h"
|
||||
#include "SWGPresets.h"
|
||||
@ -609,6 +610,113 @@ int WebAPIAdapterSrv::instanceDVSerialPatch(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceAMBESerialGet(
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
|
||||
std::vector<std::string> deviceNames;
|
||||
std::vector<QString> qDeviceNames;
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->scan(qDeviceNames);
|
||||
|
||||
for (std::vector<QString>::const_iterator it = qDeviceNames.begin(); it != qDeviceNames.end(); ++it) {
|
||||
deviceNames.push_back(it->toStdString());
|
||||
}
|
||||
|
||||
response.setNbDevices((int) deviceNames.size());
|
||||
QList<SWGSDRangel::SWGDVSerialDevice*> *deviceNamesList = response.getDvSerialDevices();
|
||||
|
||||
std::vector<std::string>::iterator it = deviceNames.begin();
|
||||
|
||||
while (it != deviceNames.end())
|
||||
{
|
||||
deviceNamesList->append(new SWGSDRangel::SWGDVSerialDevice);
|
||||
deviceNamesList->back()->init();
|
||||
*deviceNamesList->back()->getDeviceName() = QString::fromStdString(*it);
|
||||
++it;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceAMBEDevicesGet(
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
response.init();
|
||||
|
||||
std::vector<std::string> deviceNames;
|
||||
m_mainCore.m_dspEngine->getDVSerialNames(deviceNames);
|
||||
response.setNbDevices((int) deviceNames.size());
|
||||
QList<SWGSDRangel::SWGAMBEDevice*> *deviceNamesList = response.getAmbeDevices();
|
||||
|
||||
std::vector<std::string>::iterator it = deviceNames.begin();
|
||||
|
||||
while (it != deviceNames.end())
|
||||
{
|
||||
deviceNamesList->append(new SWGSDRangel::SWGAMBEDevice);
|
||||
deviceNamesList->back()->init();
|
||||
*deviceNamesList->back()->getDeviceRef() = QString::fromStdString(*it);
|
||||
deviceNamesList->back()->setDelete(0);
|
||||
++it;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceAMBEDevicesDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
(void) error;
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll();
|
||||
|
||||
response.init();
|
||||
*response.getMessage() = QString("All AMBE devices released");
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceAMBEDevicesPut(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->releaseAll();
|
||||
|
||||
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
|
||||
|
||||
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it) {
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
|
||||
}
|
||||
|
||||
instanceAMBEDevicesGet(response, error);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceAMBEDevicesPatch(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
QList<SWGSDRangel::SWGAMBEDevice *> *ambeList = query.getAmbeDevices();
|
||||
|
||||
for (QList<SWGSDRangel::SWGAMBEDevice *>::const_iterator it = ambeList->begin(); it != ambeList->end(); ++it)
|
||||
{
|
||||
if ((*it)->getDelete()) {
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->releaseController((*it)->getDeviceRef()->toStdString());
|
||||
} else {
|
||||
m_mainCore.m_dspEngine->getAMBEEngine()->registerController((*it)->getDeviceRef()->toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
instanceAMBEDevicesGet(response, error);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instancePresetFilePut(
|
||||
SWGSDRangel::SWGPresetImport& query,
|
||||
SWGSDRangel::SWGPresetIdentifier& response,
|
||||
|
@ -107,6 +107,28 @@ public:
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBESerialGet(
|
||||
SWGSDRangel::SWGDVSeralDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesGet(
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesPut(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesPatch(
|
||||
SWGSDRangel::SWGAMBEDevices& query,
|
||||
SWGSDRangel::SWGAMBEDevices& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceAMBEDevicesDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instancePresetFilePut(
|
||||
SWGSDRangel::SWGPresetImport& query,
|
||||
SWGSDRangel::SWGPresetIdentifier& response,
|
||||
|
Loading…
Reference in New Issue
Block a user