diff --git a/sdrbase/resources/index.html b/sdrbase/resources/index.html
index a985d113c..99e65e0da 100644
--- a/sdrbase/resources/index.html
+++ b/sdrbase/resources/index.html
@@ -792,7 +792,7 @@ margin-bottom: 20px;
"description" : "Channel summarized information"
};
defs.ChannelListItem = {
- "required" : [ "id", "name" ],
+ "required" : [ "id" ],
"properties" : {
"name" : {
"type" : "string",
@@ -848,7 +848,7 @@ margin-bottom: 20px;
"description" : "DV serial device details"
};
defs.DeviceListItem = {
- "required" : [ "hwType" ],
+ "required" : [ "hwType", "tx" ],
"properties" : {
"displayedName" : {
"type" : "string",
@@ -8445,7 +8445,7 @@ except ApiException as e:
- Generated 2017-11-26T00:25:44.253+01:00
+ Generated 2017-11-26T10:35:17.573+01:00
diff --git a/sdrbase/webapi/webapiadapterinterface.cpp b/sdrbase/webapi/webapiadapterinterface.cpp
index 7958099b0..0f940a953 100644
--- a/sdrbase/webapi/webapiadapterinterface.cpp
+++ b/sdrbase/webapi/webapiadapterinterface.cpp
@@ -28,5 +28,5 @@ QString WebAPIAdapterInterface::instanceDVSerialURL = "/sdrangel/dvserial";
QString WebAPIAdapterInterface::instancePresetURL = "/sdrangel/preset";
QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets";
-std::regex WebAPIAdapterInterface::devicesetURLRe("^/sdrangel/deviceset/([0-9]+)$");
-std::regex WebAPIAdapterInterface::devicesetDeviceURLRe("^/sdrangel/deviceset/([0-9]+)/device$");
+std::regex WebAPIAdapterInterface::devicesetURLRe("^/sdrangel/deviceset/([0-9]{1,2})$");
+std::regex WebAPIAdapterInterface::devicesetDeviceURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device$");
diff --git a/sdrbase/webapi/webapiadapterinterface.h b/sdrbase/webapi/webapiadapterinterface.h
index c3417bbe0..570e41801 100644
--- a/sdrbase/webapi/webapiadapterinterface.h
+++ b/sdrbase/webapi/webapiadapterinterface.h
@@ -205,7 +205,6 @@ public:
Swagger::SWGErrorResponse& error __attribute__((unused)))
{ return 501; }
-
/**
* Handler of /sdrangel/devicesets (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
* returns the Http status code (default 501: not implemented)
@@ -215,6 +214,16 @@ public:
Swagger::SWGErrorResponse& error __attribute__((unused)))
{ return 501; }
+ /**
+ * Handler of /sdrangel/devicesets (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
+ * returns the Http status code (default 501: not implemented)
+ */
+ virtual int devicesetGet(
+ int deviceSetIndex __attribute__((unused)),
+ Swagger::SWGDeviceSet& response __attribute__((unused)),
+ Swagger::SWGErrorResponse& error __attribute__((unused)))
+ { return 501; }
+
static QString instanceSummaryURL;
static QString instanceDevicesURL;
static QString instanceChannelsURL;
diff --git a/sdrbase/webapi/webapirequestmapper.cpp b/sdrbase/webapi/webapirequestmapper.cpp
index 0fa7c9f8f..18c24a7ac 100644
--- a/sdrbase/webapi/webapirequestmapper.cpp
+++ b/sdrbase/webapi/webapirequestmapper.cpp
@@ -20,6 +20,8 @@
#include
#include
+#include
+
#include "httpdocrootsettings.h"
#include "webapirequestmapper.h"
#include "SWGInstanceSummaryResponse.h"
@@ -80,13 +82,23 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
}
else
{
+ std::smatch desc_match;
+ std::string pathStr(path.constData(), path.length());
+
+ if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetURLRe)) {
+ deviceset(std::string(desc_match[1]), request, response);
+ }
+ else
+ {
+ QByteArray path = "/index.html";
+ m_staticFileController->service(path, response);
+ }
+
// QDirIterator it(":", QDirIterator::Subdirectories);
// while (it.hasNext()) {
// qDebug() << "WebAPIRequestMapper::service: " << it.next();
// }
- QByteArray path = "/index.html";
- m_staticFileController->service(path, response);
}
}
}
@@ -525,6 +537,40 @@ void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& reque
}
}
+void WebAPIRequestMapper::deviceset(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
+{
+ Swagger::SWGErrorResponse errorResponse;
+
+ if (request.getMethod() == "GET")
+ {
+ try
+ {
+ Swagger::SWGDeviceSet normalResponse;
+ int deviceSetIndex = boost::lexical_cast(indexStr);
+ int status = m_adapter->devicesetGet(deviceSetIndex, normalResponse, errorResponse);
+ response.setStatus(status);
+
+ if (status == 200) {
+ 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");
+ response.write("Invalid HTTP method");
+ }
+}
+
bool WebAPIRequestMapper::parseJsonBody(QString& jsonStr, qtwebapp::HttpResponse& response)
{
Swagger::SWGErrorResponse errorResponse;
diff --git a/sdrbase/webapi/webapirequestmapper.h b/sdrbase/webapi/webapirequestmapper.h
index 7e19455f6..097a8d3b5 100644
--- a/sdrbase/webapi/webapirequestmapper.h
+++ b/sdrbase/webapi/webapirequestmapper.h
@@ -55,6 +55,8 @@ private:
void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
+ void deviceset(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
+
bool validatePresetTransfer(Swagger::SWGPresetTransfer& presetTransfer);
bool validatePresetIdentifer(Swagger::SWGPresetIdentifier& presetIdentifier);
diff --git a/sdrgui/webapi/webapiadaptergui.cpp b/sdrgui/webapi/webapiadaptergui.cpp
index 0f0417700..7dbbbc9b2 100644
--- a/sdrgui/webapi/webapiadaptergui.cpp
+++ b/sdrgui/webapi/webapiadaptergui.cpp
@@ -593,6 +593,27 @@ int WebAPIAdapterGUI::instanceDeviceSetsDelete(
}
}
+int WebAPIAdapterGUI::devicesetGet(
+ int deviceSetIndex,
+ Swagger::SWGDeviceSet& response,
+ Swagger::SWGErrorResponse& error)
+{
+ if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_mainWindow.m_deviceUIs.size()))
+ {
+ const DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[deviceSetIndex];
+ getDeviceSet(&response, deviceSet, deviceSetIndex);
+
+ return 200;
+ }
+ else
+ {
+ error.init();
+ *error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
+
+ return 404;
+ }
+}
+
void WebAPIAdapterGUI::getDeviceSetList(Swagger::SWGDeviceSetList* deviceSetList)
{
deviceSetList->init();
diff --git a/sdrgui/webapi/webapiadaptergui.h b/sdrgui/webapi/webapiadaptergui.h
index 992844ea5..5a8a74e96 100644
--- a/sdrgui/webapi/webapiadaptergui.h
+++ b/sdrgui/webapi/webapiadaptergui.h
@@ -110,6 +110,11 @@ public:
Swagger::SWGDeviceSetList& response,
Swagger::SWGErrorResponse& error);
+ virtual int devicesetGet(
+ int deviceSetIndex,
+ Swagger::SWGDeviceSet& response,
+ Swagger::SWGErrorResponse& error);
+
private:
MainWindow& m_mainWindow;
diff --git a/swagger/sdrangel/api/swagger/swagger.yaml b/swagger/sdrangel/api/swagger/swagger.yaml
index ed972ad4e..5a6be6d13 100644
--- a/swagger/sdrangel/api/swagger/swagger.yaml
+++ b/swagger/sdrangel/api/swagger/swagger.yaml
@@ -550,6 +550,7 @@ definitions:
description: "Summarized information about attached hardware device"
required:
- hwType
+ - tx
properties:
displayedName:
description: "Displayable name that uniquely identifies this device instance"
@@ -581,7 +582,6 @@ definitions:
ChannelListItem:
description: "Summarized information about channel plugin"
required:
- - name
- id
properties:
name:
diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html
index a985d113c..99e65e0da 100644
--- a/swagger/sdrangel/code/html2/index.html
+++ b/swagger/sdrangel/code/html2/index.html
@@ -792,7 +792,7 @@ margin-bottom: 20px;
"description" : "Channel summarized information"
};
defs.ChannelListItem = {
- "required" : [ "id", "name" ],
+ "required" : [ "id" ],
"properties" : {
"name" : {
"type" : "string",
@@ -848,7 +848,7 @@ margin-bottom: 20px;
"description" : "DV serial device details"
};
defs.DeviceListItem = {
- "required" : [ "hwType" ],
+ "required" : [ "hwType", "tx" ],
"properties" : {
"displayedName" : {
"type" : "string",
@@ -8445,7 +8445,7 @@ except ApiException as e:
- Generated 2017-11-26T00:25:44.253+01:00
+ Generated 2017-11-26T10:35:17.573+01:00