You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: docs/webusb.md
+31-20Lines changed: 31 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,10 @@ Zephyr.js API for WebUSB
2
2
========================
3
3
4
4
*[Introduction](#introduction)
5
-
*[Class: WebUSB](#class-webusb)
6
-
*[API Documentation](#api-documentation)
5
+
*[Class: WebUSB](#webusb-api)
6
+
*[webusb.setURL(url)](#webusbseturlurl)
7
+
*[webusb.write(buffer)](#webusbwritebuffer)
8
+
*[Event: 'read'](#event-read)
7
9
*[Sample Apps](#sample-apps)
8
10
9
11
Introduction
@@ -19,31 +21,40 @@ When you connect your device to a Linux PC or Mac with Chrome >= 60 running, it
19
21
will give a notification that the device would like you to visit the URL you've
20
22
set. (Windows currently prevents this from working, I believe.)
21
23
22
-
API Documentation
23
-
-----------------
24
+
Web IDL
25
+
-------
26
+
This IDL provides an overview of the interface; see below for documentation of
27
+
specific API functions. We also have a short document explaining [ZJS WebIDL conventions](Notes_on_WebIDL.md).
28
+
<details>
29
+
<summary> Click to show/hide WebIDL</summary>
30
+
<pre>
31
+
// require returns a webusb object
32
+
// var webusb = require('webusb');<p>[ReturnFromRequire, ExternalInterface=(Buffer)]
33
+
interface webusb {
34
+
void setURL(string url);
35
+
void write(Buffer buf);
36
+
};
37
+
</pre>
38
+
</details>
39
+
40
+
webusb API
41
+
----------
42
+
43
+
### webusb.setURL(url)
44
+
*`url`*string* Should begin with "https://" for Chrome to accept it
45
+
and display a notification. Other URLs are valid in terms of the protocol but
46
+
will have no user-visible effect in Chrome.
47
+
48
+
### webusb.write(buffer)
49
+
*`write`*Buffer* Writes the data in `buffer` to the WebUSB TX line. By default, at most 511 bytes can be pending at one time, so that is the maximum write size, assuming all previous data has already been flushed out. An error will be thrown on overflow.
50
+
24
51
### Event: 'read'
25
52
26
53
*`Buffer``data`
27
54
28
55
Emitted when data is received on the WebUSB RX line. The `data` parameter is a
29
56
`Buffer` with the received data.
30
57
31
-
### WebUSB.setURL
32
-
33
-
`void setURL(string url);`
34
-
35
-
The `url` string should begin with "https://" in order for Chrome to accept it
36
-
and display a notification. Other URLs are valid in terms of the protocol but
37
-
will have no user-visible effect in Chrome.
38
-
39
-
### WebUSB.write
40
-
41
-
`void write(Buffer buffer);`
42
-
43
-
Writes the data in `buffer` to the WebUSB TX line. By default at most 511 bytes
44
-
can be pending at one time, so that is the maximum write size, assuming all
45
-
previous data had already been flushed out. An error will be thrown on overflow.
0 commit comments