stephb9959
2022-10-03 16:10:39 -07:00
parent 9144377472
commit 4b0521e40a
25 changed files with 337 additions and 77 deletions

View File

@@ -8,7 +8,7 @@
#include "RESTAPI_RPC.h"
#include "CommandManager.h"
#include "DeviceRegistry.h"
#include "AP_WS_Server.h"
#include "StorageService.h"
#include "framework/ow_constants.h"
#include "ParseWifiScan.h"
@@ -48,11 +48,11 @@ namespace OpenWifi::RESTAPI_RPC {
// then we should just add the command to
// the DB and let it figure out when to deliver the command.
auto SerialNumberInt = Utils::SerialNumberToInt(Cmd.SerialNumber);
if (Cmd.RunAt || (!DeviceRegistry()->Connected(SerialNumberInt) && RetryLater)) {
if (Cmd.RunAt || (!AP_WS_Server()->Connected(SerialNumberInt) && RetryLater)) {
Logger.information(fmt::format("{},{}: Command will be run in the future or when device is connected again.", Cmd.UUID, RPCID));
SetCommandStatus(Cmd, Request, Response, Handler, Storage::CommandExecutionType::COMMAND_PENDING, Logger);
return;
} else if ((!DeviceRegistry()->Connected(SerialNumberInt) && !RetryLater)){
} else if ((!AP_WS_Server()->Connected(SerialNumberInt) && !RetryLater)){
Logger.information(fmt::format("{},{}: Command canceled. Device is not connected. Command will not be retried.", Cmd.UUID, RPCID));
return SetCommandStatus(Cmd, Request, Response, Handler, Storage::CommandExecutionType::COMMAND_FAILED, Logger);
}