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

Unify the BluetoothUUID.get* algorithms. #149

Merged
merged 2 commits into from
Jul 30, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
121 changes: 45 additions & 76 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2896,17 +2896,34 @@ <h2>Standardized UUIDs</h2>
<code>"deadbeef-0000-1000-8000-00805f9b34fb"</code>.
</p>

<p class="note">
<dfn>BluetoothServiceUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-SERVICES]],
or, equivalently, the values for which
<a>BluetoothUUID.getService</a> does not throw an exception.
</p>
<div class="note">
<p>
<dfn>BluetoothServiceUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-SERVICES]],
or, equivalently, the values for which
<a>BluetoothUUID.getService</a> does not throw an exception.
</p>
<p>
<dfn>BluetoothCharacteristicUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-CHARACTERISTICS]],
or, equivalently, the values for which
<a>BluetoothUUID.getCharacteristic</a> does not throw an exception.
</p>
<p>
<dfn>BluetoothDescriptorUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-DESCRIPTORS]],
or, equivalently, the values for which
<a>BluetoothUUID.getDescriptor</a> does not throw an exception.
</p>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works, but... it's a touch odd to mix variables and the '.' literal this way. An alternative would be something like: If the string prefix + "." + name appears in...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


<p>
The static <code><dfn>BluetoothUUID.getService</dfn>(<var>name</var>)</code> method, when invoked,
MUST run the following steps:
To <dfn>ResolveUUIDName</dfn>(<var>name</var>,
<var>assigned numbers table</var>, <var>prefix</var>),
the UA MUST perform the following steps:
</p>
<ol>
<li>
Expand All @@ -2918,14 +2935,32 @@ <h2>Standardized UUIDs</h2>
return <var>name</var> and abort these steps.
</li>
<li>
If <code>org.bluetooth.service.<var>name</var></code> appears in [[!BLUETOOTH-ASSIGNED-SERVICES]],
If <code><var>prefix</var>.<var>name</var></code>
appears in <var>assigned numbers table</var>,
let <var>alias</var> be its assigned number,
and return <code><a>BluetoothUUID.canonicalUUID</a>(<var>alias</var>)</code>.
</li>
<li>
Otherwise, throw a <a>SyntaxError</a>.
</li>
</ol>

<p>
The static <code><dfn>BluetoothUUID.getService</dfn>(<var>name</var>)</code> method, when invoked,
MUST return <a>ResolveUUIDName</a>(<code><var>name</var></code>,
[[!BLUETOOTH-ASSIGNED-SERVICES]], "org.bluetooth.service").
</p>
<p>
The static <code><dfn>BluetoothUUID.getCharacteristic</dfn>(<var>name</var>)</code> method, when invoked,
MUST return <a>ResolveUUIDName</a>(<code><var>name</var></code>,
[[!BLUETOOTH-ASSIGNED-CHARACTERISTICS]], "org.bluetooth.characteristic").
</p>
<p>
The static <code><dfn>BluetoothUUID.getDescriptor</dfn>(<var>name</var>)</code> method, when invoked,
MUST return <a>ResolveUUIDName</a>(<code><var>name</var></code>,
[[!BLUETOOTH-ASSIGNED-DESCRIPTORS]], "org.bluetooth.descriptor").
</p>

<aside class="example">
<p>
<code><a>BluetoothUUID.getService</a>("<a
Expand All @@ -2941,78 +2976,12 @@ <h2>Standardized UUIDs</h2>
<code><a>BluetoothUUID.getService</a>("unknown-service")</code>
throws a <a>SyntaxError</a>.
</p>
</aside>

<p class="note">
<dfn>BluetoothCharacteristicUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-CHARACTERISTICS]],
or, equivalently, the values for which
<a>BluetoothUUID.getCharacteristic</a> does not throw an exception.
</p>

<p>
The static <code><dfn>BluetoothUUID.getCharacteristic</dfn>(<var>name</var>)</code> method, when invoked,
MUST run the following steps:
</p>
<ol>
<li>
If <var>name</var> is an <code>unsigned long</code>,
return <code><a>BluetoothUUID.canonicalUUID</a>(name)</code> and abort these steps.
</li>
<li>
If <var>name</var> is a <a>valid UUID</a>,
return <var>name</var> and abort these steps.
</li>
<li>
If <code>org.bluetooth.characteristic.<var>name</var></code> appears in [[!BLUETOOTH-ASSIGNED-CHARACTERISTICS]],
let <var>alias</var> be its assigned number,
and return <code><a>BluetoothUUID.canonicalUUID</a>(<var>alias</var>)</code>.
</li>
<li>
Otherwise, throw a <a>SyntaxError</a>.
</li>
</ol>
<aside class="example">
<p>
<code><a>BluetoothUUID.getCharacteristic</a>("<a
href="https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.ieee_11073-20601_regulatory_certification_data_list.xml"
>ieee_11073-20601_regulatory_certification_data_list</a>")</code>
returns <code>"00002a2a-0000-1000-8000-00805f9b34fb"</code>.
</p>
</aside>

<p class="note">
<dfn>BluetoothDescriptorUUID</dfn> represents
16- and 32-bit UUID aliases, <a>valid UUID</a>s,
and names defined in [[BLUETOOTH-ASSIGNED-DESCRIPTORS]],
or, equivalently, the values for which
<a>BluetoothUUID.getDescriptor</a> does not throw an exception.
</p>

<p>
The static <code><dfn>BluetoothUUID.getDescriptor</dfn>(<var>name</var>)</code> method, when invoked,
MUST run the following steps:
</p>
<ol>
<li>
If <var>name</var> is an <code>unsigned long</code>,
return <code><a>BluetoothUUID.canonicalUUID</a>(name)</code> and abort these steps.
</li>
<li>
If <var>name</var> is a <a>valid UUID</a>,
return <var>name</var> and abort these steps.
</li>
<li>
If <code>org.bluetooth.descriptor.<var>name</var></code> appears in [[!BLUETOOTH-ASSIGNED-DESCRIPTORS]],
let <var>alias</var> be its assigned number,
and return <code><a>BluetoothUUID.canonicalUUID</a>(<var>alias</var>)</code>.
</li>
<li>
Otherwise, throw a <a>SyntaxError</a>.
</li>
</ol>
<aside class="example">
<p>
<code><a>BluetoothUUID.getDescriptor</a>("<a
href="https://developer.bluetooth.org/gatt/descriptors/Pages/DescriptorViewer.aspx?u=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml"
Expand Down