Skip to content

Conversation

@bwmp
Copy link
Contributor

@bwmp bwmp commented Dec 18, 2025

actual functioning start_streaming command

zdzislaw-goik

This comment was marked as resolved.

Comment on lines +149 to +186
if (!json.contains("mode") || !json["mode"].is_string())
{
return CommandResult::getErrorResult("Invalid payload - missing mode");
}

auto modeStr = json["mode"].get<std::string>();
StreamingMode newMode;

ESP_LOGI("[DEVICE_COMMANDS]", "Switch mode and restart command received with mode: %s", modeStr.c_str());

if (modeStr == "uvc")
{
newMode = StreamingMode::UVC;
}
else if (modeStr == "wifi")
{
newMode = StreamingMode::WIFI;
}
else if (modeStr == "setup" || modeStr == "auto")
{
newMode = StreamingMode::SETUP;
}
else
{
return CommandResult::getErrorResult("Invalid mode - use 'uvc', 'wifi', or 'auto'");
}

const auto projectConfig = registry->resolve<ProjectConfig>(DependencyType::project_config);
StreamingMode currentMode = projectConfig->getDeviceMode();

if (currentMode == newMode)
{
ESP_LOGI("[DEVICE_COMMANDS]", "Device already in mode: %d, no restart needed", (int)currentMode);
return CommandResult::getSuccessResult("Device already in requested mode");
}

ESP_LOGI("[DEVICE_COMMANDS]", "Setting device mode to: %d and scheduling restart", (int)newMode);
projectConfig->setDeviceMode(newMode);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the idea behind this command and why it's needed, I completely agree with that. But do we have to duplicate the already existing switchModeCommand()? Is there something preventing us from just calling that command in here and then scheduling the restart right away, while returning what switchModeCommand returned?

source:
type: idf
version: 5.4.2
version: 5.5.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love me the update, thanks for upping the version. I'll have to copy the sdkconfig into the sdkconfig.base_defaults in boards/ later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants