diff --git a/doc/conf.py b/doc/conf.py index 05e4eb3d80359d..592e3d19defe86 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -284,6 +284,7 @@ (ZEPHYR_BASE / "doc", "[!_]*"), (ZEPHYR_BASE, "boards/**/*.rst"), (ZEPHYR_BASE, "boards/**/doc"), + (ZEPHYR_BASE, "samples/**/*.html"), (ZEPHYR_BASE, "samples/**/*.rst"), (ZEPHYR_BASE, "samples/**/doc"), (ZEPHYR_BASE, "snippets/**/*.rst"), diff --git a/samples/subsys/usb/usb.rst b/samples/subsys/usb/usb.rst index 90b1c783b4cee4..5da80b0e219a93 100644 --- a/samples/subsys/usb/usb.rst +++ b/samples/subsys/usb/usb.rst @@ -7,4 +7,4 @@ USB device support samples :maxdepth: 1 :glob: - **/* + **/README diff --git a/samples/subsys/usb/webusb/README.rst b/samples/subsys/usb/webusb/README.rst index f5d5c17e1d77fa..78ed9a456cdb92 100644 --- a/samples/subsys/usb/webusb/README.rst +++ b/samples/subsys/usb/webusb/README.rst @@ -13,7 +13,7 @@ Sample Overview *************** This simple echo application demonstrates the WebUSB sample application. -This application receives the data and echoed back to the WebUSB +This application receives the data and echoes back to the WebUSB based web application (web page) running in the browser at host. This application is intended for testing purposes only. For running real usecase, implement applications based on the WebUSB API. @@ -37,15 +37,15 @@ Build and flash webusb sample with: :goals: flash :compact: -Testing with latest Google Chrome on host -***************************************** +Testing with the latest Google Chrome on host +********************************************* -This sample application requires latest Google Chrome, a web page +This sample application requires the latest Google Chrome, a web page based on WebUSB API to connect to the USB device and optionally http server running on localhost to serve the web page. WebUSB is a powerful new feature added to the Web and it is available -only to secure origins. This means the web page/site that used to +only to secure origins. This means the web page/site that is used to connect to the device must be served over a secure connection (HTTPS). Follow these steps to run the demo on your host system: @@ -55,20 +55,25 @@ Follow these steps to run the demo on your host system: #. Implement a web app (web page) using WebUSB API and run it on localhost. - See the sample at https://github.com/finikorg/webusb-sample + The sample can be found in the webusb sample directory: + :zephyr_file:`samples/subsys/usb/webusb/index.html`. - This sample web page demonstrate how to create and use a WebUSB + This sample web page demonstrates how to create and use a WebUSB interface, as well as demonstrate the communication between browser and WebUSB enabled device. - #. To access JS app go to https://finikorg.github.io/webusb-sample/ + There are two ways to access this sample page: - #. To host the demo page locally: Clone the repo and start a web server - in the appropriate directory. + * Using Chrome browser go to :doc:`demo` - .. code-block:: console + * Host the demo page locally: Start a web server + in the webusb sample directory. - $ python -m http.server + .. code-block:: console + + $ python -m http.server + + Using Chrome browser open url http://localhost:8001/ #. Connect the board to your host. @@ -78,7 +83,8 @@ Follow these steps to run the demo on your host system: Note that at the moment WebUSB landing page notification is disabled in Chrome on Windows. See https://github.com/WICG/webusb#implementation-status -#. Click on Connect button to connect to the device. +#. Click on the :guilabel:`Connect` button to connect to the device. -#. Send some text to the device by clicking on the Send button. The demo app - will receive the same text from the device and display it in the textarea. +#. Send some text to the device by clicking on the :guilabel:`Send` button. + The demo app will receive the same text from the device and display it in + the text area. diff --git a/samples/subsys/usb/webusb/demo.rst b/samples/subsys/usb/webusb/demo.rst new file mode 100644 index 00000000000000..6925a80258093f --- /dev/null +++ b/samples/subsys/usb/webusb/demo.rst @@ -0,0 +1,7 @@ +:orphan: + +WebUSB HTML Demo App +==================== + +.. raw:: html + :file: index.html diff --git a/samples/subsys/usb/webusb/index.html b/samples/subsys/usb/webusb/index.html new file mode 100644 index 00000000000000..b6cfc96d447ebc --- /dev/null +++ b/samples/subsys/usb/webusb/index.html @@ -0,0 +1,126 @@ + + + + WebUSB Serial Sample Application + + + + + +


+ +
+

+
+ + +