mirror of
https://github.com/MrUnknownDE/OpenIris-ESPIDF.git
synced 2026-04-18 22:13:45 +02:00
Add 'get_who_am_i' command and related configurations for device identification
This commit is contained in:
@@ -26,7 +26,8 @@ std::unordered_map<std::string, CommandType> commandTypeMap = {
|
||||
{"set_led_duty_cycle", CommandType::SET_LED_DUTY_CYCLE},
|
||||
{"get_led_duty_cycle", CommandType::GET_LED_DUTY_CYCLE},
|
||||
{"get_serial", CommandType::GET_SERIAL},
|
||||
{"get_led_current", CommandType::GET_LED_CURRENT},
|
||||
{"get_led_current", CommandType::GET_LED_CURRENT},
|
||||
{"get_who_am_i", CommandType::GET_WHO_AM_I},
|
||||
};
|
||||
|
||||
std::function<CommandResult()> CommandManager::createCommand(const CommandType type, std::string_view json) const
|
||||
@@ -107,6 +108,9 @@ std::function<CommandResult()> CommandManager::createCommand(const CommandType t
|
||||
case CommandType::GET_LED_CURRENT:
|
||||
return [this]
|
||||
{ return getLEDCurrentCommand(this->registry); };
|
||||
case CommandType::GET_WHO_AM_I:
|
||||
return [this]
|
||||
{ return getInfoCommand(this->registry); };
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ enum class CommandType
|
||||
GET_LED_DUTY_CYCLE,
|
||||
GET_SERIAL,
|
||||
GET_LED_CURRENT,
|
||||
GET_WHO_AM_I,
|
||||
};
|
||||
|
||||
class CommandManager
|
||||
|
||||
@@ -248,3 +248,14 @@ CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
return CommandResult::getErrorResult("Monitoring disabled");
|
||||
#endif
|
||||
}
|
||||
|
||||
CommandResult getInfoCommand(std::shared_ptr<DependencyRegistry> /*registry*/)
|
||||
{
|
||||
const char* who = CONFIG_GENERAL_WHO_AM_I;
|
||||
const char* ver = CONFIG_GENERAL_Version;
|
||||
// Ensure non-null strings
|
||||
if (!who) who = "";
|
||||
if (!ver) ver = "";
|
||||
auto result = std::format("{{ \"who_am_i\": \"{}\", \"version\": \"{}\" }}", who, ver);
|
||||
return CommandResult::getSuccessResult(result);
|
||||
}
|
||||
|
||||
@@ -25,4 +25,7 @@ CommandResult getDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry)
|
||||
CommandResult getSerialNumberCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
// Monitoring
|
||||
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
|
||||
// General info
|
||||
CommandResult getInfoCommand(std::shared_ptr<DependencyRegistry> registry);
|
||||
Reference in New Issue
Block a user