- Updated README to reflect changes in device mode terminology from "Auto" to "Setup".

- Changed configuration macros from CONFIG_GENERAL_DEFAULT_WIRED_MODE to CONFIG_GENERAL_INCLUDE_UVC_MODE across multiple files.
- Introduced new command for retrieving LED current in CommandManager.
- Added MonitoringManager and CurrentMonitor classes to handle LED current monitoring.
- Updated Kconfig to include options for LED current monitoring.
- Modified main application logic to integrate MonitoringManager and handle new device modes.
- Adjusted CMakeLists and source files to include new monitoring components.
This commit is contained in:
PhosphorosVR
2025-09-05 01:08:11 +02:00
parent d73958530a
commit 83d7805e9e
25 changed files with 499 additions and 66 deletions

View File

@@ -11,5 +11,5 @@ idf_component_register(
INCLUDE_DIRS
"CommandManager"
"CommandManager/commands"
REQUIRES ProjectConfig cJSON CameraManager OpenIrisTasks wifiManager Helpers LEDManager
REQUIRES ProjectConfig cJSON CameraManager OpenIrisTasks wifiManager Helpers LEDManager Monitoring
)

View File

@@ -26,6 +26,7 @@ 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},
};
std::function<CommandResult()> CommandManager::createCommand(const CommandType type, std::string_view json) const
@@ -103,6 +104,9 @@ std::function<CommandResult()> CommandManager::createCommand(const CommandType t
case CommandType::GET_SERIAL:
return [this]
{ return getSerialNumberCommand(this->registry); };
case CommandType::GET_LED_CURRENT:
return [this]
{ return getLEDCurrentCommand(this->registry); };
default:
return nullptr;
}

View File

@@ -47,6 +47,7 @@ enum class CommandType
SET_LED_DUTY_CYCLE,
GET_LED_DUTY_CYCLE,
GET_SERIAL,
GET_LED_CURRENT,
};
class CommandManager

View File

@@ -9,7 +9,8 @@ enum class DependencyType
project_config,
camera_manager,
wifi_manager,
led_manager
led_manager,
monitoring_manager
};
class DependencyRegistry

View File

@@ -1,5 +1,6 @@
#include "device_commands.hpp"
#include "LEDManager.hpp"
#include "MonitoringManager.hpp"
#include "esp_mac.h"
#include <cstdio>
@@ -171,9 +172,9 @@ CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, st
{
newMode = StreamingMode::WIFI;
}
else if (strcmp(modeStr, "auto") == 0)
else if (strcmp(modeStr, "setup") == 0 || strcmp(modeStr, "auto") == 0)
{
newMode = StreamingMode::AUTO;
newMode = StreamingMode::SETUP;
}
else
{
@@ -203,8 +204,8 @@ CommandResult getDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry)
case StreamingMode::WIFI:
modeStr = "WiFi";
break;
case StreamingMode::AUTO:
modeStr = "Auto";
case StreamingMode::SETUP:
modeStr = "Setup";
break;
}
@@ -231,3 +232,19 @@ CommandResult getSerialNumberCommand(std::shared_ptr<DependencyRegistry> /*regis
auto result = std::format("{{ \"serial\": \"{}\", \"mac\": \"{}\" }}", serial_no_sep, mac_colon);
return CommandResult::getSuccessResult(result);
}
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry)
{
#if CONFIG_MONITORING_LED_CURRENT
auto mon = registry->resolve<MonitoringManager>(DependencyType::monitoring_manager);
if (!mon)
{
return CommandResult::getErrorResult("MonitoringManager unavailable");
}
float ma = mon->getCurrentMilliAmps();
auto result = std::format("{{ \"led_current_ma\": {:.3f} }}", static_cast<double>(ma));
return CommandResult::getSuccessResult(result);
#else
return CommandResult::getErrorResult("Monitoring disabled");
#endif
}

View File

@@ -22,4 +22,7 @@ CommandResult switchModeCommand(std::shared_ptr<DependencyRegistry> registry, st
CommandResult getDeviceModeCommand(std::shared_ptr<DependencyRegistry> registry);
CommandResult getSerialNumberCommand(std::shared_ptr<DependencyRegistry> registry);
CommandResult getSerialNumberCommand(std::shared_ptr<DependencyRegistry> registry);
// Monitoring
CommandResult getLEDCurrentCommand(std::shared_ptr<DependencyRegistry> registry);