Concentrators are devices in sensor networks, concentrating the management of a sub set of devices to one point. They can be small (for example: PLC:s managing a small
set of sensors and actuators), medium-sized (for example: mid-level concentrators, controlling branches of the network, islands, perhaps using separate communication protocols),
large (for example: entire sub-systems, perhaps managed by a separate child/partner organization) to massive (for example: The entire top-level system, smart-grid, IoT network).
</p>
<p>
Even though this XEP is generally written and can be used by other implementations not based on sensor networks, much of the requirements used to define this specification
comes from requirements used in sensor networks and Internet of Things applications and infrastructure.
</p>
<p>
This specification will define the following aspects of a general concentrator profile, that can handle all different types of concentrators available in sensor network architectures:
</p>
<ul>
<li>
A concentrator works with multiple <strong>data sources</strong>. Effective management of data sources and their contents is a vital part of this XEP.
</li>
<li>The ability to work with massive quantities of entities.</li>
<li>Effective synchronization of contents between interested parties.</li>
<li>Effective ways to interact with entities controlled by the concentrator.</li>
</ul>
<section2topic='Relations to other extensions'>
<p>
Even though there are technologies available in forms of XEPs that solve parts of the above mentioned problem, they do not provide sufficient support. The following paragraphs will
take the time to list why different technologies are not applicable.
</p>
<section3topic='XEP-0060'>
<p>
This XEP defines tree structures for nodes in different data sources. &xep0060; defines a model where a tree structure of nodes is published and users can browse this
tree structure. Furthermore, it allows the possibility to publish items on these nodes as well as syndicalization of this information.
</p>
<p>
This XEP also defines data sources (in a tree structure). These data sources contain nodes. &xep0248; defines a structure called a node collection, a structure that
allows the creation of collections containing loosely coupled nodes.
</p>
<p>
Even though this document defines tree structures of data, it is not however based on XEP-0060. There are multiple reasons for this:
</p>
<ul>
<li>
The structures defined in this specification do not include items to publish for each node.
</li>
<li>
We want to be able to use XEP-0060 in parallel to this specification, for the purpose of publishing sensor data.
More information about this is found in <linkurl='xep-0000-SN-PubSub.html'>xep-0000-SN-PubSub.html</link>.
</li>
<li>
For massive systems (hundreds of thousands, or millions, of nodes behind a concentrator, its vitally important to be able to manage sets of nodes directly
(for example: Edit multiple nodes at once). Many of the operations in XEP-0060 only allow for operations of singular nodes. Furthermore, many simple operations
require multiple messages per node. This document defines way to operate of sets of nodes simultaneously, as well as ways to perform operations with a smaller
number of operations.
</li>
<li>
In this document, nodes have specific functions, controlled by a specific Node Type. Different Node Types have different parameter sets, different options, commands,
capabilities, etc. XEP-0060 does not differ between node types. There, nodes are only a structural way to sort data into a tree graph.
</li>
<li>
In this document, nodes have real-time status, like errors, warnings, etc.
</li>
</ul>
</section3>
<section3topic='XEP-0248'>
<p>
XEP-0248 defines the concept of node collections and syndicalization of information from nodes in these collections. But XEP-0248 is not used in this specification.
There are multiple reasons:
</p>
<ul>
<li>
We want to be able to use XEP-0248 in parallel to this specification, for the purpose of publishing sensor data.
More information about this is found in <linkurl='xep-0000-SN-PubSub.html'>xep-0000-SN-PubSub.html</link>.
</li>
<li>
Node IDs are not necessarily unique by themselves in the system. This document defines a uniqueness concept based on a triple of data: (Data Source ID, Cache Type, Node ID). This
means that Nodes must have IDs unique within a given Cache Type, within a given data source.
</li>
<li>
We need to expand on types of events generated from a data source, to make them adhere to the particulars of nodes as defined in this specification.
</li>
<li>
Data sources own their nodes. XEP-0248 define a loosely coupled structure with references to nodes. In this document, a data source is the owner of all nodes
contained in it.
</li>
</ul>
</section3>
<section3topic='XEP-0050'>
<p>
&xep0050; defines how ad-hoc commands can be implemented and how clients can use such commands to interact with underlying logic. But XEP-0050 is not used in this specification.
There are multiple reasons:
</p>
<ul>
<li>
We want to be able to use XEP-0050 for other types of commands, than commands defined in this specification. Generally, XEP-0050 is used to implement
system-wide commands.
</li>
<li>
Commands defined in this specification are context sensitive, i.e. they depend on the type of node and the context of the node on which the act.
</li>
<li>
It is a requirement to be able to execute commands on sets of nodes directly.
</li>
<li>
Since commands have to be context sensitive, a large concentrator system may have hundreds or thousands of different commands, making it impossible to create
context sensitive GUI's using XEP-0050.
</li>
<li>
Dialog types used for Ad-Hoc-commands are not sufficient. First, dynamic dialogs are required in the general case.
(XEP <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link> define how to create dynamic forms.) Furthermore, the
wizard style type of dialogs used for more complex dialogs in ad-hoc commands, are difficult to automate.
</li>
</ul>
</section3>
</section2>
<p>
Sensor networks contains many different architectures and use cases. For this reason, the sensor network standards have been divided into multiple XEPs according to the following table:
</p>
<tablecaption='Sensor Network XEPs'>
<tr>
<th>XEP</th>
<th>Description</th>
</tr>
<tr>
<td>XEP-0000-ColorParameter</td>
<td>Defines extensions for how color parameters can be handled, based on &xep0004;</td>
</tr>
<tr>
<td>XEP-0000-DynamicForms</td>
<td>Defines extensions for how dynamic forms can be created, based on &xep0004;, &xep0122;, &xep0137; and &xep0141;.</td>
</tr>
<tr>
<td>exi</td>
<td>
Defines how to EXI can be used in XMPP to achieve efficient compression of data. Albeit not a sensor network specific XEP, this XEP should be considered
in all sensor network implementations where memory and packet size is an issue.
</td>
</tr>
<tr>
<td>xep-0000-SN-BatteryPoweredSensors</td>
<td>Defines how to handle the peculiars related to battery powered devices, and other devices intermittently available on the network.</td>
</tr>
<tr>
<td>xep-0000-SN-Concentrators</td>
<td>This specification. Defines how to handle architectures containing concentrators or servers handling multiple sensors.</td>
</tr>
<tr>
<td>xep-0000-SN-Control</td>
<td>Defines how to control actuators and other devices in sensor networks.</td>
</tr>
<tr>
<td>xep-0000-SN-Discovery</td>
<td>Defines the peculiars of sensor discovery in sensor networks. Apart from discovering sensors by JID, it also defines how to discover sensors based on location, etc.</td>
</tr>
<tr>
<td>xep-0000-SN-Events</td>
<td>Defines how sensors send events, how event subscription, hysteresis levels, etc., are configured.</td>
</tr>
<tr>
<td>xep-0000-SN-Interoperability</td>
<td>Defines guidelines for how to achieve interoperability in sensor networks, publishing interoperability interfaces for different types of devices.</td>
</tr>
<tr>
<td>xep-0000-SN-Multicast</td>
<td>Defines how sensor data can be multicast in efficient ways.</td>
</tr>
<tr>
<td>sensor-network-provisioning</td>
<td>Defines how provisioning, the management of access privileges, etc., can be efficiently and easily implemented.</td>
</tr>
<tr>
<td>xep-0000-SN-PubSub</td>
<td>Defines how efficient publication of sensor data can be made in sensor networks.</td>
</tr>
<tr>
<td>sensor-data</td>
<td>
Provides the underlying architecture, basic operations and data structures for sensor data communication over XMPP networks.
It includes a hardware abstraction model, removing any technical detail implemented in underlying technologies. This XEP is used by all other sensor network XEPs.
</td>
</tr>
</table>
</section1>
<section1topic='Glossary'anchor='glossary'>
<p>The following table lists common terms and corresponding descriptions.</p>
<dl>
<di>
<dt>Actuator</dt>
<dd>Device containing at least one configurable property or output that can and should be controlled by some other entity or device.</dd>
</di>
<di>
<dt>Computed Value</dt>
<dd>A value that is computed instead of measured.</dd>
</di>
<di>
<dt>Concentrator</dt>
<dd>Device managing a set of devices which it publishes on the XMPP network.</dd>
</di>
<di>
<dt>Data Source</dt>
<dd>
A Data source contains a collection of nodes. Three types of data sources exist: Singular, Flat and Tree. Singular data sources only include one object.
Flat data sources contain a list of objects and Tree data sources contain nodes formed as a tree graph with one root element.
</dd>
</di>
<di>
<dt>Field</dt>
<dd>
One item of sensor data. Contains information about: Node, Field Name, Value, Precision, Unit, Value Type, Status, Timestamp, Localization information, etc.
Fields should be unique within the triple (Node ID, Field Name, Timestamp).
</dd>
</di>
<di>
<dt>Field Name</dt>
<dd>Name of a field of sensor data. Examples: Energy, Volume, Flow, Power, etc.</dd>
</di>
<di>
<dt>Field Type</dt>
<dd>What type of value the field represents. Examples: Momentary Value, Status Value, Identification Value, Calculated Value, Peak Value, Historical Value, etc.</dd>
</di>
<di>
<dt>Historical Value</dt>
<dd>A value stored in memory from a previous timestamp.</dd>
</di>
<di>
<dt>Identification Value</dt>
<dd>A value that can be used for identification. (Serial numbers, meter IDs, locations, names, etc.)</dd>
</di>
<di>
<dt>Localization information</dt>
<dd>Optional information for a field, allowing the sensor to control how the information should be presented to human viewers.</dd>
</di>
<di>
<dt>Meter</dt>
<dd>A device possible containing multiple sensors, used in metering applications. Examples: Electricity meter, Water Meter, Heat Meter, Cooling Meter, etc.</dd>
</di>
<di>
<dt>Momentary Value</dt>
<dd>A momentary value represents a value measured at the time of the read-out.</dd>
</di>
<di>
<dt>Node</dt>
<dd>
Graphs contain nodes and edges between nodes. In Sensor Networks, sensors, actuators, meters, devices, gateways, etc., are often depicted as nodes and links between sensors (friendships)
are depicted as edges. In abstract terms, it's easier to talk about a Node, than have to list different types of nodes possible (sensors, actuators, meters, devices, gateways, etc.).
Each Node has a Node ID. Nodes belong to a data source, and all nodes have a Node Type. Some nodes have a parent node, and some nodes have child nodes. Nodes with the same
parent nodes a called sibling nodes.
</dd>
</di>
<di>
<dt>Node ID</dt>
<dd>
An ID uniquelly identifying a node within its corresponding context. If a globally unique ID is desired, an architechture should be used using a universally accepted
ID scheme.
</dd>
</di>
<di>
<dt>Node Type</dt>
<dd>Each node has a Node Type. The Node Type defines the functionality of the node in the system.</dd>
</di>
<di>
<dt>Parameter</dt>
<dd>
Readable and/or writable property on a node/device. The XEP xep-0000-SN-Concentrators deals with reading and writing parameters
on nodes/devices. Fields are not parameters, and parameters are not fields.
</dd>
</di>
<di>
<dt>Peak Value</dt>
<dd>A maximum or minimum value during a given period.</dd>
</di>
<di>
<dt>Precision</dt>
<dd>
In physics, precision determines the number of digits of precision. In sensor networks however, this definition is not easily applicable. Instead, precision
determines, for example, the number of decimals of precision, or power of precision. Example: 123.200 MWh contains 3 decimals of precision. All entities parsing and
delivering field information in sensor networks should always retain the number of decimals in a message.
</dd>
</di>
<di>
<dt>Sensor</dt>
<dd>
Device measuring at least one digital value (0 or 1) or analog value (value with precision and physical unit). Examples: Temperature sensor, pressure sensor, etc.
Sensor values are reported as fields during read-out. Each sensor has a unique Node ID.
</dd>
</di>
<di>
<dt>SN</dt>
<dd>Sensor Network. A network consisting, but not limited to sensors, where transport and use of sensor data is of primary concern. A sensor network may contain actuators, network applications, monitors, services, etc.</dd>
</di>
<di>
<dt>Status Value</dt>
<dd>A value displaying status information about something.</dd>
</di>
<di>
<dt>Timestamp</dt>
<dd>Timestamp of value, when the value was sampled or recorded.</dd>
</di>
<di>
<dt>Token</dt>
<dd>
A client, device or user can get a token from a provisioning server. These tokens can be included in requeests to other entities in the network, so these entities can validate
access rights with the provisioning server.
</dd>
</di>
<di>
<dt>Unit</dt>
<dd>Physical unit of value. Example: MWh, l/s, etc.</dd>
</di>
<di>
<dt>Value</dt>
<dd>A field value.</dd>
</di>
<di>
<dt>Value Status</dt>
<dd>Status of field value. Contains important status information for Quality of Service purposes. Examples: Ok, Error, Warning, Time Shifted, Missing, Signed, etc.</dd>
</di>
<di>
<dt>Value Type</dt>
<dd>Can be numeric, string, boolean, Date & Time, Time Span or Enumeration.</dd>
</di>
<di>
<dt>WSN</dt>
<dd>Wireless Sensor Network, a sensor network including wireless devices.</dd>
</di>
<di>
<dt>XMPP Client</dt>
<dd>Application connected to an XMPP network, having a JID. Note that sensors, as well as applications requesting sensor data can be XMPP clients.</dd>
</di>
</dl>
</section1>
<section1topic='Use Cases'anchor='usecases'>
<p>
To create a complete set of operations supported by all types of concentrators, ranging from PLCs to subsystems to entire systems is very difficult. So, the aim
of this document is instead to create a very small reduced set of operations, a common denominator, that would allow for basic maintenance and interoperability of
concentrators of different makes and models and of these varying ranges.
</p>
<section2topic='Capabilities'>
<section3topic='Get Capabilities'>
<p>
This document lists a sequence of commands. Some are very basic, while others are used for managing massive amounts of devices. When developing a small PLC, it might
be difficult to motivate the implementation of the more advanced commands. They are simply not necessary for the management of the device. So, clients connecting to
the concentrator need a way to learn what operations are available in the concentrator, and as a consequence what operations are not. To do this, the
<strong>getCapabilities</strong> command is sent, as is shown in the following example.
So, clients who need to interact with different types of concentrators need to be aware of what commands are supported, and limit operations to those commands.
</p>
</section3>
</section2>
<section2topic='Data Sources'>
<section3topic='Get All Data Sources'>
<p>
This command will return a flat list of all available data sources on the concentrator. It is not structured hierarchically.
If the client is interested in the hierarchical structure of available data sources, it should request only the root sources, and then ask the client for their
corresponding child data sources. If the client wants to present the data sources to a user, presenting them in their hierarchical order may be more intuitive.
Multiple subscriptions to the same source will not result in an error, however the server will still only send one event message for each event in the data source.
</p>
<p>
<strong>Important:</strong> Event subscriptions only last for as long as the client and concentrator both maintain presence. The concentrator must not persist
event notification subscriptions, and if it goes offline and back online, or if the client goes offline or online again for any reason, the event subscription
is removed.
</p>
<p>
<strong>Note:</strong> The <strong>parameters</strong> and <strong>messages</strong> attributes can be used to retrieve parameter and status message information
about the nodes in event messages sent from the concentrator. Note that the <strong>xml:lang</strong> may be used to select the language used in such events,
if the concentrator supports localization of strings.
</p>
<examplecaption='Subscribing to data source events with localized parameters'>
For more information on types of events sent, see the <linkurl='#sourceevents'>Data Source Events</link> section.
</p>
</section3>
<section3topic='Unsubscribe from data source events'>
<p>
A client can unsubscribe to changes made in a data source it is subscribed to. It does this by sending the <strong>unsubscribe</strong> command to the concentrator,
as is shown in the following example:
</p>
<examplecaption='Unsubscribing from data source events'>
... Sequence of event messages sent from concentrator to client.]]>
</example>
<p>
<strong>Important:</strong> Event subscriptions only last for as long as the client and concentrator both maintain presence. The concentrator must not persist
event notification subscriptions, and if it goes offline and back online, or if the client goes offline or online again for any reason, the event subscription
is removed.
</p>
<p>
<strong>Note:</strong> The <strong>parameters</strong> and <strong>messages</strong> attributes can be used to retrieve parameter and status message information
about the nodes in event messages sent from the concentrator.
</p>
<p>
For more information on types of events sent, see the <linkurl='#sourceevents'>Data Source Events</link> section.
</p>
</section3>
</section2>
<section2topic='Nodes'>
<section3topic='Contains Node'>
<p>
This command permits the client to check the existence of a node in the concentrator.
</p>
<examplecaption='Checking the existence of a node'>
If the device does not manage too many nodes, it could choose to implement this function. It would return all available nodes with their parameters with one call.
<section3topic='Get All Nodes derived from, with Parameters'>
<p>
This command assumes node types exist in a class hierarchy, and allows the caller to retrieve nodes with similar inheritance. It also returns node parameters
directly in the response.
</p>
<examplecaption='Get All Nodes derived from, with Parameters'>
Note that the caller can list multiple classes in the request. This would return only nodes having the correct base class(es) and
implementing all interfaces.
</p>
</section3>
<section3topic='Get Node Inheritance'>
<p>
This command assumes node types exist in a class hierarchy. It allows the caller to get a list of the node class hierarchy and implemented interfaces the
<section3topic='Get Nodes from index with Parameters'>
<p>
This command can be used to get a node or nodes from a data source using an index and an index value, and also returns the parameters for the corresponding nodes.
</p>
<examplecaption='Get Nodes from index with Parameters'>
<section3topic='Get Nodes from indices with Parameters'>
<p>
This command can be used to get nodes from a set of data source using indices and index values, and also returns the parameters for the corresponding nodes.
</p>
<examplecaption='Get Nodes from indices with Parameters'>
In a tree formed data source, all nodes except the root node has a parent node. The <strong>getAncestors</strong> command allows the client to get a list
of all ancestors (parent, grand parent, etc.) of a node, as is shown in the following example:
Note that the concentrator returns information about the node itself in the response. The <strong>parameters</strong> and <strong>messages</strong>
attributes are used in the request to control if the concentrator should return node parameters and node status messages in the response as well.
</p>
</section3>
<section3topic='Move Node Up'>
<p>
As the order of siblings in a tree can be important, depending on the context and type of nodes involved, the client may be allowed to move nodes up and down among siblings.
To move a node upwards among its siblings is done using the command <strong>moveNodeUp</strong>, as is shown in the following example:
Note that a node that is first among its siblings will maintain its position. The response to the command must still be <strong>OK</strong>.
</p>
</section3>
<section3topic='Move Node Down'>
<p>
As the order of siblings in a tree can be important, depending on the context and type of nodes involved, the client may be allowed to move nodes up and down among siblings.
To move a node downwards among its siblings is done using the command <strong>moveNodeDown</strong>, as is shown in the following example:
Note that a node that is first among its siblings will maintain its position. The response to the command must still be <strong>OK</strong>. If an attempt is performed to move a
sequence of nodes that are together first as siblings, none of the nodes move relative to each other.
</p>
</section3>
<section3topic='Move Nodes Down'>
<p>
To move a set of nodes downwards among its siblings is done using the command <strong>moveNodesDown</strong>, as is shown in the following example:
Note that a node that is last among its siblings will maintain its position. The response to the command must still be <strong>OK</strong>. If an attempt is performed to move a
sequence of nodes that are together last as siblings, none of the nodes move relative to each other.
</p>
</section3>
</section2>
<section2topic='Node Parameters'>
<section3topic='Get Node Parameters for editing'>
<p>
Previously described commands can return parameters for a node. But these parameters are for presentational or informational use. If the client wants to edit
the parameters of a node, another set of commands must be used. This use case shows how <strong>getNodeParametersForEdit</strong> can be used to edit available
parameters for one node.
</p>
<p>
<strong>Note:</strong> When editing parameters for a node, a different set of parameters might be returned compared to the set of parameters available in commands
mentioned above. There may be various reasons for this, among other things (but not limited to) user rights, node settings, and parameter type. User rights may restrict the number
of parameters the user can access. The node may be configured not to allow editing of certain parameters. Also, some types of parameters may only be available in
an edit mode (like long multi-line parameters) and not in a shorter presentation mode.
</p>
<examplecaption='Get Node Parameters for editing'>
The following table lists the different XEP's the client should implement to be able to support parameter forms according to this proposal:
</p>
<tablecaption='Form XEPs'>
<tr>
<th>XEP</th>
<th>Description</th>
</tr>
<tr>
<td>XEP-0004</td>
<td>Describes how basic forms are handled.</td>
</tr>
<tr>
<td>XEP-0122</td>
<td>Makes it possible to add certain client validation rules to form parameters.</td>
</tr>
<tr>
<td>XEP-0137</td>
<td>Makes it possible to publish a file upload parameter.</td>
</tr>
<tr>
<td>XEP-0141</td>
<td>Makes it possible to layout parameters into pages and sections.</td>
</tr>
<tr>
<td>XEP-0000-ColorParameter</td>
<td>Defines extensions for how color parameters can be handled.</td>
</tr>
<tr>
<td>xep-0000-DynamicForms</td>
<td>Makes it possible to create dynamic forms, with server-side validation and forms that change dynamically depending on input.</td>
</tr>
</table>
<p>
Read-only parameters will be returned with the <strong>readOnly</strong> element, as defined in <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>.
Clients SHOULD support this extension if using this command. However, the server MUST NOT change parameters in a node that are read-only, even if clients happen
to try to set them.
</p>
</section3>
<section3topic='Set Node Parameters after editing'>
<p>
After editing the form, the client uses the <strong>setNodeParametersAfterEdit</strong> command to set the parameters in the node. Note that it is possible to
set the same parameters (or a sub-set of the same parameters) to a different node using this command, without the need to get new form parameters. However, after the first
successful set operation, any form session used for dynamic validation during edit will not be available on the server any more.
</p>
<examplecaption='Set Node Parameters after editing'>
Note that validation rules, pagination, etc., can be stripped from the form when submitting it to the server. Also the form type attribute must be set
to <strong>'submit'</strong>. Note also that as the <strong>result</strong> attribute is <strong>OK</strong>, it is assumed the server has dropped any parameter form resources
related to the form, which disables any future dynamic validation of the contents of the form. The newly edited node will also be available in the response
in a <strong>node</strong> element.
</p>
</section3>
<section3topic='Set Node Parameters after editing, Failure'>
<p>
The following example shows how the server responds when the client tries to set invalid parameters. The response contains detailed information about why,
information which the client can use to inform the user (if any) of what went wrong.
</p>
<examplecaption='Set Node Parameters after editing, Failure'>
<errorvar='id'>There already exists a node with this ID.</error>
</setNodeParametersAfterEditResponse>
</iq>]]>
</example>
<p>
As the <strong>result</strong> attribute is <strong>FormError</strong>, the server maintains any parameter form resources related to the form, and features such as
dynamic validation of the contents of the form will still be available until the parameters have been successfully set, the operation has been
explicitly cancelled or a form session time-out has occurred. See <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>
<note>
XEP-xxxx: Dynamic Data Forms <<linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link>>
</note> for more information.
</p>
</section3>
<section3topic='Get Common Node Parameters for editing'>
<p>
Advanced concentrators handling large quantities of nodes may let users edit sets of nodes at once to be practical. This is done by publishing the
<strong>getCommonNodeParametersForEdit</strong> command. It will return a form with parameters that are common for all selected nodes. Since nodes
may have different node types it is assumed that different nodes have different sets of parameters. But if this command is used, only parameters matching
in IDs, descriptions, validation rules, etc., (but not values) will be returned in a form.
</p>
<p>
<strong>Important:</strong> A parameter that exists in multiple nodes, but has different parameter values among the nodes, will be marked with the
<strong>notSame</strong> element, according to <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>. Clients using this command MUST
support the extensions defined in <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>.
</p>
<examplecaption='Get Common Node Parameters for editing'>
Note that parameters that are not available in all selected nodes will have been removed. Also and ID-parameter will have been removed, since they
cannot be set for a collection of nodes.
</p>
<p>
Fields marked with the <strong>notSame</strong> element only present one value, perhaps the value of the first node. However, the field should be clearly
marked in any end-user GUI (for example by graying the field), and MUST ONLY be sent back to the server in a set operation if explicitly edited by the end-user.
The parameter will be set in all selected nodes in that case. Unedited fields should be treated as if the end-user accepts the different values for the current set of nodes.
</p>
</section3>
<section3topic='Set Common Node Parameters after editing'>
<p>
After editing the form, the client uses the <strong>setCommonNodeParametersAfterEdit</strong> command to set the parameters in the set of nodes. Note that it is possible to
set the same parameters (or a sub-set of the same parameters) to a different set of nodes using this command, without the need to get new form parameters. However, after the first
successful set operation, any form session used for dynamic validation during edit will not be available on the server any more.
</p>
<examplecaption='Set Common Node Parameters after editing'>
Note that validation rules, pagination, etc., can be stripped from the form when submitting it to the server. Also the form type attribute must be set
to <strong>'submit'</strong>. Note also that as the <strong>result</strong> attribute is <strong>OK</strong>, it is assumed the server has dropped any parameter form resources
related to the form, which disables any future dynamic validation of the contents of the form.
</p>
<p>
<strong>Important:</strong> A parameter that exists in multiple nodes, but has different parameter values among the nodes, will be marked with the
<strong>notSame</strong> element, according to <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>. Such parameters MUST NOT be sent back to the server
unless they have explicitly been edited or signed by the end-user. The value sent back to the server will be set in all nodes.
</p>
</section3>
<section3topic='Set Common Node Parameters after editing, Failure'>
<p>
The following example shows how the server responds when the client tries to set invalid parameters to a set of nodes. The response contains detailed information about why,
information which the client can use to inform the user (if any) of what went wrong.
</p>
<examplecaption='Set Node Parameters after editing, Failure'>
As the <strong>result</strong> attribute is <strong>FormError</strong>, the server maintains any parameter form resources related to the form, and features such as
dynamic validation of the contents of the form will still be available until the parameters have been successfully set, the operation has been
explicitly cancelled or a form session time-out has occurred. See <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>
<linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link> for more information.
</p>
</section3>
<section3topic='Get Node Status'>
<p>
Each node in the concentrator has a <strong>state</strong>. This state is a dynamic run-time state, and therefore not presented as a more static property.
This state can be any of the following values, in order of increasing importance:
</p>
<tablecaption='Node states'>
<tr>
<th>State</th>
<th>Description</th>
</tr>
<tr>
<td>None</td>
<td>Nothing has been reported on the node.</td>
</tr>
<tr>
<td>Information</td>
<td>There are informative events reported on the node.</td>
</tr>
<tr>
<td>WarningSigned</td>
<td>There are warnings reported on the node. But these warnings have been viewed by an operator.</td>
</tr>
<tr>
<td>WarningUnsigned</td>
<td>There are new or unreviewed warnings reported on the node.</td>
</tr>
<tr>
<td>ErrorSigned</td>
<td>There are errors reported on the node. But these errors have been viewed by an operator.</td>
</tr>
<tr>
<td>ErrorUnsigned</td>
<td>There are new or unreviewed errors reported on the node.</td>
</tr>
</table>
<p>
Other types of "states" are of course possible, such as phase - installation phase, test phase, production phase, etc. - but such "states" are seen as static
and presented as parameters on the node. The purpose of the dynamic state attribute of a node, is to give a dynamic runtime state that has
the possibility to change during runtime, which operators must be aware of.
</p>
<p>
The following commands have an optional attribute <strong>messages</strong>, with which they can ask the server to return any events logged on the node, giving more details of the
<messagetimestamp='2013-03-21T11:06:15'type='WarningUnsigned'id='ClockWarning'>Internal clock is offset more than 7 seconds.</message>
</getNodeResponse>
</iq>]]>
</example>
</section3>
</section2>
<section2topic='Creating and Destroying Nodes'>
<section3topic='Get Addable Node Types'>
<p>
Since nodes are context sensitive, depending on node type and tree structure, before being able to create a new node, it is important to know what types of nodes
that can be added to a given node. This is done using the <strong>getAddableNodeTypes</strong> command, as is shown in the following example:
When you know what type of node you want to create, you need to get a set of parameters you need to fill in for the new node, before you can create it.
This is done using the <strong>getParametersForNewNode</strong> command, as is shown in the following example:
Note that validation rules, pagination, etc., can be stripped from the form when submitting it to the server. Also the form type attribute must be set
to <strong>'submit'</strong>. Note also that as the <strong>result</strong> attribute is <strong>OK</strong>, it is assumed the server has dropped any parameter form resources
related to the form, which disables any future dynamic validation of the contents of the form. The newly created node with corresponding parameters is also returned
in the response in a <strong>node</strong> element.
</p>
</section3>
<section3topic='Create New Node, Failure'>
<p>
The following example shows how the server responds when it cannot accept parameters provided when trying to create a node. The response will contain detailed information
about why, information which the client can use to inform the user (if any) of what went wrong.
<errorvar='id'>There already exists a node with this ID.</error>
<errorvar='referenceId'>Referenced node was not found.</error>
</createNewNodeResponse>
</iq>]]>
</example>
<p>
As the <strong>result</strong> attribute is <strong>FormError</strong>, the server maintains any parameter form resources related to the form, and features such as
dynamic validation of the contents of the form will still be available until the parameters have been successfully set, the operation has been
explicitly cancelled or a form session time-out has occurred. See <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>
<linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link> for more information.
</p>
</section3>
<section3topic='Destroy Node'>
<p>
To destroy (remove) a node from the concentrator, the <strong>destroyNode</strong> command is sent, as is shown in the following example:
failureString='Unable to schedule the wakeup call.'
successString='Wakeup call scheduled.'/>
</getNodeCommandsResponse>
</iq>]]>
</example>
<p>
There are two types of commands available: <strong>Simple</strong> and <strong>Parameterized</strong>. <strong>Simple</strong> commands take no parameters, and
are therefore simpler to execute. <strong>Parameterized</strong> commands require the client to get a set of parameters for the corresponding command before it
can be executed. For more information about command attributes, see <linkurl='#nodecommands'>Node Commands</link>.
</p>
</section3>
<section3topic='Execute Simple Node Command'>
<p>
Executing a simple command is done by sending the <strong>executeNodeCommand</strong> command to the concentrator, as is shown in the following example:
To execute a parameterized command on the node, the client first needs to get (and edit) a set of parameters for the command. Getting a set of parameters for a
Executing a parameterized command is also done by sending the <strong>executeNodeCommand</strong> command to the concentrator, but including the edited form parameters,
If an error occurs during the execution of a command or if the server rejects the execution of a command, the server returns a response code different from
<strong>OK</strong>. If the response code is <strong>FormError</strong>, the server maintains any parameter form resources related to the form, and features such as
dynamic validation of the contents of the form will still be available until the parameters have been successfully set, the operation has been
explicitly cancelled or a form session time-out has occurred. See <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>
<linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link> for more information.
<section3topic='Get Common Command Parameters from command on multiple nodes'>
<p>
To execute a parameterized command on a set of nodes, the client first needs to get (and edit) a set of parameters for the common command. Getting a set of parameters for a
common parameterized command is done as follows:
</p>
<examplecaption='Get Common Command Parameters from command on multiple nodes'>
<section3topic='Execute Common Parameterized Command on multiple nodes'>
<p>
Executing a common parameterized command is also done by sending the <strong>executeCommonNodeCommand</strong> command to the concentrator, but including the edited form parameters,
as is shown in the following example:
</p>
<examplecaption='Execute Common Parameterized Command on multiple nodes'>
<section3topic='Execute Parameterized Command on Multiple Nodes, Failure'>
<p>
If an error occurs during the execution of a common command or if the server rejects the execution of a common command, the server returns a response code different from
<strong>OK</strong>. If the response code is <strong>FormError</strong>, the server maintains any parameter form resources related to the form, and features such as
dynamic validation of the contents of the form will still be available until the parameters have been successfully set, the operation has been
explicitly cancelled or a form session time-out has occurred. See <linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms</link>
<linkurl='xep-0000-DynamicForms.html'>xep-0000-DynamicForms.html</link> for more information.
</p>
<examplecaption='Execute Parameterized Command on Multiple Nodes, Failure'>
<errorvar='mode'>You are not allowed to harass people at 04:30:00!</error>
</executeCommonNodeCommandResponse>
</iq>]]>
</example>
</section3>
<section3topic='Execute Command on Multiple Nodes, Partial Failure'>
<p>
When executing a command, simple or parameterized, on multiple nodes, it might happen that the command fails on some nodes, but not on others, even though
any parameters are validated beforehand. Therefore, the client needs to check any <strong>result</strong> elements in the response, even though the
response code is <strong>OK</strong>.
</p>
<p>
The following example shows the execution of a parameterized command on multiple nodes that fail on some nodes but are executed on others.
</p>
<examplecaption='Execute Command on Multiple Nodes, Partial Failure'>
Events are asynchronous messages sent from the concentrator to devices registered with the concentrator and having subscribed to events from the concentrator.
<linkurl='#subscribe'>Event subscription</link> can be activated using the <strong>subscribe</strong> command. You can also <linkurl='#subscribe2'>retrieve historical events</link>
using the <strong>subscribe</strong> command.
</p>
<p>
Each event is sent from the concentrator to each subscriber using a <strong>message</strong> stanza. Each such <strong>message</strong> stanza may contain multiple
events. The following subsections list the different types of events that can be sent. Even though these examples may list only one element in a message stanza, this
is not a limitation. Different types of events may also be mixed within the message stanza.
</p>
<p>
Event subscriptions only last for as long as the client and concentrator both maintains presence. The concentrator must not persist
event notification subscriptions, and if it goes offline and back online, or if the client goes offline or online again for any reason, the event subscription
is removed.
</p>
<p>
Node events may contain parameters or status messages. This depends on how the subscription was made. The <strong>parameters</strong> and <strong>messages</strong> attributes
in the <strong>subscribe</strong> command determine if node parameters and/or status messages should be sent in event messages.
</p>
<section3topic='Node added event'>
<p>
The <strong>nodeAdded</strong> event is sent when a node has been added to a data source which the client subscribes to. The following example
shows how such an event message may look like:
</p>
<examplecaption='Node added event, without parameters'>
<strong>Note:</strong> Moving a node in a data source from one parent to another, possibly between different data sources, is performed by first
removing it from the current source (sending a <strong>nodeRemoved</strong> event) and then adding it to the new data source (sending a <strong>nodeAdded</strong>
event), in that order.
</p>
</section3>
<section3topic='Node removed'>
<p>
The <strong>nodeRemoved</strong> event is sent when a node in a data source has been removed or destroyed. It does not include status message or parameter
information about the node, only the reference to the node. The following example shows how such an event message may look like:
<strong>Note:</strong> Moving a node in a data source from one parent to another, possibly between different data sources, is performed by first
removing it from the current source (sending a <strong>nodeRemoved</strong> event) and then adding it to the new data source (sending a <strong>nodeAdded</strong>
event), in that order.
</p>
</section3>
<section3topic='Node updated'>
<p>
The <strong>nodeUpdated</strong> event is sent when a node has been updated in a data source which the client subscribes to. The following example
shows how such an event message may look like:
</p>
<examplecaption='Node updated event, without parameters'>
<strong>Note: </strong>If only the status has changed, and no other parameters have changed, the <linkurl='#nodeStatusChanged'>nodeStatusChanged</link>
event could be sent instead, for somewhat improved performance in this case.
</p>
</section3>
<section3topic='Node status changed'anchor='#nodeStatusChanged'>
<p>
The <strong>nodeStatusChanged</strong> event is sent when the <linkurl='#nodestates'>state of the node</link> has changed, but no other parameters have been changed.
If the client has subscribed to state messages, these will also be included in the event.
</p>
<examplecaption='Node status changed event, without messages'>
<messagetimestamp='2013-03-22T12:49:34'type='Error'>Sensor does not respond to read-out requests.</message>
</nodeStatusChanged>
</message>]]>
</example>
</section3>
<section3topic='Node moved up'>
<p>
The <strong>nodeMovedUp</strong> event is sent when a node in a data source has been moved up among its siblings. It does not include status message or parameter
information about the node, only the reference to the node. The following example shows how such an event message may look like:
<strong>Note:</strong> If issuing a <strong>moveNodeUp</strong> command on a node that is already first among its siblings, the node is not moved and the
concentrator must not send a <strong>nodeMovedUp</strong> event. However, if the client receives such an event pointing to a node that is already first among
its siblings, it should not move the node.
</p>
</section3>
<section3topic='Node moved down'>
<p>
The <strong>nodeMovedDown</strong> event is sent when a node in a data source has been moved down among its siblings. It does not include status message or parameter
information about the node, only the reference to the node. The following example shows how such an event message may look like:
<strong>Note:</strong> If issuing a <strong>moveNodeDown</strong> command on a node that is already last among its siblings, the node is not moved and the
concentrator must not send a <strong>nodeMovedDown</strong> event. However, if the client receives such an event pointing to a node that is already last among
its siblings, it should not move the node.
</p>
</section3>
</section2>
<section2topic='Field Databases'>
<p>
A concentrator can often store data from sensors locally (or remotely but controlled locally). Storage is done in <strong>field databases</strong>. A concentrator with
only communicative abilities will publish zero such field databases (and support for none of the field database commands), while a pure metering database will publish
one or many field databases, but none of the nodes available in any of the different data sources are readable or writable. The nodes in this latter case only acts as
placeholders for the data that the concentrator is storing or controlling.
</p>
<p>
The following subsections lists different use cases relating to field databases and how to use them.
</p>
<section3topic='Get All Databases'>
<p>
The client can retrieve the list of available databases on the concentrator using the <strong>getDatabases</strong> command, as is shown in the following example:
<desc>This parameter specifies how multiple status flags are to be treated in the readout.</desc>
<value>Any</value>
<optionlabel='Any'><value>Any of the conditions above are met.</value></option>
<optionlabel='All'><value>All of the conditions above are met.</value></option>
</field>
</x>
</getDatabaseReadoutParametersResponse>
</iq>]]>
</example>
</section3>
<section3topic='Start Database Readout'>
<p>
Once the parameter form has been filled out, a database readout can be started using the <strong>startDatabaseReadout</strong> command.
Data read from the concentrator will follow the same flow of sensor data as that described in <linkurl='sensor-data.html'>sensor-data</link>
<note>
XEP-xxxx: Sensor Data <linkurl='sensor-data.html'>sensor-data</link>
</note>. The only difference is that the read-out is started with the <strong>startDatabaseReadout</strong> command instead of the <strong>req</strong>
command of the sensor data namespace.
</p>
<p>
The following diagram shows the flow of messages when requesting a readout from a database:
<td>If provided, a string presentable to users. If localization is supported and a correct language attribute was provided, this string will be localized.</td>
<td>Used to uniquely identify the node in sources where the ID of the node is not sufficient. Example: In a spatial ordering different nodes may represent
countries, regions, cities, areas, streets, buildings and apartments in the same source. However, the ID of each node would depend on what type of node it
represents. It might be valid to have a region, city and/or area with the same ID. So, to these circumstances, a Cache Type of Country, Region, City, Area,
Street, Building and Apartment can be used to allow for non-unique IDs within the source, as long as they are unique within the same cache type. ***</td>
<td>If the children of the node have an intrinsic order (true), or if the order is not important (false). If the order is not important, the client
can present the order as it wishes, for example sorted on Node ID or any other parameter available on the child nodes. However, if the children have an
intrinsic order, it's important for the client to refresh the child list when necessary whenever the order is unknown, such as after a nodeAdded event or
a nodeRemoved event.
</td>
</tr>
<tr>
<td>isReadable</td>
<td>optional</td>
<td>false</td>
<td>If the node can be read. (*)</td>
</tr>
<tr>
<td>isConfigurable</td>
<td>optional</td>
<td>false</td>
<td>If the node can be configured. (**)</td>
</tr>
<tr>
<td>hasCommands</td>
<td>optional</td>
<td>false</td>
<td>If the node has registered commands or not.</td>
<td>When the node was last changed. Can be used by clients to synchronize content between the concentrator and itself.</td>
</tr>
</table>
<p>
(*) See <linkurl='sensor-data.html'>sensor-data</link> for more information about how to read nodes.
</p>
<p>
(**) See <linkurl='xep-0000-SN-Control.html'>xep-0000-SN-Control</link> for more information about how to configure nodes.
</p>
<p>
(***) Note that <strong>cacheType</strong> is optional. In some data sources it might be necessary to include a cache type to allow for IDs that are not unique
within the source. In these cases, it concentrator must include the cacheType attribute for nodes in the corresponding data source, and clients must use the corresponding
cacheType value when referencing the node. But if such a separation of IDs within a source is not required, the concentrator may ignore the cacheType attribute.
In these instances clients may also ignore the cacheType attribute when referencing the nodes in the corresponding data source, or use the empty string as value for the
cacheType value. The server must ignore empty cacheType values for data sources not using a cache type separation mechanism.
</p>
</section2>
<section2topic='Parameter Types'>
<p>
Nodes can report parameters of different types. The following table lists available parameter types.
</p>
<tablecaption='Parameter Types'>
<tr>
<th>Element Name</th>
<th>Parameter Value</th>
</tr>
<tr>
<td>boolean</td>
<td>Boolean values. Can be true or false.</td>
</tr>
<tr>
<td>color</td>
<td>Color values. They are strings containing 6 case-insensitive hexadecimal digits of the form RRGGBB, where RR=Red component, GG=Green component, BB=Blue component.</td>
</tr>
<tr>
<td>dateTime</td>
<td>Date and time value, with possible time zone information.</td>
</tr>
<tr>
<td>double</td>
<td>double precision floating point value.</td>
</tr>
<tr>
<td>duration</td>
<td>A time duration value.</td>
</tr>
<tr>
<td>int</td>
<td>A 32-bit integer value.</td>
</tr>
<tr>
<td>long</td>
<td>A 64-bit integer value.</td>
</tr>
<tr>
<td>string</td>
<td>A string value.</td>
</tr>
<tr>
<td>time</td>
<td>A time value using a 24-hour clock.</td>
</tr>
</table>
</section2>
<section2topic='Response Codes'>
<p>
All responses have a response code that the client is required to check. The following table lists possible response codes and their corresponding meanings.
</p>
<tablecaption='Response Codes'>
<tr>
<th>Response Code</th>
<th>Description</th>
</tr>
<tr>
<td>OK</td>
<td>Request is OK and accepted.</td>
</tr>
<tr>
<td>NotFound</td>
<td>Corresponding object, node, etc., was not found.</td>
</tr>
<tr>
<td>InsufficientPrivileges</td>
<td>Insufficient privileges to perform the corresponding action or execute the corresponding command. Make sure to provide sufficient credentials in the call
(user, service, device tokens) with sufficient privileges to perform the action/command.</td>
</tr>
<tr>
<td>Locked</td>
<td>The object/node is locked, and operation could not be performed or completed.</td>
</tr>
<tr>
<td>NotImplemented</td>
<td>Command is not implemented.</td>
</tr>
<tr>
<td>FormError</td>
<td>The form send to the concentrator contains errors. The response contains detailed error information.</td>
</tr>
<tr>
<td>OtherError</td>
<td>Another error occurred.</td>
</tr>
</table>
</section2>
<section2topic='Unimplemented commands'>
<p>
It's important that the concentrator responds to unrecognized commands. This, to make sure future extensions to this document does not produce unexpected
results in concentrators implementing a previous version, or in concentrators implementing only a subset of available commands.
</p>
<p>
When a concentrator receives an element that it does not understand, it must do as follows:
</p>
<ul>
<li>If the element is received in a message stanza, the element must be ignored.</li>
<li>If the element is received in an iq-result stanza, the element must be ignored.</li>
<li>If the element is received in an iq-get or iq-set stanza, an iq-result stanza must be composed containing an element with the same name as the incoming
element, but with <strong>Response</strong> appended to it, having a response code of <strong>NotImplemented</strong>.</li>
</ul>
<p>
The following example shows how unrecognized commands must be handled by the concentrator:
Node commands have a set of attributes. The following table lists available attributes and what they mean.
</p>
<tablecaption='Command attributes'>
<tr>
<th>Attribute</th>
<th>Use</th>
<th>Description</th>
</tr>
<tr>
<td>id</td>
<td>required</td>
<td>ID of the command. Used to identify the command.</td>
</tr>
<tr>
<td>name</td>
<td>required</td>
<td>A string that can be presented to an end-user. Should be localized if the request contained a language preference.</td>
</tr>
<tr>
<td>type</td>
<td>required</td>
<td>If the command is 'Simple' or 'Parameterized'.</td>
</tr>
<tr>
<td>sortCategory</td>
<td>optional</td>
<td>Should be used (if available) by clients to sort available node commands before presenting them to an end-user. Commands should be sorted by Sort Category, Sort Key and
lastly by Name.</td>
</tr>
<tr>
<td>sortKey</td>
<td>optional</td>
<td>
Should be used (if available) by clients to sort available node commands before presenting them to an end-user. Commands should be sorted by Sort Category, Sort Key and
lastly by Name.
</td>
</tr>
<tr>
<td>confirmationString</td>
<td>optional</td>
<td>Should presented to clients (if available) before letting an end-user execute the command. A delete command might have a confirmationString saying
'Are you sure you want to delete the current item?' The confirmation string should be presented as a Yes/No[/Cancel] dialog.</td>
</tr>
<tr>
<td>failureString</td>
<td>optional</td>
<td>
Could be presented to end-users (if available) if a command fails. It provides the client with an optionally localized string giving some context to the error message.
A delete command might have a failureString saying 'Unable to delete the current item.'. The client could then add additional error information, if available,
for instance from the response code.
</td>
</tr>
<tr>
<td>successString</td>
<td>optional</td>
<td>
Could be presented to end-users (if available) if a command is successfully executed. It provides the client with an optionally localized string giving some context
to the message. A delete command might have a successString saying 'Current item successfully deleted.'.
</td>
</tr>
</table>
</section2>
<section2topic='Node States'>
<p>
Nodes can be in different states. Even though nodes are free to publish any amount of states as parameters, there are a set of states that are so crucial to the
concept of a node state, that they are published using a separate attribute and separate events. These node states are as follows:
</p>
<tablecaption='Node States'>
<tr>
<th>State</th>
<th>Description</th>
</tr>
<tr>
<td>None</td>
<td>The node has nothing special to report.</td>
</tr>
<tr>
<td>Information</td>
<td>The node has informative events reported on it.</td>
</tr>
<tr>
<td>WarningSigned</td>
<td>The node has warnings reported on it. These warnings have been viewed by an operator.</td>
</tr>
<tr>
<td>WarningUnsigned</td>
<td>The node has warnings reported on it that have not been viewed by anybody.</td>
</tr>
<tr>
<td>ErrorSigned</td>
<td>The node has errors reported on it. These errors have been viewed by an operator.</td>
</tr>
<tr>
<td>ErrorUnsigned</td>
<td>The node has errors reported on it that have not been viewed by anybody.</td>
</tr>
</table>
</section2>
<section2topic='Required Data Sources'>
<p>
The following table lists required data sources for concentrators (of sensors, actuators, meters, etc.) in sensor networks:
</p>
<tablecaption='Required Data Sources'>
<tr>
<th>Data Source</th>
<th>Description</th>
</tr>
<tr>
<td>MeteringTopology</td>
<td>Data Source containing the topology of metering devices, including sensors, actuators, meter, infrastructure components, etc.</td>
</tr>
</table>
<p>
More information can be found in the <note>XEP-xxxx: Interoperability <linkurl='#interop'>Interoperability section</link></note>.
Localization of content can be performed if clients provide <strong>xml:lang</strong> attributes in commands made to the concentrator. If omitted, the
<strong>default language</strong> will be used in responses. If provided, but the concentrator does not support localization, or the requested language,
the <strong>default language</strong> will also be used.
</p>
</section2>
<section2topic='Time Zones'>
<p>
Concentrators of larger sub-systems spanning multiple time-zones should specify all timestamps with time-zone information, so readers can perform comparisons
of time information.
</p>
<p>
Information read from a concentrator that lacks time-zone information should be considered to lie in the same time-zone as the reader, unless not explicitly
This document publishes a lot of commands with which to interact with a concentrator. If security and access rights is an issue, it might not be sufficient
to allow all friends access to the system. There are many ways in which to restrict access to the contents of the concentrator. Following are some examples:
</p>
<ul>
<li>
The concentrator can restrict friendships to trusted friends, and then assign access rights internally to the approved contacts.
</li>
<li>
The concentrator can use a provisioning server (see <note>XEP-xxxx: Provisioning <linkurl='sensor-network-provisioning.html'>sensor-network-provisioning</link></note>)
to delegate trust to a third party responsible for controlling who can get access to the concentrator (<strong>isFriend</strong> or <strong>canAccess</strong> commands),
and what items can be viewed (<strong>hasPrivilege</strong> or <strong>downloadPrivileges</strong> commands).
</li>
<li>
All requests to the concentrator can contain the optional attributes <strong>deviceToken</strong>, <strong>serviceToken</strong> and <strong>userToken</strong>.
Clients making requests to the concentrator can use these attributes to forward information about who originated the action (<strong>userToken</strong>),
what service is performing the action (<strong>serviceToken</strong>) or what device is performing the action (<strong>deviceToken</strong>). The concentrator
can use this information to check with provisioning servers what access rights and user privileges exist before performing the action.
</li>
</ul>
</section2>
<section2topic='Integration with provisioning servers'>
<p>
The <linkurl='sensor-network-provisioning.html'>sensor-network-provisioning</link> document describes how trust can be delegated to trusted provisioning servers
that can be used to restrict access to and privileges in a network.
</p>
<p>
If a concentrator has a trusted relationship with a provisioning server, external or internal, the provisioning server must be used to guarantee that the
concetrator only allows access according to rules defiend by the provisioning server. In order to do this, it's important that clients always provide
available tokens (<strong>userToken</strong>, <strong>serviceToken</strong> and <strong>deviceToken</strong>) to the concentrator so that it can forward this
information to the provisioning server.
</p>
<p>
The following subsections show different examples of how such an integration can be performed.
</p>
<section3topic='Restricting access to data source per contact'>
<p>
This section shows how a provisioning server can be used to restrict access to data sources to users allowed to access those data sources.
The user has a <strong>userToken</strong> it received during <linkurl='sensor-network-provisioning#usertoken'>connection with the service</link>. This user token should
be included in all calls made by the user.
</li>
<li>
The service has a <strong>serviceToken</strong> it received during <linkurl='sensor-network-provisioning#servicetoken'>service registration</link>. This service token
should be aggregated by all calls made by the service.
</li>
<li>
The concentrators should cache all calls made to the provisioning server according to available <linkurl='sensor-network-provisioning#cache'>cache rules</link>.
</li>
<li>
The conversion of a Data Source ID to a Privilege ID should be performed according to rules defined in <linkurl='xep-0000-SN-Interoperability.html'>xep-0000-SN-Interoperability</link>.
</li>
</ul>
</section3>
<section3topic='Restricting access to node properties per contact'>
<p>
This section shows how a provisioning server can be used to restrict access to node parameters that users allowed to access and edit.
Not that privileges for all parameters needs to be checked in every call. And if lost from the cache, a new request needs to be made to the provisioning server.
</li>
<li>
The conversion of a Parameter ID (and Page) to a Privilege ID should be performed according to rules defined in
In addition to rules noted above, also notice the following:
</p>
<ul>
<li>
Not that privileges for all parameters needs to be checked in every call. And if lost from the cache, a new request needs to be made to the provisioning server.
</li>
<li>
The conversion of a Command ID to a Privilege ID should be performed according to rules defined in <linkurl='xep-0000-SN-Interoperability.html'>xep-0000-SN-Interoperability</link>.