mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 09:18:54 -05:00
Web API: changed /sdrangel/devicesets POST,DELETE to /sdrangel/deviceset to reflect that it applies to a single device set
This commit is contained in:
parent
e7c73b8449
commit
4b51599706
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@ QString WebAPIAdapterInterface::instancePresetsURL = "/sdrangel/presets";
|
||||
QString WebAPIAdapterInterface::instancePresetURL = "/sdrangel/preset";
|
||||
QString WebAPIAdapterInterface::instancePresetFileURL = "/sdrangel/preset/file";
|
||||
QString WebAPIAdapterInterface::instanceDeviceSetsURL = "/sdrangel/devicesets";
|
||||
QString WebAPIAdapterInterface::instanceDeviceSetURL = "/sdrangel/deviceset";
|
||||
|
||||
std::regex WebAPIAdapterInterface::devicesetURLRe("^/sdrangel/deviceset/([0-9]{1,2})$");
|
||||
std::regex WebAPIAdapterInterface::devicesetDeviceURLRe("^/sdrangel/deviceset/([0-9]{1,2})/device$");
|
||||
|
@ -309,10 +309,10 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/devicesets (POST) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* Handler of /sdrangel/deviceset (POST) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceDeviceSetsPost(
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx __attribute__((unused)),
|
||||
SWGSDRangel::SWGSuccessResponse& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
@ -323,10 +323,10 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler of /sdrangel/devicesets (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* Handler of /sdrangel/deviceset (DELETE) swagger/sdrangel/code/html2/index.html#api-Default-instanceChannels
|
||||
* returns the Http status code (default 501: not implemented)
|
||||
*/
|
||||
virtual int instanceDeviceSetsDelete(
|
||||
virtual int instanceDeviceSetDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
@ -506,6 +506,7 @@ public:
|
||||
static QString instancePresetURL;
|
||||
static QString instancePresetFileURL;
|
||||
static QString instanceDeviceSetsURL;
|
||||
static QString instanceDeviceSetURL;
|
||||
static std::regex devicesetURLRe;
|
||||
static std::regex devicesetDeviceURLRe;
|
||||
static std::regex devicesetDeviceSettingsURLRe;
|
||||
|
@ -90,6 +90,8 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
|
||||
instancePresetFileService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceDeviceSetsURL) {
|
||||
instanceDeviceSetsService(request, response);
|
||||
} else if (path == WebAPIAdapterInterface::instanceDeviceSetURL) {
|
||||
instanceDeviceSetService(request, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -715,7 +717,21 @@ void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& reque
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
else if (request.getMethod() == "POST")
|
||||
else
|
||||
{
|
||||
response.setStatus(405,"Invalid HTTP method");
|
||||
errorResponse.init();
|
||||
*errorResponse.getMessage() = "Invalid HTTP method";
|
||||
response.write(errorResponse.asJson().toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void WebAPIRequestMapper::instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
|
||||
{
|
||||
SWGSDRangel::SWGErrorResponse errorResponse;
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
if (request.getMethod() == "POST")
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
QByteArray txStr = request.getParameter("tx");
|
||||
@ -725,7 +741,7 @@ void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& reque
|
||||
tx = !(txStr == "0");
|
||||
}
|
||||
|
||||
int status = m_adapter->instanceDeviceSetsPost(tx, normalResponse, errorResponse);
|
||||
int status = m_adapter->instanceDeviceSetPost(tx, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
@ -737,7 +753,7 @@ void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& reque
|
||||
else if (request.getMethod() == "DELETE")
|
||||
{
|
||||
SWGSDRangel::SWGSuccessResponse normalResponse;
|
||||
int status = m_adapter->instanceDeviceSetsDelete(normalResponse, errorResponse);
|
||||
int status = m_adapter->instanceDeviceSetDelete(normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
|
@ -56,6 +56,7 @@ private:
|
||||
void instancePresetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instancePresetFileService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceDeviceSetsService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void instanceDeviceSetService(qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
|
||||
void devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
void devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response);
|
||||
|
@ -560,7 +560,7 @@ int WebAPIAdapterGUI::instanceDeviceSetsGet(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceDeviceSetsPost(
|
||||
int WebAPIAdapterGUI::instanceDeviceSetPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
@ -574,7 +574,7 @@ int WebAPIAdapterGUI::instanceDeviceSetsPost(
|
||||
return 202;
|
||||
}
|
||||
|
||||
int WebAPIAdapterGUI::instanceDeviceSetsDelete(
|
||||
int WebAPIAdapterGUI::instanceDeviceSetDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
|
@ -101,12 +101,12 @@ public:
|
||||
SWGSDRangel::SWGDeviceSetList& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetsPost(
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetsDelete(
|
||||
virtual int instanceDeviceSetDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
@ -688,7 +688,7 @@ int WebAPIAdapterSrv::instanceDeviceSetsGet(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDeviceSetsPost(
|
||||
int WebAPIAdapterSrv::instanceDeviceSetPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
|
||||
@ -702,7 +702,7 @@ int WebAPIAdapterSrv::instanceDeviceSetsPost(
|
||||
return 202;
|
||||
}
|
||||
|
||||
int WebAPIAdapterSrv::instanceDeviceSetsDelete(
|
||||
int WebAPIAdapterSrv::instanceDeviceSetDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
|
@ -116,12 +116,12 @@ public:
|
||||
SWGSDRangel::SWGDeviceSetList& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetsPost(
|
||||
virtual int instanceDeviceSetPost(
|
||||
bool tx,
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
virtual int instanceDeviceSetsDelete(
|
||||
virtual int instanceDeviceSetDelete(
|
||||
SWGSDRangel::SWGSuccessResponse& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
@ -499,9 +499,12 @@ paths:
|
||||
$ref: "#/responses/Response_500"
|
||||
"501":
|
||||
$ref: "#/responses/Response_501"
|
||||
|
||||
/sdrangel/deviceset:
|
||||
x-swagger-router-controller: instance
|
||||
post:
|
||||
description: Add (append) a new device set with default values
|
||||
operationId: instanceDeviceSetsPost
|
||||
operationId: instanceDeviceSetPost
|
||||
tags:
|
||||
- Instance
|
||||
parameters:
|
||||
@ -521,7 +524,7 @@ paths:
|
||||
$ref: "#/responses/Response_501"
|
||||
delete:
|
||||
description: Remove last device set. The GUI version does not remove the first device.
|
||||
operationId: instanceDeviceSetsDelete
|
||||
operationId: instanceDeviceSetDelete
|
||||
tags:
|
||||
- Instance
|
||||
responses:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,8 +25,8 @@ It uses the following APIs:
|
||||
- URI: `/sdrangel/preset`
|
||||
- HTTP method: `PATCH`
|
||||
- To create a new device set:
|
||||
- OperationID: `instanceDeviceSetsPost`
|
||||
- URI: `/sdrangel/devicesets`
|
||||
- OperationID: `instanceDeviceSetPost`
|
||||
- URI: `/sdrangel/deviceset`
|
||||
- HTTP method: `POST`
|
||||
- Activate the DV serial dongle support for digital voice modes
|
||||
- OperationID: `instanceDVSerialPatch`
|
||||
@ -44,8 +44,8 @@ Create a Tx device set with a LimeSDR Tx device and a NFM modulator channel conf
|
||||
It uses the following APIs:
|
||||
|
||||
- To create a new device set:
|
||||
- OperationID: `instanceDeviceSetsPost`
|
||||
- URI: `/sdrangel/devicesets`
|
||||
- OperationID: `instanceDeviceSetPost`
|
||||
- URI: `/sdrangel/deviceset`
|
||||
- HTTP method: `POST`
|
||||
- To select a device in a device set:
|
||||
- Operation ID: `devicesetDevicePut`
|
||||
|
@ -14,10 +14,10 @@ base_url = "http://127.0.0.1:8091/sdrangel"
|
||||
commands = [
|
||||
["/deviceset/0/device", "PUT", None, {"hwType": "BladeRF"}, "setup BladeRF on Rx 0"],
|
||||
["/preset", "PATCH", None, {"deviceSetIndex": 0, "preset": {"groupName": "OM144", "centerFrequency": 145640000, "type": "R", "name": "Repeaters extended"}}, "load preset on Rx 0"],
|
||||
["/devicesets", "POST", None, None, "add Rx 1 device set"],
|
||||
["/deviceset", "POST", None, None, "add Rx 1 device set"],
|
||||
["/deviceset/1/device", "PUT", None, {"hwType": "SDRdaemonSource"}, "setup SDRdaemonSource on Rx 1"],
|
||||
["/preset", "PATCH", None, {"deviceSetIndex": 1, "preset": {"groupName": "OM430", "centerFrequency": 439550000, "type": "R", "name": "F5ZKP Daemon RPi3 SUSE"}}, "load preset on Rx 1"],
|
||||
["/devicesets", "POST", None, None, "add Rx 2 device set"],
|
||||
["/deviceset", "POST", None, None, "add Rx 2 device set"],
|
||||
["/deviceset/2/device", "PUT", None, {"hwType": "SDRplay1"}, "setup SDRplay on Rx 2"],
|
||||
["/preset", "PATCH", None, {"deviceSetIndex": 2, "preset": {"groupName": "40m", "centerFrequency": 7130000, "type": "R", "name": "SSB low"}}, "load preset on Rx 2"],
|
||||
["/dvserial", "PATCH", {"dvserial": 1}, None, "set DV serial processing for AMBE frames decoding"],
|
||||
|
@ -57,7 +57,7 @@ def main():
|
||||
global base_url
|
||||
base_url = "http://%s/sdrangel" % options.address
|
||||
|
||||
r = callAPI("/devicesets", "POST", {"tx": 1}, None, "Add Tx device set")
|
||||
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
@ -68,7 +68,7 @@ def main():
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
r = callAPI("/devicesets", "POST", {"tx": 1}, None, "Add Tx device set")
|
||||
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user