Skip to content

Commit

Permalink
Block use of invalidated attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jyasskin committed Aug 12, 2016
1 parent 04042fe commit 1f899d0
Showing 1 changed file with 86 additions and 23 deletions.
109 changes: 86 additions & 23 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2536,11 +2536,6 @@ spec: permissions
and run the following steps <a>in parallel</a>:
</p>
<ol>
<li>
If <code><var>deviceObj</var>.gatt.{{BluetoothRemoteGATTServer/connected}}</code>
is `false`,
<a>reject</a> <var>promise</var> with a {{NetworkError}} and abort these steps.
</li>
<li>
<a>Populate the Bluetooth cache</a> with entries matching the description.
</li>
Expand Down Expand Up @@ -2589,6 +2584,26 @@ spec: permissions
</li>
</ol>
</div>

<div algorithm>
<p>
<dfn>Represented</dfn>(|obj|: Device or GATT Attribute) returns,
depending on the type of |obj|:
</p>
<dl class="switch">
<dt>{{BluetoothDevice}}</dt>
<dd><code>|obj|.{{[[representedDevice]]}}</code></dd>

<dt>{{BluetoothRemoteGATTService}}</dt>
<dd><code>|obj|.{{[[representedService]]}}</code></dd>

<dt>{{BluetoothRemoteGATTCharacteristic}}</dt>
<dd><code>|obj|.{{[[representedCharacteristic]]}}</code></dd>

<dt>{{BluetoothRemoteGATTDescriptor}}</dt>
<dd><code>|obj|.{{[[representedDescriptor]]}}</code></dd>
</dl>
</div>
</section>

<section>
Expand Down Expand Up @@ -2627,11 +2642,25 @@ spec: permissions
<dd><code><var>attribute</var>.{{BluetoothRemoteGATTCharacteristic/service}}.{{BluetoothRemoteGATTService/device}}</code></dd>
</dl>
</li>
<li>
If <code><var>deviceObj</var>.gatt.{{BluetoothRemoteGATTServer/connected}}</code>
is `false`,
return <a>a promise rejected with</a> with a {{NetworkError}} and
abort these steps.
</li>
<li>
If <a>Represented</a>(|attribute|) is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.

Note: This happens when a Service or Characteristic is removed from the device,
and then its object is used again.
</li>
<li>
<a>Query the Bluetooth cache</a> in <code><var>deviceObj</var></code>
for entries that:
<ul>
<li>are within the Bluetooth attribute or device represented by <var>attribute</var>,</li>
<li>are within <a>Represented</a>(|attribute|),</li>
<li>have a type described by <var>child type</var>,</li>
<li>have a UUID that is not <a>blacklisted</a>,</li>
<li>if <var>uuid</var> is present, have a UUID of <var>uuid</var>,</li>
Expand Down Expand Up @@ -3282,8 +3311,13 @@ spec: permissions
and abort these steps.
</li>
<li>
Let <var>characteristic</var> be the <a>Characteristic</a>
that <code>this</code> represents.
Let |characteristic| be
<code>this.{{[[representedCharacteristic]]}}</code>.
</li>
<li>
If |characteristic| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
Return a <code>this.service.device.gatt</code>-<a>connection-checking wrapper</a> around
Expand Down Expand Up @@ -3343,10 +3377,6 @@ spec: permissions
return <a>a promise rejected with</a> a {{SecurityError}}
and abort these steps.
</li>
<li>
Let <var>characteristic</var> be the <a>Characteristic</a>
that <code>this</code> represents.
</li>
<li>
Let <var>bytes</var> be
<a>a copy of the bytes held</a> by <code><var>value</var></code>.
Expand All @@ -3362,6 +3392,15 @@ spec: permissions
return <a>a promise rejected with</a> a {{NetworkError}}
and abort these steps.
</li>
<li>
Let |characteristic| be
<code>this.{{[[representedCharacteristic]]}}</code>.
</li>
<li>
If |characteristic| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
Return a <code>this.service.device.gatt</code>-<a>connection-checking wrapper</a> around
<a>a new promise</a> <var>promise</var>
Expand Down Expand Up @@ -3428,8 +3467,13 @@ spec: permissions
<a>reject</a> <var>promise</var> with a {{SecurityError}} and abort these steps.
</li>
<li>
Let <var>characteristic</var> be
the GATT <a>Characteristic</a> that <code>this</code> represents.
Let |characteristic| be
<code>this.{{[[representedCharacteristic]]}}</code>.
</li>
<li>
If |characteristic| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
If neither of the <code>Notify</code> or <code>Indicate</code> bits are set
Expand Down Expand Up @@ -3488,8 +3532,13 @@ spec: permissions
</p>
<ol>
<li>
Let <var>characteristic</var> be
the GATT <a>Characteristic</a> that <code>this</code> represents.
Let |characteristic| be
<code>this.{{[[representedCharacteristic]]}}</code>.
</li>
<li>
If |characteristic| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
If <var>characteristic</var>'s <a>active notification context set</a> contains
Expand Down Expand Up @@ -3711,8 +3760,13 @@ spec: permissions
and abort these steps.
</li>
<li>
Let <var>descriptor</var> be the <a>Descriptor</a>
that <code>this</code> represents.
Let |descriptor| be
<code>this.{{[[representedDescriptor]]}}</code>.
</li>
<li>
If |descriptor| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
Return a
Expand Down Expand Up @@ -3763,10 +3817,6 @@ spec: permissions
return <a>a promise rejected with</a> a {{SecurityError}}
and abort these steps.
</li>
<li>
Let <var>descriptor</var> be the <a>Descriptor</a>
that <code>this</code> represents.
</li>
<li>
Let <var>bytes</var> be
<a>a copy of the bytes held</a> by <code><var>value</var></code>.
Expand All @@ -3783,6 +3833,15 @@ spec: permissions
return <a>a promise rejected with</a> a {{NetworkError}}
and abort these steps.
</li>
<li>
Let |descriptor| be
<code>this.{{[[representedDescriptor]]}}</code>.
</li>
<li>
If |descriptor| is `null`,
return <a>a promise rejected with</a> an {{InvalidStateError}} and
abort these steps.
</li>
<li>
Return a
<code>this.characteristic.service.device.gatt</code>-<a>connection-checking wrapper</a> around
Expand Down Expand Up @@ -4250,7 +4309,6 @@ spec: permissions
<li>
Take the following actions depending on the <code>Error Code</code>:
<dl class="switch">
<dt><code>Invalid Handle</code></dt>
<dt><code>Invalid PDU</code></dt>
<dt><code>Invalid Offset</code></dt>
<dt><code>Attribute Not Found</code></dt>
Expand All @@ -4261,6 +4319,11 @@ spec: permissions
Return a {{NotSupportedError}} from the step.
</dd>

<dt><code>Invalid Handle</code></dt>
<dd>
Return an {{InvalidStateError}} from the step.
</dd>

<dt><code>Invalid Attribute Value Length</code></dt>
<dd>
Return an {{InvalidModificationError}} from the step.
Expand Down

0 comments on commit 1f899d0

Please sign in to comment.