zephyr/samples/subsys/usb/webusb
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
..
src samples: webusb: rework usb descriptor 2017-11-07 15:31:02 -05:00
CMakeLists.txt Introduce cmake-based rewrite of KBuild 2017-11-08 20:00:22 -05:00
Makefile samples: move usb samples subsystem folder 2017-03-29 19:35:34 +00:00
prj.conf arch: intel_quark: use DW device driver when USB is selected 2017-06-28 15:14:15 -04:00
README.txt doc: fix wiki board references in non .rst files 2017-07-11 12:45:35 -05:00
sample.yaml usb: Remove default Vendor and Product ID 2017-10-19 09:30:58 -04:00

Title: WebUSB Enabled Custom Driver and A Sample Application

This project includes:

1. WebUSB Enabled Custom Driver:
--------------------------------

This enables WebUSB support to the device via the platform capability
descriptors.

For a deeper dive into the WebUSB, refer to
https://github.com/WICG/webusb/blob/gh-pages/explainer.md

WebUSB API Specification:
https://wicg.github.io/webusb/

2. Sample Application:
----------------------

A simple echo application to demonstrate the WebUSB enabled custom
class driver.

This application receives the data and echoed 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.

Building and flashing:
----------------------

Refer to
https://www.zephyrproject.org/doc/boards/x86/arduino_101/doc/board.html
for details on building and flashing the image into an Arduino 101.

Testing with latest Google Chrome on host
-----------------------------------------

This sample application requires latest Google Chrome, a web page
based on WebUSB API to connect to the USB device and 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
connect to the device must be served over a secure connection (HTTPS).

For testing and development purposes, there is a flag in Chrome
(--disable-webusb-security) that disables this CORS-like checks for
origins and allow any origin to ask the user for permission to connect
to a device. So, we use this flag to interact with the device through
http://localhost by starting up http server on host and serving the
web page.

Follow below steps to run the demo on host:

1. Run the latest dev-channel release of Google Chrome on host.
   https://www.google.com/chrome/browser/desktop/index.html?extra=devchannel

2. Enable "Experimental Web Platform Features" flag in
   chrome://flags/#enable-experimental-web-platform-features.

3. Run chrome with the --disable-webusb-security switch to disable
   WebUSB's CORS-like checks for origin device communication.

4. Implement a web app (web page) using WebUSB API and run
   it on localhost.

   See the sample at https://github.com/nagineni/webusb-serial

   This sample web page demonstrate how to create and use a WebUSB
   interface, as well as demonstrate the communication between browser
   and WebUSB enabled device.

   To host the demo page locally: Clone the repo and start a web server
   in the appropriate directory.
   $ python -m SimpleHTTPServer

5. Connect the board to a host.

6. Once the device is booted, you should see a notification from
   Chrome: "Go to localhost to connect.". Click on the notification
   to open demo page.

7. Click on Connect button to connect to the device.

8. Send some text to the device by clicking on Send button. The demo app
   will receive the same text from the device and display it in the textarea.