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

Open Native USB Feature #75

Merged
merged 9 commits into from
Oct 26, 2022
Merged

Open Native USB Feature #75

merged 9 commits into from
Oct 26, 2022

Conversation

rickkas7
Copy link
Contributor

The docs currently use a branch of particle-usb with a few custom modifications. The plan is to roll the changes back into the mainline, fixing the API, adding tests, etc.

The new changes

There are two changes:

  • In enterDfuMode, add a noReconnectWait option. This is desirable in a WebUSB environment because if the device was first use when already in DFU mode, when exiting DFU mode, the browser may request authorization to the non-DFU interface, since the browser must separately authorize each. This leads to an awkward user experience when the user doesn’t need to manipulate the device.
  • Added a new method openNativeUsbDevice, which works like openByDeviceID, except it takes a native WebUSB device object. This is useful when you want to customize the device selection for WebUSB, and other cases where you already have the native WebUSB object but want to wrap it in particle-usb.

Tests

I also added test cases for the new code. There are unit tests in device-base-test.js that are run automatically during the test:ci phase. There is also an e2e test in browser.e2e.js that is not automatically run because it requires interacting with WebUSB authorization in a browser.

Copy link
Contributor

@busticated busticated left a comment

Choose a reason for hiding this comment

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

awesome thanks rick! couple of notes - let me know if you want to pair on it 🙏 👍

test/e2e/browser.e2e.js Outdated Show resolved Hide resolved
test/e2e/browser.e2e.js Outdated Show resolved Hide resolved
test/integration/device-base.js Outdated Show resolved Hide resolved
test/integration/device-base.js Show resolved Hide resolved
Copy link
Contributor

@hugomontero hugomontero left a comment

Choose a reason for hiding this comment

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

LGTM! 👍
Just one little problem when trying the e2e with 2 devices connected at the same time.

src/device-base.js Outdated Show resolved Hide resolved
test/integration/device-base.js Outdated Show resolved Hide resolved
Copy link
Contributor

@busticated busticated left a comment

Choose a reason for hiding this comment

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

nice - thanks @rickkas7 🙏 🙌 👍

@rickkas7 rickkas7 merged commit cd15945 into main Oct 26, 2022
@rickkas7 rickkas7 deleted the feature/open-native-usb branch October 26, 2022 18:30
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