Skip to content

Commit

Permalink
Specify connect/disconnect for Bluetooth serial ports (#197)
Browse files Browse the repository at this point in the history
* Specify connect/disconnect for Bluetooth serial ports

* Fix definition for "logically connected" and define "available"
  • Loading branch information
nondebug authored Dec 21, 2023
1 parent 343fe09 commit 03b8824
Showing 1 changed file with 51 additions and 11 deletions.
62 changes: 51 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h3>
<ol>
<li>Let |allPorts:list&lt;SerialPort&gt;| be an empty [=list=].
</li>
<li>[=list/For each=] paired Bluetooth device:
<li>[=list/For each=] Bluetooth device registered with the system:
<ol>
<li>[=list/For each=] {{BluetoothServiceUUID}}
|uuid:BluetoothServiceUUID| supported by the device:
Expand Down Expand Up @@ -201,7 +201,7 @@ <h3>
</li>
</ol>
</li>
<li>[=list/For each=] available non-Bluetooth serial port:
<li>[=list/For each=] [=available=] non-Bluetooth serial port:
<ol>
<li>Let |port:SerialPort| be a {{SerialPort}} representing
the port.
Expand Down Expand Up @@ -232,6 +232,12 @@ <h3>
<li>Return |promise|.
</li>
</ol>
<p>
A serial port is <dfn>available</dfn> if it is a wired serial port and
the port is physically connected to the system, or if it is a wireless
serial port and the wireless device hosting the port is registered
with the system.
</p>
<section data-dfn-for="SerialPortRequestOptions">
<h4>
<dfn>SerialPortRequestOptions</dfn> dictionary
Expand Down Expand Up @@ -390,8 +396,8 @@ <h3>
</li>
<li>Run the following steps [=in parallel=]:
<ol>
<li>Let |availablePorts| be the sequence of available serial
ports on the system which the user has allowed the site to access
<li>Let |availablePorts| be the sequence of [=available=] serial
ports which the user has allowed the site to access
as the result of a previous call to {{Serial/requestPort()}}.
</li>
<li>Let |ports| be the sequence of the {{SerialPort}}s
Expand Down Expand Up @@ -429,6 +435,7 @@ <h2>
interface SerialPort : EventTarget {
attribute EventHandler onconnect;
attribute EventHandler ondisconnect;
readonly attribute boolean connected;
readonly attribute ReadableStream readable;
readonly attribute WritableStream writable;

Expand Down Expand Up @@ -488,6 +495,17 @@ <h2>
The amount of data to buffer for transmit and receive
</td>
</tr>
<tr>
<td>
<dfn>[[\connected]]</dfn>
</td>
<td>
`false`
</td>
<td>
A flag indicating the logical connection state of serial port
</td>
</tr>
<tr>
<td>
<dfn>[[\readable]]</dfn>
Expand Down Expand Up @@ -551,31 +569,41 @@ <h3>
</h3>{{SerialPort/onconnect}} is an [=event handler IDL attribute=] for
the {{connect}} event type.
<p>
When a serial port becomes available on the system that the user has
allowed the site to access as the result of a previous call to
{{Serial/requestPort()}}, run the following steps:
When a serial port that the user has allowed the site to access as the
result of a previous call to {{Serial/requestPort()}} becomes
[=logically connected=], run the following steps:
</p>
<ol>
<li>Let |port:SerialPort| be a {{SerialPort}} representing the port.
</li>
<li>Set |port|.{{SerialPort/[[connected]]}} to `true`.
</li>
<li>[=Fire an event=] named {{connect}} at |port| with its
{{Event/bubbles}} attribute initialized to `true`.
</li>
</ol>
<p>
A serial port is <dfn>logically connected</dfn> if it is a wired
serial port and the port is physically connected to the system, or if
it is a wireless serial port and the system has active connections to
the wireless device (e.g. an open Bluetooth L2CAP channel).
</p>
</section>
<section>
<h3>
<dfn>ondisconnect</dfn> attribute
</h3>{{SerialPort/ondisconnect}} is an [=event handler IDL attribute=]
for the {{disconnect}} event type.
<p>
When a serial port becomes unavailable on the system that the user
has allowed the site to access as the result of a previous call to
{{Serial/requestPort()}}, run the following steps:
When a serial port that the user has allowed the site to access as the
result of a previous call to {{Serial/requestPort()}} is no longer
[=logically connected=], run the following steps:
</p>
<ol>
<li>Let |port:SerialPort| be a {{SerialPort}} representing the port.
</li>
<li>Set |port|.{{SerialPort/[[connected]]}} to `false`.
</li>
<li>[=Fire an event=] named {{disconnect}} at |port| with its
{{Event/bubbles}} attribute initialized to `true`.
</li>
Expand Down Expand Up @@ -843,6 +871,18 @@ <h5>
</section>
</section>
</section>
<section>
<h2>
<dfn>connected</dfn> attribute
</h2>
<p>
The {{SerialPort/connected}} getter steps are:
</p>
<ol>
<li>Return [=this=].{{SerialPort/[[connected]]}}.
</li>
</ol>
</section>
<section>
<h2>
<dfn>readable</dfn> attribute
Expand Down Expand Up @@ -1743,7 +1783,7 @@ <h3>
<ol>
<li>Set [=this=].{{SerialPort/[[state]]}} to `"forgetting"`.
</li>
<li>Remove [=this=] from the sequence of available serial ports
<li>Remove [=this=] from the sequence of serial ports
on the system which the user has allowed the site to access as
the result of a previous call to {{Serial/requestPort()}}.
</li>
Expand Down

0 comments on commit 03b8824

Please sign in to comment.