-
-
Notifications
You must be signed in to change notification settings - Fork 80
USB Updates #353
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
Merged
Merged
USB Updates #353
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The main change here is switching from using BOS descriptors to using interface/class-specific descriptors for the equivalent of reading BLE GATT characteristics over USB. BOS are really meant for operating system capabilities, not application-level protocols. Instead, we now have interface/class-specific responses to control requests that allow reading each characteristic individually. Since the wValue parameter is 16 bits, it is natural to use the BLE 16-bit UUIDs for this purpose. To avoid potential clashes, we also use bRequest to sort these by groups. For now, there is one for standard BLE 16-bit UUIDs and one for Pybricks-defined 16-bit UUIDs. Now, all remaining BOS descriptor info is known at compile time, so we no longer need to fill it in at runtime. There are also some fixes to make the BOS descriptors work correctly with Chromium-based browsers. Chromium seems to be a bugging and expects the WebUSB descriptor to be the first device capability and the Microsoft OS 2.0 descriptor to be the last device capability. Otherwise, it doesn't seem to parse them correctly. Also, we had the bcdUSB incorrectly set to 2.0.1 instead of 2.1.0.
Replace use of MIN macro with explicit comparisons. We are removing the defines for these, so we can't depend on them anymore.
Drop the MIN/MAX macros from the contiki includes. These can conflict with other definitions, and are not used in the code.
NxOS had it's own USB configuration. Replace it with the Pybricks USB configuration so that we can use the Pybricks USB protocol. This also fixes not setting bit 7 of bmAttributes.
We have adapted the NxOS USB driver for Pybricks, so now we can move it to the common pbio/drv/usb directory. While moving, the code style is automatically formatted and pbio naming conventions are applied.
Member
|
Amazing, great work! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on USB, I finally figured out some of the things that were making Chromium not happy about the WebUSB BOS descriptor that we couldn't figure out before.
In addition to that, we were using BOS descriptors for Pybricks Profile characteristics, but that wasn't really a good fit. So I changed how we handle those. Now, characteristics can be read individually by requesting class data from the Pybricks interface. This allows them to be read one at a time and would allow for values to change dynamically at runtime if needed in the future.
Also, I've reworked the NxOS USB descriptors to the Pybricks ones so that it matches what was done for SPIKE hubs. This driver then gets moved to pbiod/drv/usb. But Pybricks interface endpoint reads and writes aren't handled yet, so no download and run on NXT yet.
I didn't touch the EV3 stuff since that is a work in progress in #340. After that is done, we should be able to pull out a common pbsys_usb and descriptor definitions that can be shared by all 3 drivers.