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

@@ -15,7 +15,7 @@
#include "framework/MicroService.h"
#include "framework/RESTAPI_errors.h"
#include "framework/RESTAPI_protocol.h"
#include "DeviceRegistry.h"
#include "RESTAPI_device_helper.h"
namespace OpenWifi {
void RESTAPI_device_handler::DoGet() {
@@ -27,28 +27,9 @@ namespace OpenWifi {
GWObjects::Device Device;
if (StorageService()->GetDevice(SerialNumber, Device)) {
Poco::JSON::Object Answer;
if(GetBoolParameter("completeInfo",false)) {
GWObjects::ConnectionState CS;
DeviceRegistry()->GetState(SerialNumber,CS);
GWObjects::HealthCheck HC;
DeviceRegistry()->GetHealthcheck(SerialNumber, HC);
std::string Stats;
DeviceRegistry()->GetStatistics(SerialNumber, Stats);
Poco::JSON::Object Answer;
Poco::JSON::Object DeviceInfo;
Device.to_json(DeviceInfo);
Answer.set("deviceInfo", DeviceInfo);
Poco::JSON::Object CSInfo;
CS.to_json(CSInfo);
Answer.set("connectionInfo",CSInfo);
Poco::JSON::Object HCInfo;
HC.to_json(HCInfo);
Answer.set("healthCheckInfo",HCInfo);
Poco::JSON::Parser P;
auto StatsInfo = P.parse(Stats).extract<Poco::JSON::Object::Ptr>();
Answer.set("statsInfo",StatsInfo);
CompleteDeviceInfo(Device, Answer);
return ReturnObject(Answer);
} else {
Poco::JSON::Object Obj;