Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bluetooth device emulation support #630

Merged
merged 29 commits into from
Oct 4, 2024
Merged
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c413238
Initial cut
alexnj Aug 10, 2024
35e3421
Add semantics and examples
alexnj Aug 16, 2024
9e201a6
Review changes.
alexnj Aug 19, 2024
9bd0bf4
Curly brace for SimulateAdvertisementParameters
alexnj Aug 19, 2024
a5217c4
Add algorithm for adding a virtual peripheral
alexnj Sep 4, 2024
b67a242
Add remote algorithm for simulateAdvertisement
alexnj Sep 4, 2024
d99c313
Review changes
alexnj Sep 4, 2024
f2a3577
Review updates
alexnj Sep 5, 2024
3c9eec6
Reintroduce simulateCentral + review feedback
alexnj Sep 11, 2024
f8f6dc4
Rename simulateCentral to simulateAdapter
alexnj Sep 11, 2024
ee735fd
Rename virtual prefix to simulated + review changes
alexnj Sep 12, 2024
83d6e02
Review changes
alexnj Sep 12, 2024
7053802
Formatting for scanRecord definitions
alexnj Sep 12, 2024
6e0a6b3
Apply suggestions from code review
alexnj Sep 16, 2024
5c9b744
Review edits
alexnj Sep 16, 2024
e90b078
Update index.bs
alexnj Sep 16, 2024
977a282
Review edits + issues
alexnj Sep 16, 2024
4450610
Update changes from offline sync
alexnj Sep 17, 2024
2f92b5b
An attempt at resolving the correct event loop
alexnj Sep 17, 2024
4411dce
Add text to resolve navigator.bluetooth on navigable.
alexnj Sep 18, 2024
e34b094
Revise spec to adjust for bidi navigable resolution
alexnj Sep 18, 2024
8df4f2d
Review updates + CDDL changes to match the actual impl.
alexnj Sep 19, 2024
03050b9
More updates.
alexnj Sep 19, 2024
0a18c16
Update steps for global param for scan for devices algorithm
alexnj Sep 19, 2024
79256fa
Add a missing [=exists=].
alexnj Sep 19, 2024
dab2bf1
Correct lint errors + review changes
alexnj Sep 20, 2024
fa4b089
Review changes
alexnj Sep 20, 2024
b7a40ff
Review changes.
alexnj Sep 24, 2024
b373044
Update data type to bstr
alexnj Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4938,6 +4938,19 @@ To <dfn>serialize prompt devices</dfn> given [=device prompt=] |prompt|:

</div>

#### The bluetooth.ScanRecord Type #### {#bluetooth-scanrecord-type}

<pre highlight="cddl" class="cddl remote-cddl local-cddl">
bluetooth.ScanRecord = {
optional name: text,
optional uuids: BluetoothServiceUuid[],
optional appearance: integer,
alexnj marked this conversation as resolved.
Show resolved Hide resolved
optional manufacturerData: BluetoothManufacturerDataMap,
}
</pre>

A bluetooth.ScanRecord represents data of the advertisement packet sent by a Bluetooth device.

### Errors ### {#bidi-errors}

This specification extends the set of [=error codes=] from
Expand Down Expand Up @@ -5013,6 +5026,130 @@ A [=local end=] could dismiss a prompt by sending the following message:
</pre>
</div>

#### The bluetooth.simulateCentral Command #### {#bluetooth-simulatecentral-command}

<pre highlight="cddl" class="cddl remote-cddl local-cddl">
bluetooth.simulateCentral = (
alexnj marked this conversation as resolved.
Show resolved Hide resolved
method: "bluetooth.simulateCentral",
params: bluetooth.SimulateCentralParameters,
)

bluetooth.SimulateCentralParameters = {
state: "absent" / "powered-off" / "powered-on"
}
</pre>

<div algorithm="remote end steps for bluetooth.simulateCentral">
The [=remote end steps=] with command parameters |params| are:

1. Let |state| be |params|[`"state"`].
alexnj marked this conversation as resolved.
Show resolved Hide resolved
1. Return [=success=] with data `null`.
alexnj marked this conversation as resolved.
Show resolved Hide resolved

</div>

<div class="example">
A [=local end=] could simulate a central by sending the following message:

<pre highlight="json">
{
"method": "bluetooth.simulateCentral",
"state": "powered-on"
}
</pre>
</div>

#### The bluetooth.simulatePreconnectedPeripheral Command #### {#bluetooth-simulateconnectedperipheral-command}

<pre highlight="cddl" class="cddl remote-cddl local-cddl">
bluetooth.simulatePreconnectedPeripheral = (
alexnj marked this conversation as resolved.
Show resolved Hide resolved
method: "bluetooth.simulatePreconnectedPeripheral",
params: bluetooth.SimulatePreconnectedPeripheralParameters,
)

bluetooth.SimulatePreconnectedPeripheralParameters = {
address: string,
name: string,
manufacturerData: BluetoothManufacturerDataMap,
knownServiceUuids: string[]
}
</pre>

<div algorithm="remote end steps for bluetooth.simulatePreconnectedPeripheral">
The [=remote end steps=] with command parameters |params| are:

1. Let |address| be |params|[`"address"`].
1. Let |name| be |params|[`"name"`].
1. Let |manufacturerData| be |params|[`"manufacturerData"`].
1. Let |knownServiceUuids| be |params|[`"knownServiceUuids"`].
alexnj marked this conversation as resolved.
Show resolved Hide resolved
1. Return [=success=] with data `null`.
alexnj marked this conversation as resolved.
Show resolved Hide resolved

</div>

<div class="example">
A [=local end=] could simulate a preconnected peripheral by sending the following message:

<pre highlight="json">
{
"method": "bluetooth.simulatePreconnectedPeripheral",
"address": "09:09:09:09:09:09",
"name": "Some Device",
"manufacturerData": { "companyIdentifier": 17 },
alexnj marked this conversation as resolved.
Show resolved Hide resolved
"knownServiceUuids": [
"12345678-1234-5678-9abc-def123456789",
]
}
</pre>
</div>

#### The bluetooth.simulateAdvertisement Command #### {#bluetooth-simulateadvertisement-command}

<pre highlight="cddl" class="cddl remote-cddl local-cddl">
bluetooth.simulateAdvertisement = (
method: "bluetooth.simulateAdvertisement",
params: bluetooth.SimulateAdvertisementParameters,
)

bluetooth.SimulateAdvertisementParameters = {
entry: bluetooth.SimulateAdvertisementScanEntryParameters[]
alexnj marked this conversation as resolved.
Show resolved Hide resolved
}

bluetooth.SimulateAdvertisementScanEntryParameters = {
deviceAddress: string,
rssi: integer,
scanRecord: bluetooth.ScanRecord
}

</pre>

<div algorithm="remote end steps for bluetooth.simulateAdvertisement">
The [=remote end steps=] with command parameters |params| are:

1. Let |entry| be |params|[`"entry"`].
1. Return [=success=] with data `null`.

</div>

<div class="example">
A [=local end=] could simulate a device advertisement by sending the following message:

<pre highlight="json">
{
"method": "bluetooth.simulateAdvertisement",
"entry": {
"deviceAddress": "08:08:08:08:08:08",
"rssi": -10,
"scanRecord": {
"name": "Heart Rate",
"uuids": ["0000180d-0000-1000-8000-00805f9b34fb"],
"manufacturerData": { "companyIdentifier": 17 },
alexnj marked this conversation as resolved.
Show resolved Hide resolved
"appearance": 1,
"txPower": 1
}
}
}
</pre>
</div>

### Events ### {#bidi-events}

#### The bluetooth.requestDevicePromptUpdated Event #### {#bluetooth-requestdevicepromptupdated-event}
Expand Down