particle-iot / particle-cli

Command Line Interface for Particle Cloud and devices
Apache License 2.0
212 stars 92 forks source link

Replace dfu-util with particle usb dfu #674

Closed keeramis closed 1 year ago

keeramis commented 1 year ago

Description

This PR removes the last uses of dfu-util to use particle usb dfu for improved compatibility.

Other improvements:

  1. Uses usbUtils to handle multiple devices connected simultaneously
  2. Refactors promise-based methods in the keys module to utilize the async/await syntax, improving code readability and maintainability.
  3. Removes the particle keys protocol commands

How to Test

This PR requires that the latest particle usb upload functionality exists which currently is in this PR. Checkout the particle-usb repo locally and link your locally checked out particle-cli to use locally checked out particle-usb

  1. Checkout this branch locally and follow the instructions in the README (run nvm use followed by npm install)

  2. Checkout this branch of particle-usb locally.

    1. Go to particle-usb root directory. Run npm link. Ensure it is linked as expected
    2. Go to particle-cli root directory. Run npm link particle-usb
    3. Verify from particle-cli/node_modules that the particle-usb points to your local repo
  3. Run any particle keys xxx commands and particle doctor command on your device(s) and verify that they are working as expected.

  4. For example, To run particle keys xxx, run npm start -- keys xxx from project's root directory

Bonus points if you are able to verify that the keys are generated as expected!

Related Issues / Discussions

Particle-USB PR that is needed for this PR to work: https://github.com/particle-iot/particle-usb/pull/91

Completeness

keeramis commented 1 year ago

It's worth noting an interesting observation related to 'particle keys.' We create a key of 121 bytes. However, when we save this key, we save 192 bytes. Will it be beneficial to consider optimizing this process to save only the original 121 bytes, or alternatively, to provide documentation explaining this behavior.