Adding "completeInfo" on device get and list.

This commit is contained in:
stephb9959
2021-12-05 22:54:33 -08:00
parent 8b22611142
commit c00effc8bc
6 changed files with 146 additions and 87 deletions

View File

@@ -13,12 +13,14 @@
#include "StorageService.h"
#include "framework/RESTAPI_protocol.h"
#include "framework/MicroService.h"
#include "RESTAPI/RESTAPI_device_helper.h"
namespace OpenWifi {
void RESTAPI_devices_handler::DoGet() {
auto serialOnly = GetBoolParameter(RESTAPI::Protocol::SERIALONLY, false);
auto deviceWithStatus = GetBoolParameter(RESTAPI::Protocol::DEVICEWITHSTATUS, false);
auto completeInfo = GetBoolParameter("completeInfo",false);
Poco::JSON::Object RetObj;
if (!QB_.Select.empty()) {
@@ -27,12 +29,18 @@ namespace OpenWifi {
for (auto &i : Numbers) {
GWObjects::Device D;
if (StorageService()->GetDevice(i, D)) {
Poco::JSON::Object Obj;
if (deviceWithStatus)
D.to_json_with_status(Obj);
else
D.to_json(Obj);
Objects.add(Obj);
if(completeInfo) {
Poco::JSON::Object FullDeviceInfo;
CompleteDeviceInfo(D, FullDeviceInfo);
Objects.add(FullDeviceInfo);
} else {
Poco::JSON::Object Obj;
if (deviceWithStatus)
D.to_json_with_status(Obj);
else
D.to_json(Obj);
Objects.add(Obj);
}
} else {
Logger_.error(
Poco::format("DEVICE(%s): device in select cannot be found.", i));