-
Notifications
You must be signed in to change notification settings - Fork 13
Add switch_mode_and_restart command to CommandManager for manufacturing #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
actual functioning start_streaming command
| 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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
actual functioning start_streaming command