Added several new commands.

This commit is contained in:
stephb9959
2021-05-18 11:24:36 -07:00
parent 90cfaff82c
commit 5ca81b94a4

View File

@@ -638,26 +638,18 @@ void RESTAPI_device_commandHandler::LEDs(Poco::Net::HTTPServerRequest &Request,
Poco::JSON::Object::Ptr Obj = parser.parse(Request.stream()).extract<Poco::JSON::Object::Ptr>();
Poco::DynamicStruct ds = *Obj;
std::cout << __LINE__ <<std::endl;
if (ds.contains("pattern") &&
ds.contains("serialNumber")) {
std::cout << __LINE__ <<std::endl;
auto SerialNumber = ds["serialNumber"].toString();
std::cout << __LINE__ <<std::endl;
if(SerialNumber != SNum) {
std::cout << __LINE__ <<std::endl;
BadRequest(Response);
return;
}
std::cout << __LINE__ <<std::endl;
auto Pattern = ds["pattern"].toString();
std::cout << "LEDS:" << Pattern << " " << SerialNumber << " " << std::endl;
if(Pattern!="on" && Pattern!="off" && Pattern!="blink")
{
Logger_.warning(Poco::format("LEDs(%s): Bad pattern",SerialNumber));
@@ -671,6 +663,8 @@ void RESTAPI_device_commandHandler::LEDs(Poco::Net::HTTPServerRequest &Request,
if(ds.contains("when"))
When = uCentral::Utils::from_RFC3339(ds["when"].toString());
Logger_.information(Poco::format("LEDS(%s): Pattern:%s Duration: %d", SerialNumber, Pattern, (int)Duration));
uCentral::Objects::CommandDetails Cmd;
Cmd.SerialNumber = SerialNumber;