Skip to content

Commit

Permalink
Specify a Bluetooth Scanning API. (#239)
Browse files Browse the repository at this point in the history
* Specify a Bluetooth Scanning API.

The API can filter by name, namePrefix, serviceUUID, the ID in a manufacturer data entry, or the UUID in a service data entry, or can explicitly opt into receiving all advertisements.

This doesn't cover scanning from a service worker yet.

Fixes #191.
  • Loading branch information
jyasskin committed Aug 2, 2016
1 parent 6077959 commit 9c56bc4
Show file tree
Hide file tree
Showing 4 changed files with 3,670 additions and 51 deletions.
38 changes: 30 additions & 8 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,7 +1579,7 @@ spec: permissions
interface BluetoothDevice {
readonly attribute DOMString id;
readonly attribute DOMString? name;
readonly attribute BluetoothRemoteGATTServer gatt;
readonly attribute BluetoothRemoteGATTServer? gatt;
readonly attribute FrozenArray<UUID> uuids;

Promise<void> watchAdvertisements();
Expand All @@ -1606,7 +1606,8 @@ spec: permissions
</p>

<p>
<dfn>gatt</dfn> provides a way to interact with this device's GATT server.
{{BluetoothDevice/gatt}} provides a way to interact with this device's GATT server
if the site has permission to use any of its services.
</p>

<p>
Expand Down Expand Up @@ -1646,6 +1647,17 @@ spec: permissions
The <a>Bluetooth device</a> this object represents.
</td>
</tr>
<tr>
<td><dfn>\[[gatt]]</dfn></td>
<td>
a new {{BluetoothRemoteGATTServer}} instance with
its {{BluetoothRemoteGATTServer/device}} attribute initialized to `this`
and its {{BluetoothRemoteGATTServer/connected}} attribute initialized to `false`.
</td>
<td>
Does not change.
</td>
</tr>
<tr>
<td><dfn>\[[allowedServices]]</dfn></td>
<td>`undefined`</td>
Expand Down Expand Up @@ -1736,12 +1748,6 @@ spec: permissions
<li>
Initialize <code><var>result</var>.watchingAdvertisements</code> to `false`.
</li>
<li>
Set <code><var>result</var>.gatt.{{BluetoothRemoteGATTServer/device}}</code> to <var>result</var>.
</li>
<li>
Set <code><var>result</var>.gatt.{{BluetoothRemoteGATTServer/connected}}</code> to `false`.
</li>
<li>
Add <var>device</var>'s
advertised <a>Service UUIDs</a>
Expand All @@ -1765,6 +1771,22 @@ spec: permissions
</li>
</ol>

<div algorithm>
<p>
Getting the <code><dfn attribute for="BluetoothDevice">gatt</dfn></code> attribute
MUST perform the following steps:
</p>
<ol class="algorithm">
<li>
If <code>this.{{[[allowedServices]]}}</code> is an empty list,
return `null`.
</li>
<li>
Return <code>this.{{[[gatt]]}}</code>.
</li>
</ol>
</div>

<p>
Getting the <code><dfn attribute for="BluetoothDevice">uuids</dfn></code> attribute
MUST perform the following steps:
Expand Down
Loading

0 comments on commit 9c56bc4

Please sign in to comment.