Add PoC PWN duty cycle adjustment command for FaceFocus

This commit is contained in:
Lorow
2025-08-19 00:03:31 +02:00
parent 9a1f55d012
commit 21e8dbe264
13 changed files with 227 additions and 99 deletions

View File

@@ -25,6 +25,8 @@ CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry,
const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
projectConfig->setDeviceMode(static_cast<StreamingMode>(mode));
cJSON_Delete(parsedJson);
return CommandResult::getSuccessResult("Device mode set");
}
@@ -64,10 +66,41 @@ CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> re
}
}
projectConfig->setDeviceConfig(OTALogin, OTAPassword, OTAPort);
cJSON_Delete(parsedJson);
projectConfig->setOTAConfig(OTALogin, OTAPassword, OTAPort);
return CommandResult::getSuccessResult("OTA Config set");
}
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload)
{
const auto parsedJson = cJSON_Parse(jsonPayload.data());
if (parsedJson == nullptr)
{
return CommandResult::getErrorResult("Invalid payload");
}
const auto dutyCycleObject = cJSON_GetObjectItem(parsedJson, "dutyCycle");
if (dutyCycleObject == nullptr)
{
return CommandResult::getErrorResult("Invalid payload - missing dutyCycle");
}
const auto dutyCycle = dutyCycleObject->valueint;
if (dutyCycle < 0 || dutyCycle > 100)
{
return CommandResult::getErrorResult("Invalid payload - unsupported dutyCycle");
}
const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
projectConfig->setLEDDUtyCycleConfig(dutyCycle);
cJSON_Delete(parsedJson);
return CommandResult::getSuccessResult("LED duty cycle set");
}
CommandResult restartDeviceCommand()
{
OpenIrisTasks::ScheduleRestart(2000);

View File

@@ -13,6 +13,8 @@ CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry,
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult restartDeviceCommand();
CommandResult startStreamingCommand();