From 3d86075e3c5579943d6afb8f3a339742f07383f6 Mon Sep 17 00:00:00 2001 From: Chengwei Hsieh Date: Thu, 1 May 2025 15:03:34 -0700 Subject: [PATCH 1/4] Add WebDriver Bidi commands Add the following WebDriver Bidi commands and events for Web Bluetooth automation. - bluetooth.SimulateService - bluetooth.SimulateCharacteristic - bluetooth.simulateCharacteristicResponse - bluetooth.SimulateDescriptor - bluetooth.simulateDescriptorResponse - bluetooth.CharacteristicEventGenerated - bluetooth.DescriptorEventGenerated The detail algorithm for each of the those will be completed in future PRs. --- index.bs | 335 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 332 insertions(+), 3 deletions(-) diff --git a/index.bs b/index.bs index 28bce08..57f25ac 100644 --- a/index.bs +++ b/index.bs @@ -5018,8 +5018,18 @@ referenced. ## Definitions ## {#bluetooth-bidi-definitions}
-bluetooth.BluetoothServiceUuid = text;
+bluetooth.BluetoothUuid = text;
 bluetooth.BluetoothManufacturerData = { key: uint, data: tstr };
+bluetooth.CharacteristicProperties = {
+  ? broadcast: bool,
+  ? read: bool,
+  ? writeWithoutResponse: bool,
+  ? write: bool,
+  ? notify: bool,
+  ? indicate: bool,
+  ? authenticatedSignedWrites: bool,
+  ? extendedProperties: bool
+}
 
@@ -5119,7 +5129,7 @@ To serialize prompt devices given [=device prompt=] |prompt|: bluetooth.ScanRecord = { ? name: text, - ? uuids: [ * bluetooth.BluetoothServiceUuid ], + ? uuids: [ * bluetooth.BluetoothUuid ], ? appearance: number, ? manufacturerData: [ * bluetooth.BluetoothManufacturerData ], } @@ -5166,6 +5176,11 @@ BluetoothCommand = ( bluetooth.SimulateAdvertisement // bluetooth.SimulateGattConnectionResponse // bluetooth.SimulateGattDisconnection // + bluetooth.SimulateService // + bluetooth.SimulateCharacteristic // + bluetooth.simulateCharacteristicResponse // + bluetooth.SimulateDescriptor // + bluetooth.simulateDescriptorResponse // ) @@ -5344,7 +5359,7 @@ bluetooth.SimulatePreconnectedPeripheralParameters = { address: text, name: text, manufacturerData: [ * bluetooth.BluetoothManufacturerData ], - knownServiceUuids: [ * bluetooth.BluetoothServiceUuid ] + knownServiceUuids: [ * bluetooth.BluetoothUuid ] } @@ -5567,6 +5582,271 @@ A [=local end=] could simulate device GATT disconnection by sending the followin +#### The bluetooth.simulateService Command #### {#bluetooth-simulateservice-command} + +
+bluetooth.SimulateService = (
+   method: "bluetooth.simulateService",
+   params: bluetooth.SimulateServiceParameters,
+)
+
+bluetooth.simulateServiceParameters = {
+   context: text,
+   address: text,
+   uuid: bluetooth.BluetoothUuid,
+   type: "add" / "remove",
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.simulateService. + +
+ +
+A [=local end=] could simulate adding a GATT service by sending the following message: + +
+{
+  "method": "bluetooth.simulateService",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "uuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "type": "add"
+  }
+}
+
+
+ +
+A [=local end=] could simulate removing a GATT service by sending the following message: + +
+{
+  "method": "bluetooth.simulateService",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "uuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "type": "remove"
+  }
+}
+
+
+ +#### The bluetooth.SimulateCharacteristic Command #### {#bluetooth-simulatecharacteristic-command} + +
+bluetooth.SimulateCharacteristic = (
+   method: "bluetooth.simulateCharacteristic",
+   params: bluetooth.SimulateCharacteristicParameters,
+)
+
+bluetooth.SimulateCharacteristicParameters = {
+   context: text,
+   address: text,
+   serviceUuid: bluetooth.BluetoothUuid,
+   characteristicUuid: bluetooth.BluetoothUuid,
+   ? characteristicProperties: bluetooth.CharacteristicProperties,
+   type: "add" / "remove"
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.simulateCharacteristic. + +
+ +
+A [=local end=] could simulate adding a GATT characteristic with read, write, and notify properties +by sending the following message: + +
+{
+  "method": "bluetooth.simulateCharacteristic",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "characteristicProperties": {
+      "read": true,
+      "write": true,
+      "notify": true},
+    "type": "add"
+  }
+}
+
+
+ +
+A [=local end=] could simulate removing a GATT characteristic by sending the following message: + +
+{
+  "method": "bluetooth.simulateCharacteristic",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "type": "remove"
+  }
+}
+
+
+ +#### The bluetooth.simulateCharacteristicResponse Command #### {#bluetooth-simulatecharacteristicresponse-command} + +
+bluetooth.SimulateCharacteristicResponse = (
+   method: "bluetooth.simulateCharacteristicResponse",
+   params: bluetooth.SimulateCharacteristicResponseParameters,
+)
+
+bluetooth.SimulateCharacteristicResponseParameters = {
+   context: text,
+   address: text,
+   serviceUuid: bluetooth.BluetoothUuid,
+   characteristicUuid: bluetooth.BluetoothUuid,
+   type: "read" / "write" / "subscribe-to-notifications" / "unsubscribe-from-notifications",
+   code: uint
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.simulateCharacteristicResponse. + +
+ +
+A [=local end=] could simulate a response of success (error code `0x00` according to Error Response) +for a characteristic read operation by sending the following message: + +
+{
+  "method": "bluetooth.simulateCharacteristicResponse",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "type": "read",
+    "code": 0
+  }
+}
+
+
+ +#### The bluetooth.SimulateDescriptor Command #### {#bluetooth-simulatedescriptor-command} + +
+bluetooth.SimulateDescriptor = (
+   method: "bluetooth.simulateDescriptor",
+   params: bluetooth.SimulateDescriptorParameters,
+)
+
+bluetooth.SimulateDescriptorParameters = {
+   context: text,
+   address: text,
+   serviceUuid: bluetooth.BluetoothUuid,
+   characteristicUuid: bluetooth.BluetoothUuid,
+   descriptorUuid: bluetooth.BluetoothUuid,
+   type: "add" / "remove"
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.simulateDescriptor. + +
+ +
+A [=local end=] could simulate adding a GATT descriptor by sending the following message: + +
+{
+  "method": "bluetooth.simulateDescriptor",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "descriptorUuid": "00002901-0000-1000-8000-00805f9b34fb",
+    "type": "add"
+  }
+}
+
+
+ +
+A [=local end=] could simulate removing a GATT descriptor by sending the following message: + +
+{
+  "method": "bluetooth.simulateDescriptor",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "descriptorUuid": "00002901-0000-1000-8000-00805f9b34fb",
+    "type": "remove"
+  }
+}
+
+
+ +#### The bluetooth.simulateDescriptorResponse Command #### {#bluetooth-simulatedescriptorresponse-command} + +
+bluetooth.SimulateDescriptorResponse = (
+   method: "bluetooth.simulateDescriptorResponse",
+   params: bluetooth.SimulateDescriptorResponseParameters,
+)
+
+bluetooth.SimulateDescriptorResponseParameters = {
+   context: text,
+   address: text,
+   serviceUuid: bluetooth.BluetoothUuid,
+   characteristicUuid: bluetooth.BluetoothUuid,
+   descriptorUuid: bluetooth.BluetoothUuid,
+   type: "read" / "write",
+   code: uint
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.simulateDescriptorResponse. + +
+ +
+A [=local end=] could simulate a response of success (error code `0x00` according to Error Response) +for a descriptor read operation by sending the following message: + +
+{
+  "method": "bluetooth.simulateDescriptorResponse",
+  "params": {
+    "context": "cxt-d03fdd81",
+    "address": "09:09:09:09:09:09",
+    "serviceUuid": "0000180d-0000-1000-8000-00805f9b34fb",
+    "characteristicUuid": "00002a21-0000-1000-8000-00805f9b34fb",
+    "descriptorUuid": "00002901-0000-1000-8000-00805f9b34fb",
+    "type": "read",
+    "code": 0
+  }
+}
+
+
+ ### Events ### {#bidi-events} #### The bluetooth.requestDevicePromptUpdated Event #### {#bluetooth-requestdevicepromptupdated-event} @@ -5628,6 +5908,55 @@ To trigger a gatt connection attempted event given a [=navigable=] |n +#### The bluetooth.characteristicEventGenerated Event #### {#bluetooth-characteristicEventGenerated-event} + +
+bluetooth.CharacteristicEventGenerated = (
+   method: "bluetooth.characteristicEventGenerated",
+   params: bluetooth.CharacteristicEventGeneratedParameters
+)
+
+bluetooth.CharacteristicEventGeneratedParameters = {
+  context: text,
+  address: text,
+  serviceUuid: bluetooth.BluetoothUuid,
+  characteristicUuid: bluetooth.BluetoothUuid,
+  type: "read" / "write-with-response" / "write-without-response" / "subscribe-to-notifications" / "unsubscribe-from-notifications",
+  ? data: [ * uint ]
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.characteristicEventGenerated. + +
+ +#### The bluetooth.descriptorEventGenerated Event #### {#bluetooth-descriptoreventgenerated-event} + +
+bluetooth.DescriptorEventGenerated = (
+   method: "bluetooth.descriptorEventGenerated",
+   params: bluetooth.DescriptorEventGeneratedParameters
+)
+
+bluetooth.DescriptorEventGeneratedParameters = {
+  context: text,
+  address: text,
+  serviceUuid: bluetooth.BluetoothUuid,
+  characteristicUuid: bluetooth.BluetoothUuid,
+  descriptorUuid: bluetooth.BluetoothUuid,
+  type: "read" / "write",
+  ? data: [ * uint ]
+}
+
+ +
+ +Issue: TODO: Finish the algorithm of bluetooth.descriptorEventGenerated. + +
+ # Terminology and Conventions # {#terminology} This specification uses a few conventions and several terms from other From 0bbc112bc83ae10a0e18a3d077844fef027630bb Mon Sep 17 00:00:00 2001 From: Chengwei Hsieh Date: Thu, 1 May 2025 15:12:43 -0700 Subject: [PATCH 2/4] Correct title case --- index.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index 57f25ac..24bc3d1 100644 --- a/index.bs +++ b/index.bs @@ -5636,7 +5636,7 @@ A [=local end=] could simulate removing a GATT service by sending the following -#### The bluetooth.SimulateCharacteristic Command #### {#bluetooth-simulatecharacteristic-command} +#### The bluetooth.simulateCharacteristic Command #### {#bluetooth-simulatecharacteristic-command}
 bluetooth.SimulateCharacteristic = (
@@ -5742,7 +5742,7 @@ for a characteristic read operation by sending the following message:
 
-#### The bluetooth.SimulateDescriptor Command #### {#bluetooth-simulatedescriptor-command} +#### The bluetooth.simulateDescriptor Command #### {#bluetooth-simulatedescriptor-command}
 bluetooth.SimulateDescriptor = (

From b4d48c919c0cfa8ffcc50680d06e654213586aac Mon Sep 17 00:00:00 2001
From: Chengwei Hsieh 
Date: Thu, 1 May 2025 15:17:22 -0700
Subject: [PATCH 3/4] Correct title case

---
 index.bs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/index.bs b/index.bs
index 24bc3d1..655e974 100644
--- a/index.bs
+++ b/index.bs
@@ -5908,7 +5908,7 @@ To trigger a gatt connection attempted event given a [=navigable=] |n
 
 
 
-#### The bluetooth.characteristicEventGenerated Event #### {#bluetooth-characteristicEventGenerated-event}
+#### The bluetooth.characteristicEventGenerated Event #### {#bluetooth-characteristiceventgenerated-event}
 
 
 bluetooth.CharacteristicEventGenerated = (

From 52440c9d9fe5153a6497107f6c89f6973431beaf Mon Sep 17 00:00:00 2001
From: Chengwei Hsieh 
Date: Thu, 1 May 2025 22:28:07 -0700
Subject: [PATCH 4/4] Address comments

---
 index.bs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/index.bs b/index.bs
index 655e974..9a6dcc1 100644
--- a/index.bs
+++ b/index.bs
@@ -5590,7 +5590,7 @@ bluetooth.SimulateService = (
    params: bluetooth.SimulateServiceParameters,
 )
 
-bluetooth.simulateServiceParameters = {
+bluetooth.SimulateServiceParameters = {
    context: text,
    address: text,
    uuid: bluetooth.BluetoothUuid,
@@ -5675,7 +5675,8 @@ by sending the following message:
     "characteristicProperties": {
       "read": true,
       "write": true,
-      "notify": true},
+      "notify": true
+    },
     "type": "add"
   }
 }