Skip to content
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

Put a Protected Device automatically in Service Mode to run CLI commands #751

Merged

Conversation

keeramis
Copy link
Contributor

@keeramis keeramis commented Jul 13, 2024

This PR adds a helper module device-protection-helper.js that can be used by multiple modules and prevent circular dependency issues. It also adds a new method that checks if a device is ready for use (ie rebooted after a certain reset operation was done)

How to Test

See this test plan

Related Issues / Discussions

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA
  • Problem and solution clearly stated
  • Tests have been provided
  • Docs have been updated
  • CI is passing

@keeramis keeramis changed the title Put a Protected Device automatically in Service Mode to run any CLI commands Put a Protected Device automatically in Service Mode to run CLI commands Jul 13, 2024
@keeramis keeramis force-pushed the feature/sc-129067/automatic-service-mode branch from b1bf844 to f029ce6 Compare July 22, 2024 19:54
if (usbDevice && usbDevice.isOpen){
await usbDevice.close();
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (usbDevice.isInDfuMode && semver.lt(firmwareVersion, '6.1.3')) {
								outputMsg.push(`Your device may be in Service Mode. Re-enable Device Protection by running ${chalk.yellow('particle device-protection enable')}`);

this will cause particle usb dfu to have this error as well. I will fix this in usb module or here if you prefer

@keeramis keeramis marked this pull request as ready for review July 23, 2024 09:35
@monkbroc
Copy link
Member

Can you change the base branch to a long running branch like feature/automatic-service-mode

@keeramis keeramis requested a review from monkbroc July 24, 2024 06:44
Copy link
Member

@monkbroc monkbroc left a comment

Choose a reason for hiding this comment

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

Looks good. Ensure that the target branch is a long-running branch before merging.

* Waits for the device to reboot to reboot by checking if the device is ready to accept control requests.
* It waits for a maximum of 60 seconds with a 1-second interval.
*/
async function waitForDeviceToReboot(deviceId) {
Copy link
Member

Choose a reason for hiding this comment

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

Where is this function used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was useful when I was working with dfu devices and flashing modules. This is again, used for an edge case on 6.1.1. I will remove this for now and insert it later if needed.

@keeramis keeramis force-pushed the feature/sc-129067/automatic-service-mode branch from 25af477 to 159325a Compare July 24, 2024 16:26
@keeramis keeramis changed the base branch from master to feature/automatic-service-mode July 24, 2024 16:28
@keeramis keeramis merged commit bbcbe68 into feature/automatic-service-mode Jul 24, 2024
5 checks passed
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.

2 participants