Skip to content

Commit 75e1dd5

Browse files
authored
Complete the algorithm of bluetooth.simulateCharacteristic WebDriver Bidi command (#655)
1 parent 89af1aa commit 75e1dd5

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

index.bs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5015,7 +5015,12 @@ and has a <dfn>simulated GATT service mapping</dfn>, which is an <a>ordered map<
50155015
<a>UUID</a> strings to <a>simulated GATT services</a>.
50165016

50175017
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
5018+
<a>simulated Bluetooth device</a>, has a property of <a>UUID</a>, is known-present in the
5019+
<a>Bluetooth cache</a>. and has a <dfn>simulated GATT characteristic mapping</dfn>, which
5020+
is an <a>ordered map</a> of Bluetooth <a>UUID</a> strings to <a>simulated GATT characteristics</a>.
5021+
5022+
A <dfn>simulated GATT characteristic</dfn> is a software defined [=Characteristic=] that belongs to a
5023+
<a>simulated GATT service</a>, has a property of <a>UUID</a>, and is known-present in the
50195024
<a>Bluetooth cache</a>.
50205025

50215026
Issue: CDDL snippetes use the "text" type instead of
@@ -5692,8 +5697,43 @@ bluetooth.SimulateCharacteristicParameters = {
56925697
</pre>
56935698

56945699
<div algorithm="remote end steps for bluetooth.simulateCharacteristic">
5700+
The [=remote end steps=] with command parameters |params| are:
56955701

5696-
Issue: TODO: Finish the algorithm of bluetooth.simulateCharacteristic.
5702+
1. Let |contextId| be |params|[`"context"`].
5703+
1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with |contextId|.
5704+
1. Let |deviceAddress| be |params|[`"address"`].
5705+
1. Let |simulatedBluetoothAdapter| be |navigable|'s <a>simulated Bluetooth adapter</a>.
5706+
1. If |simulatedBluetoothAdapter| is empty, return [=error=] with [=error code=] [=invalid argument=].
5707+
1. Let |deviceMapping| be |simulatedBluetoothAdapter|'s <a>simulated Bluetooth device mapping</a>.
5708+
1. If |deviceMapping|[|deviceAddress|] [=map/exists=], let |simulatedDevice| be |deviceMapping|[|deviceAddress|].
5709+
1. Otherwise, return [=error=] with [=error code=] [=invalid argument=].
5710+
1. Let |simulatedDeviceInstance| be the result of <a>get the <code>BluetoothDevice</code> representing</a>
5711+
|simulatedDevice| inside |navigable|'s <a>active window</a>'s <a spec=HTML>associated <code>Navigator</code></a>'s
5712+
[=associated Bluetooth=].
5713+
1. Let |serviceMapping| be |simulatedDevice|'s <a>simulated GATT service mapping</a>.
5714+
1. Let |serviceUuid| be |params|[`"serviceUuid"`].
5715+
1. If |serviceMapping|[|serviceUuid|] [=map/exists=], let |simulatedService| be |serviceMapping|[|serviceUuid|].
5716+
1. Otherwise, return [=error=] with [=error code=] [=invalid argument=].
5717+
1. Let |characteristicMapping| be |simulatedService|'s <a>simulated GATT characteristic mapping</a>.
5718+
1. Let |characteristicUuid| be |params|[`"characteristicUuid"`].
5719+
1. If |params|[`"type"`] is `"add"`:
5720+
1. If |characteristicMapping|[|characteristicUuid|] [=map/exists=], return [=error=] with
5721+
[=error code=] [=invalid element state=].
5722+
1. Let |simulatedGattCharacteristic| be a new <a>simulated GATT characteristic</a>.
5723+
1. Set |simulatedGattCharacteristic|'s <a>UUID</a> to |characteristicUuid|.
5724+
1. Set |characteristicMapping|[|characteristicUuid|] to |simulatedGattCharacteristic|.
5725+
1. <a>Create a <code>BluetoothRemoteGATTCharacteristic</code> representing</a> |simulatedGattCharacteristic|
5726+
and add a mapping from |simulatedGattCharacteristic| to the resulting {{Promise}} in
5727+
|simulatedDeviceInstance|.{{[[context]]}}.{{Bluetooth/[[attributeInstanceMap]]}}.
5728+
1. Return [=success=] with data `null`.
5729+
1. Else if |params|[`"type"`] is `"remove"`:
5730+
1. If |characteristicMapping|[|characteristicUuid|] [=map/exists=], let |simulatedGattCharacteristic|
5731+
be |characteristicMapping|[|characteristicUuid|].
5732+
1. Otherwise, return [=error=] with [=error code=] [=invalid element state=].
5733+
1. Remove |simulatedGattCharacteristic| from |simulatedDeviceInstance|.{{[[context]]}}.{{Bluetooth/[[attributeInstanceMap]]}}.
5734+
1. Remove |characteristicUuid| from |characteristicMapping|.
5735+
1. Return [=success=] with data `null`.
5736+
1. Return [=error=] with [=error code=] [=invalid argument=].
56975737

56985738
</div>
56995739

0 commit comments

Comments
 (0)