Skip to content

Commit 89af1aa

Browse files
authored
Support bluetooth.simulateService WebDriver Bidi command (#652)
1 parent 4cc1268 commit 89af1aa

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

index.bs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5008,7 +5008,15 @@ Each <a>simulated Bluetooth adapter</a> has an <dfn>adapter state</dfn> that is
50085008

50095009
Each <a>simulated Bluetooth adapter</a> has a <dfn lt="LE supported state">low-energy supported state</dfn> that is a boolean describing if the adapter supports Bluetooth Low Energy.
50105010

5011-
A <dfn>simulated Bluetooth device</dfn> is a software defined [=Bluetooth device=] that behaves like a physical device, and may be attached to a <a>simulated Bluetooth adapter</a>, and may have associated properties like <a>Manufacturer Specific Data</a> and <a>Service UUIDs</a>.
5011+
A <dfn>simulated Bluetooth device</dfn> is a software defined [=Bluetooth device=] that
5012+
behaves like a physical device, may be attached to a <a>simulated Bluetooth adapter</a>,
5013+
may have associated properties like <a>Manufacturer Specific Data</a> and <a>Service UUIDs</a>,
5014+
and has a <dfn>simulated GATT service mapping</dfn>, which is an <a>ordered map</a> of Bluetooth
5015+
<a>UUID</a> strings to <a>simulated GATT services</a>.
5016+
5017+
A <dfn>simulated GATT service</dfn> is a software defined [=Service=] that belongs to a
5018+
<a>simulated Bluetooth device</a>, has a property of <a>UUID</a>, and is known-present in the
5019+
<a>Bluetooth cache</a>.
50125020

50135021
Issue: CDDL snippetes use the "text" type instead of
50145022
"browsingContext.BrowsingContext" to allow indepedent programmatic
@@ -5599,8 +5607,37 @@ bluetooth.SimulateServiceParameters = {
55995607
</pre>
56005608

56015609
<div algorithm="remote end steps for bluetooth.simulateService">
5610+
The [=remote end steps=] with command parameters |params| are:
56025611

5603-
Issue: TODO: Finish the algorithm of bluetooth.simulateService.
5612+
1. Let |contextId| be |params|[`"context"`].
5613+
1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with |contextId|.
5614+
1. Let |deviceAddress| be |params|[`"address"`].
5615+
1. Let |simulatedBluetoothAdapter| be |navigable|'s <a>simulated Bluetooth adapter</a>.
5616+
1. If |simulatedBluetoothAdapter| is empty, return [=error=] with [=error code=] [=invalid argument=].
5617+
1. Let |deviceMapping| be |simulatedBluetoothAdapter|'s <a>simulated Bluetooth device mapping</a>.
5618+
1. If |deviceMapping|[|deviceAddress|] [=map/exists=], let |simulatedDevice| be |deviceMapping|[|deviceAddress|].
5619+
1. Otherwise, return [=error=] with [=error code=] [=invalid argument=].
5620+
1. Let |simulatedDeviceInstance| be the result of <a>get the <code>BluetoothDevice</code> representing</a>
5621+
|simulatedDevice| inside |navigable|'s <a>active window</a>'s <a spec=HTML>associated <code>Navigator</code></a>'s
5622+
[=associated Bluetooth=].
5623+
1. Let |serviceMapping| be |simulatedDevice|'s <a>simulated GATT service mapping</a>.
5624+
1. Let |uuid| be |params|[`"uuid"`].
5625+
1. If |params|[`"type"`] is `"add"`:
5626+
1. If |serviceMapping|[|uuid|] [=map/exists=], return [=error=] with [=error code=] [=invalid element state=].
5627+
1. Let |simulatedGattService| be a new <a>simulated GATT service</a>.
5628+
1. Set |simulatedGattService|'s <a>UUID</a> to |uuid|.
5629+
1. Set |serviceMapping|[|uuid|] to |simulatedGattService|.
5630+
1. <a>Create a <code>BluetoothRemoteGATTService</code> representing</a> |simulatedGattService|
5631+
and add a mapping from |simulatedGattService| to the resulting {{Promise}} in
5632+
|simulatedDeviceInstance|.{{[[context]]}}.{{Bluetooth/[[attributeInstanceMap]]}}.
5633+
1. Return [=success=] with data `null`.
5634+
1. Else if |params|[`"type"`] is `"remove"`:
5635+
1. If |serviceMapping|[|uuid|] [=map/exists=], let |simulatedGattService| be |serviceMapping|[|uuid|].
5636+
1. Otherwise, return [=error=] with [=error code=] [=invalid element state=].
5637+
1. Remove |simulatedGattService| from |simulatedDeviceInstance|.{{[[context]]}}.{{Bluetooth/[[attributeInstanceMap]]}}.
5638+
1. Remove |uuid| from |serviceMapping|.
5639+
1. Return [=success=] with data `null`.
5640+
1. Return [=error=] with [=error code=] [=invalid argument=].
56045641

56055642
</div>
56065643

0 commit comments

Comments
 (0)