From 03b88247357727848fd19cd7267614921afd9d25 Mon Sep 17 00:00:00 2001 From: Matt Reynolds Date: Thu, 21 Dec 2023 10:21:56 -0800 Subject: [PATCH] Specify connect/disconnect for Bluetooth serial ports (#197) * Specify connect/disconnect for Bluetooth serial ports * Fix definition for "logically connected" and define "available" --- index.html | 62 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index cf9e727..eafec2a 100644 --- a/index.html +++ b/index.html @@ -173,7 +173,7 @@

  1. Let |allPorts:list<SerialPort>| be an empty [=list=].
  2. -
  3. [=list/For each=] paired Bluetooth device: +
  4. [=list/For each=] Bluetooth device registered with the system:
    1. [=list/For each=] {{BluetoothServiceUUID}} |uuid:BluetoothServiceUUID| supported by the device: @@ -201,7 +201,7 @@

  5. -
  6. [=list/For each=] available non-Bluetooth serial port: +
  7. [=list/For each=] [=available=] non-Bluetooth serial port:
    1. Let |port:SerialPort| be a {{SerialPort}} representing the port. @@ -232,6 +232,12 @@

    2. Return |promise|.
    +

    + A serial port is available 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. +

    SerialPortRequestOptions dictionary @@ -390,8 +396,8 @@

  8. Run the following steps [=in parallel=]:
      -
    1. Let |availablePorts| be the sequence of available serial - ports on the system which the user has allowed the site to access +
    2. 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()}}.
    3. Let |ports| be the sequence of the {{SerialPort}}s @@ -429,6 +435,7 @@

      interface SerialPort : EventTarget { attribute EventHandler onconnect; attribute EventHandler ondisconnect; + readonly attribute boolean connected; readonly attribute ReadableStream readable; readonly attribute WritableStream writable; @@ -488,6 +495,17 @@

      The amount of data to buffer for transmit and receive + + + [[\connected]] + + + `false` + + + A flag indicating the logical connection state of serial port + + [[\readable]] @@ -551,17 +569,25 @@

      {{SerialPort/onconnect}} is an [=event handler IDL attribute=] for the {{connect}} event type.

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

      1. Let |port:SerialPort| be a {{SerialPort}} representing the port.
      2. +
      3. Set |port|.{{SerialPort/[[connected]]}} to `true`. +
      4. [=Fire an event=] named {{connect}} at |port| with its {{Event/bubbles}} attribute initialized to `true`.
      +

      + A serial port is logically connected 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). +

      @@ -569,13 +595,15 @@

      {{SerialPort/ondisconnect}} is an [=event handler IDL attribute=] for the {{disconnect}} event type.

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

      1. Let |port:SerialPort| be a {{SerialPort}} representing the port.
      2. +
      3. Set |port|.{{SerialPort/[[connected]]}} to `false`. +
      4. [=Fire an event=] named {{disconnect}} at |port| with its {{Event/bubbles}} attribute initialized to `true`.
      5. @@ -843,6 +871,18 @@
      +
      +

      + connected attribute +

      +

      + The {{SerialPort/connected}} getter steps are: +

      +
        +
      1. Return [=this=].{{SerialPort/[[connected]]}}. +
      2. +
      +

      readable attribute @@ -1743,7 +1783,7 @@

      1. Set [=this=].{{SerialPort/[[state]]}} to `"forgetting"`.
      2. -
      3. Remove [=this=] from the sequence of available serial ports +
      4. 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()}}.