1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

Web API: implement devicesetDeviceGet (1)

This commit is contained in:
f4exb
2017-12-04 18:22:25 +01:00
parent a3fb30107b
commit 7dafae3fa1
7 changed files with 144 additions and 65 deletions
+16 -4
View File
@@ -86,9 +86,9 @@ void WebAPIRequestMapper::service(qtwebapp::HttpRequest& request, qtwebapp::Http
std::string pathStr(path.constData(), path.length());
if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetURLRe)) {
deviceset(std::string(desc_match[1]), request, response);
devicesetService(std::string(desc_match[1]), request, response);
} else if (std::regex_match(pathStr, desc_match, WebAPIAdapterInterface::devicesetDeviceURLRe)) {
devicesetDevice(std::string(desc_match[1]), request, response);
devicesetDeviceService(std::string(desc_match[1]), request, response);
}
else
{
@@ -539,7 +539,7 @@ void WebAPIRequestMapper::instanceDeviceSetsService(qtwebapp::HttpRequest& reque
}
}
void WebAPIRequestMapper::deviceset(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
void WebAPIRequestMapper::devicesetService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
@@ -573,7 +573,7 @@ void WebAPIRequestMapper::deviceset(const std::string& indexStr, qtwebapp::HttpR
}
}
void WebAPIRequestMapper::devicesetDevice(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
void WebAPIRequestMapper::devicesetDeviceService(const std::string& indexStr, qtwebapp::HttpRequest& request, qtwebapp::HttpResponse& response)
{
SWGSDRangel::SWGErrorResponse errorResponse;
@@ -600,6 +600,18 @@ void WebAPIRequestMapper::devicesetDevice(const std::string& indexStr, qtwebapp:
}
}
}
else if (request.getMethod() == "GET")
{
SWGSDRangel::SWGDeviceSettings normalResponse;
int status = m_adapter->devicesetDeviceGet(deviceSetIndex, normalResponse, errorResponse);
response.setStatus(status);
if (status == 200) {
response.write(normalResponse.asJson().toUtf8());
} else {
response.write(errorResponse.asJson().toUtf8());
}
}
else
{
response.setStatus(405,"Invalid HTTP method");