Add get device name command for displaying the current name in the setup tool

This commit is contained in:
Lorow
2025-08-16 15:08:06 +02:00
parent 3b817ce28f
commit cbcb9b492e
6 changed files with 43 additions and 13 deletions

View File

@@ -9,8 +9,6 @@
#include <format>
#include <string>
CommandResult setDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult updateOTACredentialsCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult updateLEDDutyCycleCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);

View File

@@ -31,3 +31,12 @@ CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, std::
return CommandResult::getSuccessResult("Config updated");
}
CommandResult getMDNSNameCommand(std::shared_ptr<DependencyRegistry> registry)
{
const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
auto mdnsConfig = projectConfig->getMDNSConfig();
auto result = std::format("{{ \"hostname\": \"{}\" }}", mdnsConfig.hostname);
return CommandResult::getSuccessResult(result);
}

View File

@@ -8,4 +8,5 @@
#include "DependencyRegistry.hpp"
std::optional<MDNSPayload> parseMDNSCommandPayload(std::string_view jsonPayload);
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult setMDNSCommand(std::shared_ptr<DependencyRegistry> registry, std::string_view jsonPayload);
CommandResult getMDNSNameCommand(std::shared_ptr<DependencyRegistry> registry);