samples/subsys/usb/webusb/README.html · samples/subsys/usb/webusb/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · WebUSB

WebUSB

Secure origin, browser permission과 localhost demo 흐름을 연결합니다.

Official pathsamples/subsys/usb/webusb/README.html
Source filesamples/subsys/usb/webusb/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

WebUSB API, Chrome notification 제한과 Connect·Send 시험을 설명합니다.

Browser

Google Chrome

Origin

HTTPS · localhost

Behavior

Browser-device echo

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 B4F0A9CBA618C7822246059B1602AFDA602348DA80B102242E7FC1E6126CFD26
.. zephyr:code-sample:: webusb
   :name: WebUSB
   :relevant-api: _usb_device_core_api

   Receive and echo data from a web page using WebUSB API.

For a deeper dive into the WebUSB, refer to
https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web

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

Overview
********

This simple echo application demonstrates the WebUSB sample application.
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.
This sample can be found under :zephyr_file:`samples/subsys/usb/webusb` in the
Zephyr project tree.

Requirements
************

This project requires an USB device driver, which is available for multiple
boards supported in Zephyr.

Building and Running
********************

Build and flash webusb sample with:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/usb/webusb
   :board: <board to use>
   :goals: flash
   :compact:

Testing with the latest Google Chrome on host
*********************************************

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 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:

#. Run the latest Google Chrome on host.

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

   The sample can be found in the webusb sample directory:
   :zephyr_file:`samples/subsys/usb/webusb/index.html`.

   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.

   There are two ways to access this sample page:

   * Using Chrome browser go to :doc:`demo`

   * Host the demo page locally: Start a web server
     in the webusb sample directory.

     .. code-block:: console

        $ python -m http.server

     Using Chrome browser open url http://localhost:8001/

#. Connect the board to your host.

#. 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.
   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 the :guilabel:`Connect` button to connect to the device.

#. 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.

Part 3

한국어 전문 번역

WebUSB에 대한 자세한 배경은 Google의 WebUSB 소개를, API 정의는 WebUSB API Specification을 참고합니다.

개요

이 간단한 echo application은 WebUSB sample 동작을 보여 줍니다. Device가 data를 받아 host browser에서 실행 중인 WebUSB 기반 web application으로 그대로 돌려보냅니다.

Testing 전용 sample이므로 실제 use case에는 WebUSB API를 바탕으로 별도 application을 구현해야 합니다. Source는 samples/subsys/usb/webusb에 있습니다.

요구 사항

USB device driver가 필요하며 Zephyr가 지원하는 여러 board에서 사용할 수 있습니다.

빌드 및 실행

다음 command에서 사용할 board를 지정해 WebUSB sample을 build하고 flash합니다.

west build -b <board to use> samples/subsys/usb/webusb
west flash

Host의 최신 Google Chrome으로 테스트

최신 Google Chrome, USB device에 연결하는 WebUSB API 기반 web page, 그리고 선택적으로 page를 제공할 localhost HTTP server가 필요합니다.

WebUSB는 secure origin에서만 사용할 수 있는 강력한 Web 기능입니다. 따라서 device에 연결하는 web page 또는 site는 secure connection인 HTTPS로 제공해야 합니다. Localhost는 개발 시험용 접근 경로로 사용합니다.

Host에서는 다음 순서로 demo를 실행합니다.

  1. Host에서 최신 Google Chrome을 실행합니다.
  2. WebUSB API를 사용하는 web application을 구현해 localhost에서 실행합니다. Sample page는 samples/subsys/usb/webusb/index.html에 있으며 WebUSB interface 생성·사용과 browser-device 통신을 보여 줍니다.

    Chrome에서 WebUSB HTML Demo App을 직접 열거나 webusb sample directory에서 local web server를 시작할 수 있습니다.

    $ python -m http.server

    그런 다음 Chrome에서 http://localhost:8001/을 엽니다.

  3. Board를 host에 연결합니다.
  4. Device가 boot되면 Chrome의 “Go to localhost to connect.” notification을 눌러 demo page를 엽니다. 현재 Windows의 Chrome에서는 WebUSB landing page notification이 비활성화되어 있으므로 implementation status를 확인합니다.
  5. Connect button을 눌러 device에 연결합니다.
  6. Text를 입력하고 Send button을 누릅니다. Demo application은 device가 echo한 같은 text를 받아 text area에 표시합니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.