@@ -4234,6 +4234,8 @@ To <dfn>clean up the disconnected device</dfn> |deviceObj|, the UA must:
423442341. Set <code><var> deviceObj</var> .gatt.{{BluetoothRemoteGATTServer/connected}} </code>
42354235 to `false`.
423642361. Clear <code><var> deviceObj</var> .gatt.{{[[activeAlgorithms]]}} </code> .
4237+ 1. Set <code><var> deviceObj</var> .gatt.{{[[automatedGATTConnectionResponse]]}} </code> to
4238+ `"not-expected"`.
423742391. Let |context| be <code> |deviceObj|.{{[[context]]}} </code> .
423842401. Remove all entries from <code> |context|.{{[[attributeInstanceMap]]}} </code>
42394241 whose keys are inside <code> |deviceObj|.{{[[representedDevice]]}} </code> .
@@ -5163,6 +5165,7 @@ BluetoothCommand = (
51635165 bluetooth.SimulatePreconnectedPeripheral //
51645166 bluetooth.SimulateAdvertisement //
51655167 bluetooth.SimulateGattConnectionResponse //
5168+ bluetooth.SimulateGattDisconnection //
51665169)
51675170</pre>
51685171
@@ -5510,6 +5513,60 @@ A [=local end=] could simulate a device gatt connection response of success
55105513</pre>
55115514</div>
55125515
5516+ #### The bluetooth.simulateGattDisconnection Command #### {#bluetooth-simulategattdisconnection-command}
5517+
5518+ <pre highlight="cddl" class="cddl remote-cddl local-cddl">
5519+ bluetooth.SimulateGattDisconnection = (
5520+ method: "bluetooth.simulateGattDisconnection",
5521+ params: bluetooth.SimulateGattDisconnectionParameters,
5522+ )
5523+
5524+ bluetooth.SimulateGattDisconnectionParameters = {
5525+ context: text,
5526+ address: text,
5527+ }
5528+
5529+ </pre>
5530+
5531+ <div algorithm="remote end steps for bluetooth.simulateGattDisconnection">
5532+ The [=remote end steps=] with command parameters |params| are:
5533+
5534+ 1. Let |contextId| be |params|[`"context"`] .
5535+ 1. Let |navigable| be the result of [=trying=] to [=get a navigable=] with |contextId|.
5536+ 1. Let |deviceAddress| be |params|[`"address"`] .
5537+ 1. Let |simulatedBluetoothAdapter| be |navigable|'s <a>simulated Bluetooth adapter</a> .
5538+ 1. If |simulatedBluetoothAdapter| is empty, return [=error=] with [=error code=] [=invalid argument=] .
5539+ 1. Let |deviceMapping| be |simulatedBluetoothAdapter|'s <a>simulated Bluetooth device mapping</a> .
5540+ 1. If |deviceMapping|[|deviceAddress|] [=map/exists=] , let |simulatedDevice| be |deviceMapping|[|deviceAddress|] .
5541+ Otherwise, return [=error=] with [=error code=] [=invalid argument=] .
5542+ 1. Let |simulatedDeviceInstance| be the result of <a>get the <code>BluetoothDevice</code> representing</a>
5543+ |simulatedDevice| inside |navigable|'s <a>active window</a>' s <a spec=HTML>associated <code>Navigator</code></a> 's
5544+ [=associated Bluetooth=] .
5545+ 1. If |simulatedDeviceInstance|.{{[[gatt]]}} .{{[[automatedGATTConnectionResponse]]}} is `"expected"`,
5546+ set |simulatedDeviceInstance|.{{[[gatt]]}} .{{[[automatedGATTConnectionResponse]]}} to `0x15`.
5547+ <div class="note">
5548+ `0x15` represents `"Remote Device Terminated Connection due to Power Off"` according to the
5549+ <a>List of Error Codes</a> . This simulates a scenario where the Bluetooth device is not able to
5550+ respond to a GATT connection attempt.
5551+ </div>
5552+ 1. Otherwise, <a>clean up the disconnected device</a> |simulatedDeviceInstance|.
5553+
5554+ </div>
5555+
5556+ <div class="example">
5557+ A [=local end=] could simulate device GATT disconnection by sending the following message:
5558+
5559+ <pre highlight="json">
5560+ {
5561+ "method": "bluetooth.simulateGattDisconnection",
5562+ "params": {
5563+ "context": "cxt-d03fdd81",
5564+ "address": "09:09:09:09:09:09",
5565+ }
5566+ }
5567+ </pre>
5568+ </div>
5569+
55135570### Events ### {#bidi-events}
55145571
55155572#### The bluetooth.requestDevicePromptUpdated Event #### {#bluetooth-requestdevicepromptupdated-event}
0 commit comments