-
Notifications
You must be signed in to change notification settings - Fork 8.2k
usb: device_next: support BOS descriptor with vendor request code #76326
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
nashif
merged 4 commits into
zephyrproject-rtos:main
from
jfischer-no:pr-device_next-sample-webusb
Nov 19, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
152644c
samples: usb: add samples function to setup USB device only
jfischer-no b00b5ca
usb: device_next: support vendor request with recipient device
jfischer-no c9521e6
usb: device_next: support BOS descriptor with vendor request code
jfischer-no 210cda7
samples: usb: add new WebUSB sample
jfischer-no File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(webusb) | ||
|
|
||
| include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake) | ||
| FILE(GLOB app_sources src/*.c) | ||
| target_sources(app PRIVATE ${app_sources}) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Copyright (c) 2023 Nordic Semiconductor ASA | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| # Source common USB sample options used to initialize new experimental USB | ||
| # device stack. The scope of these options is limited to USB samples in project | ||
| # tree, you cannot use them in your own application. | ||
| source "samples/subsys/usb/common/Kconfig.sample_usbd" | ||
|
|
||
| source "Kconfig.zephyr" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| .. zephyr:code-sample:: webusb-next | ||
| :name: WebUSB-next | ||
| :relevant-api: usbd_api | ||
|
|
||
| Receive and echo data from a web page using WebUSB API. | ||
|
|
||
| Overview | ||
| ******** | ||
|
|
||
| This sample demonstrates how to use the Binary Device Object Store (BOS), | ||
| Microsoft OS 2.0 descriptors, and WebUSB descriptors to implement a WebUSB | ||
| sample application. The sample USB function receives the data and echoes back | ||
| to the WebUSB API based application running in the browser on your local host. | ||
| This sample can be found at :zephyr_file:`samples/subsys/usb/webusb-next` in the | ||
| Zephyr project tree. | ||
|
|
||
| Requirements | ||
| ************ | ||
|
|
||
| This project requires a USB device controller driver using the UDC API. | ||
| On your host computer, this project requires a web browser that supports the | ||
| WebUSB API, such as Chromium or a Chromium-based browser. | ||
|
|
||
| Building and Running | ||
| ******************** | ||
|
|
||
| Build and flash webusb sample with: | ||
|
|
||
| .. zephyr-app-commands:: | ||
| :zephyr-app: samples/subsys/usb/webusb-next | ||
| :board: <board to use> | ||
| :goals: flash | ||
| :compact: | ||
|
|
||
| Demonstration | ||
| ************* | ||
|
|
||
| The sample includes a simple WebUSB API application and can be found in the | ||
| sample directory: :zephyr_file:`samples/subsys/usb/webusb-next/index.html`. | ||
|
|
||
| There are two ways to access this sample page: | ||
|
|
||
| * Using browser go to :doc:`demo` | ||
|
|
||
| * Start a web server in the sample directory: | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| $ python -m http.server | ||
|
|
||
| Then follow these steps: | ||
|
|
||
| #. Connect the board to your host. | ||
|
|
||
| #. Once the device has booted, you may see a notification from the browser: "Go | ||
| to localhost to connect". Click on the notification to open the demo page. If | ||
| there is no notification from the browser, open the URL http://localhost:8001/ | ||
| in your browser. | ||
|
|
||
| #. Click on the :guilabel:`Connect` button to connect to the device. | ||
|
|
||
| #. Send some text to the device by clicking on the :guilabel:`Send` button. | ||
| The demo application will receive the same text from the device and display | ||
| it in the text area. | ||
|
|
||
| References | ||
| *********** | ||
|
|
||
| WebUSB API Specification: | ||
| https://wicg.github.io/webusb/ | ||
|
|
||
| Chrome for Developers, "Access USB Devices on the Web": | ||
| https://developer.chrome.com/docs/capabilities/usb |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| :orphan: | ||
|
|
||
| WebUSB HTML Demo App | ||
| ==================== | ||
|
|
||
| .. raw:: html | ||
| :file: index.html |
Oops, something went wrong.
Oops, something went wrong.
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.
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 would prefer some prefix on the node, e.g.
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.
Then the user does not know the real structure name. This makes sense for more abstract macros, but not here.