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

Clarify how the ServiceChanged algorithm categorizes changes. #276

Merged
Merged
Changes from all commits
Commits
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
100 changes: 95 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -4120,9 +4120,98 @@ spec: html
Let <var>addedAttributes</var> be the list of attributes discovered in the previous step.
</li>
<li>
If an attribute with the same definition, ignoring Characteristic and Descriptor values,
If an attribute with the same definition
(see the <a>Service Interoperability Requirements</a>),
ignoring Characteristic and Descriptor values,
appears in both <var>removedAttributes</var> and <var>addedAttributes</var>,
remove it from both.

<div class="example" id="example-changed-service">
<p>
Given the following device states:
</p>

<dl>
<dt>State 1</dt>
<dd>
<ul>
<li>Service A
<ul>
<li>Characteristic C: value `[1, 2, 3]`</li>
</ul>
</li>
<li>Service B</li>
</ul>
</dd>

<dt>State 2</dt>
<dd>
<ul>
<li>Service A
<ul>
<li>Characteristic C: value `[3, 2, 1]`</li>
</ul>
</li>
<li>Service B</li>
</ul>
</dd>

<dt>State 3</dt>
<dd>
<ul>
<li>Service A
<ul>
<li>Characteristic D: value `[3, 2, 1]`</li>
</ul>
</li>
<li>Service B</li>
</ul>
</dd>

<dt>State 4</dt>
<dd>
<ul>
<li>Service A
<ul>
<li>Characteristic C: value `[1, 2, 3]`</li>
</ul>
</li>
<li>Service B
<ul>
<li>Include Service A</li>
</ul>
</li>
</ul>
</dd>
</dl>

<p>
A transition from state 1 to 2 leaves service A with
"the same definition, ignoring Characteristic and Descriptor values",
which means it's removed from both |removedAttributes| and |addedAttributes|,
and it wouldn't appear in any {{servicechanged}} events.
</p>
<p>
A transition from state 1 to 3 leaves service A with a different definition,
because a <a>service definition</a> includes its characteristic definitions,
so it's left in both |removedAttributes| and |addedAttributes|.
Then in <a href="#same-service-removed-and-added">step 8</a>,
the service is moved to |changedServices|,
which makes it cause a {{servicechanged}} event
instead of both a {{serviceadded}} and {{serviceremoved}}.
<a href="#characteristic-descriptor-change-adds-changed-service">Step 9</a>
also adds service A to |changedServices| because
characteristic C was removed and characteristic D was added.
</p>
<p>
A transition from state 1 to 4 is similar to the 1->3 transition.
Service B is moved to |changedServices| in
<a href="#same-service-removed-and-added">step 8</a>,
but no characteristics or descriptors have changed,
so it's not redundantly added in
<a href="#characteristic-descriptor-change-adds-changed-service">step 9</a>.
</p>
</div>
</li>
<li>
Let |invalidatedAttributes| be
Expand Down Expand Up @@ -4169,14 +4258,14 @@ spec: html
<li>
Let <var>changedServices</var> be a set of <a>Service</a>s, initially empty.
</li>
<li>
<li id="same-service-removed-and-added">
If the <a lt="same attribute">same</a> <a>Service</a> appears in
both <var>removedAttributes</var> and <var>addedAttributes</var>,
remove it from both, and add it to <var>changedServices</var>.
</li>
<li>
<li id="characteristic-descriptor-change-adds-changed-service">
For each <a>Characteristic</a> and <a>Descriptor</a>
in <var>removedAttributes</var> and <var>addedAttributes</var>,
in <var>removedAttributes</var> or <var>addedAttributes</var>,
remove it from its original list,
and add its parent <a>Service</a> to <var>changedServices</var>.
<span class="note">After this point, <var>removedAttributes</var> and <var>addedAttributes</var> contain only <a>Service</a>s.</span>
Expand Down Expand Up @@ -4915,8 +5004,9 @@ spec: html
</li>
</ol>
</li>
<li value="3">Service Interoperability Requirements
<li value="3"><dfn>Service Interoperability Requirements</dfn>
<ol>
<li value="1"><dfn>Service Definition</dfn></li>
<li value="3">Characteristic Definition
<ol>
<li value="1">Characteristic Declaration
Expand Down