README.rst
1.. zephyr:code-sample:: webusb
2 :name: WebUSB
3 :relevant-api: usbd_api
4
5 Receive and echo data from a web page using WebUSB API.
6
7Overview
8********
9
10This sample demonstrates how to use the Binary Device Object Store (BOS),
11Microsoft OS 2.0 descriptors, and WebUSB descriptors to implement a WebUSB
12sample application. The sample USB function receives the data and echoes back
13to the WebUSB API based application running in the browser on your local host.
14
15Requirements
16************
17
18This project requires a USB device controller driver using the UDC API.
19On your host computer, this project requires a web browser that supports the
20WebUSB API, such as Chromium or a Chromium-based browser.
21
22Building and Running
23********************
24
25Build and flash webusb sample with:
26
27.. zephyr-app-commands::
28 :zephyr-app: samples/subsys/usb/webusb
29 :board: <board to use>
30 :goals: flash
31 :compact:
32
33Demonstration
34*************
35
36The sample includes a simple WebUSB API application and can be found in the
37sample directory: :zephyr_file:`samples/subsys/usb/webusb/index.html`.
38
39There are two ways to access this sample page:
40
41* Using browser go to :doc:`demo`
42
43* Start a web server in the sample directory:
44
45 .. code-block:: console
46
47 $ python -m http.server
48
49Then follow these steps:
50
51#. Connect the board to your host.
52
53#. Once the device has booted, you may see a notification from the browser: "Go
54 to localhost to connect". Click on the notification to open the demo page. If
55 there is no notification from the browser, open the URL http://localhost:8001/
56 in your browser.
57
58#. Click on the :guilabel:`Connect` button to connect to the device.
59
60#. Send some text to the device by clicking on the :guilabel:`Send` button.
61 The demo application will receive the same text from the device and display
62 it in the text area.
63
64References
65***********
66
67WebUSB API Specification:
68https://wicg.github.io/webusb/
69
70Chrome for Developers, "Access USB Devices on the Web":
71https://developer.chrome.com/docs/capabilities/usb
72