-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxep-0325.xml
1936 lines (1901 loc) · 82.8 KB
/
xep-0325.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
<!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
<title>Internet of Things - Control</title>
<abstract>
Note: This specification has been retracted by the author; new
implementations are not recommended.
This specification describes how to control devices or actuators in an
XMPP-based sensor network.
</abstract>
&LEGALNOTICE;
<number>0325</number>
<status>Retracted</status>
<type>Standards Track</type>
<sig>Standards</sig>
<approver>Council</approver>
<dependencies>
<spec>XEP-0001</spec>
<spec>XEP-0004</spec>
<spec>XEP-0030</spec>
<spec>XEP-0122</spec>
<spec>XEP-0137</spec>
<spec>XEP-0141</spec>
<spec>XEP-0323</spec>
<spec>XEP-0324</spec>
<spec>XEP-0331</spec>
<spec>XEP-0336</spec>
</dependencies>
<supersedes/>
<supersededby/>
<shortname>sensor-network-control</shortname>
&peterwaher;
<revision>
<version>0.5.1</version>
<date>2021-03-04</date>
<initials>mw</initials>
<remark><p>Cross-document editorial adjustments for inclusive language.</p></remark>
</revision>
<revision>
<version>0.5</version>
<date>2017-05-20</date>
<initials>XEP Editor: ssw</initials>
<remark>Mark XEP as retracted by the author.</remark>
</revision>
<revision>
<version>0.4</version>
<date>2015-11-09</date>
<initials>psa</initials>
<remark>
<p>Updated contact information.</p>
<p>Updated example JIDs to example.org</p>
</remark>
</revision>
<revision>
<version>0.3</version>
<date>2014-04-07</date>
<initials>pw</initials>
<remark>
<p>Response codes have been removed and replaced by XMPP compliant IQ error stanzas. The table below shows how old status codes map to XMPP IQ error elements.</p>
<p>The <strong>getFormResponse</strong> element has been removed.</p>
<p>The <strong>setResponse</strong> is now only used when configuration is successful.</p>
<p>The <strong>parameter</strong> subelement to <strong>setResponse</strong> has been reintroduced. Examples are provided in XEP-0324.</p>
<p>The element <strong>paramError</strong> has been introduced, and can be used to provide error information that are linked to control parameters.</p>
<p>Added anchors to all second level subsections.</p>
<p>The section 'Reading current control states' has been updated to include two methods: One simple method only using control forms, and a second, using Sensor Data (XEP-0323).</p>
<p>Harmonization of data types between XEP-0323 and XEP-0325.</p>
<p>The attribute <strong>writable</strong> used to correlate fields in XEP-0323 with control parameters is described.</p>
</remark>
</revision>
<revision>
<version>0.2</version>
<date>2014-03-10</date>
<initials>pw</initials>
<remark>
<p>Namespace in dynamic form examples has been changed to urn:xmpp:xdata:dynamic.</p>
<p>Corrected the namespace used for parameterGroup elements in the examples of the document.</p>
<p>Added support for color values with alpha channel.</p>
<p>Updated the schema to more strictly validate references to x-data forms.</p>
<p>Schema was updated to reflect the correct relationship between the x-data subelement in a set operation.</p>
<p>Fixed links to documents with new numbers.</p>
<p>Changed namespace urn:xmpp:sn to urn:xmpp:iot</p>
<p>Schema was corrected: The parameter sub-element in the setResponse element was removed.</p>
</remark>
</revision>
<revision>
<version>0.1</version>
<date>2013-05-06</date>
<initials>psa</initials>
<remark>
<p>Initial published version approved by the XMPP Council.</p>
</remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2013-03-27</date>
<initials>pw</initials>
<remark>
<p>First draft.</p>
</remark>
</revision>
</header>
<section1 topic='Introduction' anchor='intro'>
<p>
Actuators are devices in sensor networks that can be controlled through the network and act with the outside world. In sensor networks and Internet of Things applications,
actuators make it possible to automate real-world processes. This document defines a mechanism whereby actuators can be controlled in XMPP-based sensor networks, making it
possible to integrate sensors and actuators of different brands, makes and models into larger Internet of Things applications.
</p>
<p>
Note has to be taken, that these XEP's are designed for implementation in sensors, many of which have very limited amount of memory (both RAM and ROM) or resources (processing power).
Therefore, simplicity is of utmost importance. Furthermore, sensor networks can become huge, easily with millions of devices in peer-to-peer networks.
</p>
<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>
<table caption='Sensor Network XEPs'>
<tr>
<th>XEP</th>
<th>Description</th>
</tr>
<tr>
<td>xep-0000-IoT-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-IoT-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-IoT-Events</td>
<td>Defines how sensors send events, how event subscription, hysteresis levels, etc., are configured.</td>
</tr>
<tr>
<td>xep-0000-IoT-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-IoT-Multicast</td>
<td>Defines how sensor data can be multicast in efficient ways.</td>
</tr>
<tr>
<td>xep-0000-IoT-PubSub</td>
<td>Defines how efficient publication of sensor data can be made in sensor networks.</td>
</tr>
<tr>
<td>xep-0000-IoT-Chat</td>
<td>Defines how human-to-machine interfaces should be constructed using chat messages to be user friendly, automatable and consistent with other IoT extensions and possible underlying architecture.</td>
</tr>
<tr>
<td>XEP-0322</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-0323</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>
<tr>
<td>XEP-0324</td>
<td>Defines how provisioning, the management of access privileges, etc., can be efficiently and easily implemented.</td>
</tr>
<tr>
<td>XEP-0325</td>
<td>This specification. Defines how to control actuators and other devices in Internet of Things.</td>
</tr>
<tr>
<td>XEP-0326</td>
<td>Defines how to handle architectures containing concentrators or servers handling multiple sensors.</td>
</tr>
<tr>
<td>XEP-0331</td>
<td>Defines extensions for how color parameters can be handled, based on &xep0004;</td>
</tr>
<tr>
<td>XEP-0336</td>
<td>Defines extensions for how dynamic forms can be created, based on &xep0004;, &xep0122;, &xep0137; and &xep0141;.</td>
</tr>
</table>
</section1>
<section1 topic='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>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 Internet of Things, sensors, actuators, meters, devices, gatewats, etc., are often depicted as nodes whereas links between sensors (friendships)
are depicted as edges. In abstract terms, it's easier to talk about a Node, rather than list different possible node types (sensors, actuators, meters, devices, gateways, etc.).
Each Node has a Node ID.
</dd>
</di>
<di>
<dt>Node ID</dt>
<dd>
An ID uniquely identifying a node within its corresponding context. If a globally unique ID is desired, an architecture should be used using a universally accepted
ID scheme.
</dd>
</di>
<di>
<dt>Parameter</dt>
<dd>
Readable and/or writable property on a node/device. The XEP-0326 &xep0326; 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 requests 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>
<section1 topic='Use Cases' anchor='usecases'>
<p>
Control in sensor networks is about setting output values. To make the implementation simple, it is assumed that control of a device can be made using a single message.
If only a simple set operation is requested, a <message> stanza can be sent. If an acknowledgement (ACK) of the operation (or Not-acknowledgement NACK) of the operation
is desired, an <iq> stanza can be used instead.
</p>
<p>
To set control parameters in a device, the <strong>set</strong> command is sent to the device. The set command allows for two different ways of setting control parameters:
</p>
<ul>
<li>Using strongly typed parameters. This way performs best in EXI compression and automation.</li>
<li>Using a weakly typed data form. This might be better for manually setting control parameters, since it allows the device to give the user a better user interface explaining
available control parameters.</li>
</ul>
<p>
What type of control parameters there are available in different types of devices is described in
<note>
XEP-xxxx: Internet of Things - Interoperability <<link url='xep-0000-IoT-Interoperability.html'>xep-0000-IoT-Interoperability.html</link>>
</note>.
</p>
<p>
If the device is a concentrator, as defined in <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>,
an handles multiple nodes behind it, which node(s) to control is defined using <strong>node</strong> elements. If not a concentrator,
the use of <strong>node</strong> elements is not necessary, and control commands are sent directly to the device itself.
</p>
<section2 topic='Control commands' anchor='controlcommands'>
<section3 topic='Sending a control command using a message stanza'>
<p>
Following is an example of a control command sent using a message stanza:
</p>
<example caption='Message stanza for setting a value'>
<![CDATA[
<message from='primary@example.org/amr'
to='digital.output@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<boolean name='Output' value='true'/>
</set>
</message>]]>
</example>
<p>
Note that any response is supressed when sending a message stanza, regardless if the desired control command could be executed or not. The following example shows how the same
control command could be issued using an IQ stanza instead:
</p>
</section3>
<section3 topic='Sending a control command using an IQ stanza'>
<p>
Following is an example of a control command sent using an iq stanza:
</p>
<example caption='IQ stanza for setting a value'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='digital.output@example.org'
id='1'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<boolean name='Output' value='true'/>
</set>
</iq>
<iq type='result'
from='digital.output@example.org'
to='primary@example.org/amr'
id='1'>
<setResponse xmlns='urn:xmpp:iot:control'/>
</iq>]]>
</example>
<p>
<strong>Note:</strong> An empty <strong>setResponse</strong> element means that the control command was executed as provided in the request. Sometimes, the device
can restrict the command to a subset of nodes and/or parameters. In such cases, the <strong>setResponse</strong> element will contain what nodes and/or parameters
were finally used to perform the command. For examples of this, see &xep0324;.
</p>
<p>
In the following use cases, often a message stanza will be used to illustrate the point. However, the same operation could equally well be used using an iq stanza instead.
</p>
</section3>
<section3 topic='Control failure response'>
<p>
By using an IQ stanza, the caller can receive an acknowledgement of the reception of the command, or error information if the command could not be processed.
Following is an example of a control command sent using an iq stanza, where the receiver reports an error back to the caller:
</p>
<example caption='Control failure response'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='analog.output@example.org'
id='2'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<boolean name='Output' value='true'/>
</set>
</iq>
<iq type='error'
from='analog.output@example.org'
to='primary@example.org/amr'
id='2'>
<error type='modify'>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<paramError xmlns='urn:xmpp:iot:control' var='Output'>Invalid parameter type.</error>
</error>
</iq>]]>
</example>
<p>
Here, the <strong>paramError</strong> element is used in the IQ Error response, to provide error information related to a specific control parameter.
</p>
</section3>
</section2>
<section2 topic='Setting control parameters' anchor='set'>
<p>
The following sub-sections illustrate how to set parameters of different types in a device.
</p>
<section3 topic='Setting a single boolean-valued control parameter'>
<p>
Setting single boolean-valued control parameters is a common use case, for instance when controlling digital outputs. The following example shows how a boolean value
can be set in a device.
</p>
<example caption='Setting a single boolean-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='digital.output@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<boolean name='Output' value='true'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single 32-bit integer-valued control parameter'>
<p>
Setting single integer-valued control parameters is a common use case, for instance when controlling analog outputs. The following example shows how a 32-bit integer value
can be set in a device.
</p>
<example caption='Setting a single 32-bit integer-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='analog.output@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<int name='Output' value='50000'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single 64-bit integer-valued control parameter'>
<p>
Setting single integer-valued control parameters is a common use case, for instance when controlling analog outputs. Even though 32-bit integers may cover most control needs,
it might in some cases be limiting. Therefore, a 64-bit control parameters can be created. The following example shows how a 64-bit integer value
can be set in a device.
</p>
<example caption='Setting a single 64-bit integer-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='megaprecision.analog.output@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<long name='Output' value='500000000000000'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single string-valued control parameter'>
<p>
Setting single string-valued control parameters is a common use case, for instance when controlling text displays. The following example shows how a string value
can be set in a device.
</p>
<example caption='Setting a single string-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='text.display@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<string name='Row1' value='Temperature: 21.4 °C'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single double-valued control parameter'>
<p>
Setting single double-valued control parameters can be an alternative form of controlling analog outputs for instance. The following example shows how a double value
can be set in a device.
</p>
<example caption='Setting a single double-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='analog.output2@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<double name='4-20mA' value='8.192'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single date-valued control parameter'>
<p>
Setting date-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
The following example shows how a date value can be set in a device.
</p>
<example caption='Setting a single date-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='alarm@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<date name='TariffStartDate' value='2013-05-01'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single time-valued control parameter'>
<p>
Setting time-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
The following example shows how a time value can be set in a device.
</p>
<example caption='Setting a single time-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='alarm@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<time name='Alarm Time' value='08:00:00'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single date & time-valued control parameter'>
<p>
Setting date & time-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
The following example shows how a date & time value can be set in a device.
</p>
<example caption='Setting a single date & time-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='alarm@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<dateTime name='Alarm Time' value='2013-04-02T08:00:00'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single duration-valued control parameter'>
<p>
Setting duration-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
The following example shows how a duration value can be set in a device.
</p>
<example caption='Setting a single duration-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='alarm@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<duration name='Alarm Duration' value='PT3M30S'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting a single color-valued control parameter'>
<p>
Setting single color values in a device can occur in instances where color or lighting is important. Sometimes color is set using enumerations (string-valued
or integer-valued parameters), and sometimes as a color property. The following example shows how a color value can be set in a device.
</p>
<example caption='Setting a single color-valued control parameter'>
<![CDATA[
<message from='primary@example.org/amr'
to='spotlight@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<color name='Color' value='3399FF'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Setting multiple control parameters at once'>
<p>
Often, setting a single control parameter is not sufficient for a control action. In these cases, setting multiple control parameters at once is necessary.
The <strong>set</strong> command makes this easy however, since it allows for any number of control parameters to be set at once, as the following example shows:
</p>
<example caption='Setting multiple control parameters at once'>
<![CDATA[
<message from='primary@example.org/amr'
to='dimmer@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<int name='FadeTimeMilliseconds' value='500'/>
<int name='OutputPercent' value='10'/>
</set>
</message>]]>
</example>
<p>
Sometimes the order of control parameters are important in the device, and sometimes the parameters form part of a whole. It depends on the context of the device.
In the above example, the order is important. When the OutputPercent control parameter is set, it will start to fade in or out to the desired setting (10%), using the
fade time set previously. If the FadeTimeMilliseconds control parameter would have been set after the OutputPercent parameter, the fading would have been started using
the previous setting, which might be unknown.
</p>
<p>
The order of control parameters to use depends on the device. The <link url='#controlform'>Control Form</link> lists available control parameters of the device in the
order they are expected to be sent to the device. The XEP <link url='xep-0000-IoT-Interoperability.html'>xep-0000-IoT-Interoperability</link> details what control parameters
must be available for different interfaces, and if the order of control parameters is important.
</p>
</section3>
</section2>
<section2 topic='Control forms' anchor='forms'>
<section3 topic='Getting a control form' anchor='controlform'>
<p>
A client can get a control form containing available control parameters of the device. This is done using the <strong>getForm</strong> command,
as is shown in the following example:
</p>
<example caption='Getting a control form'>
<![CDATA[
<iq type='get'
from='primary@example.org/amr'
to='dimmer@example.org'
id='3'>
<getForm xmlns='urn:xmpp:iot:control' xml:lang='en'/>
</iq>
<iq type='result'
from='dimmer@example.org'
to='primary@example.org/amr'
id='3'>
<x type='form'
xmlns='jabber:x:data'
xmlns:xdv='http://jabber.org/protocol/xdata-validate'
xmlns:xdl:='http://jabber.org/protocol/xdata-layout'
xmlns:xdd:='urn:xmpp:xdata:dynamic'>
<title>Dimmer</title>
<xdl:page label='Output'>
<xdl:fieldref var='FaceTimeMilliseconds'/>
<xdl:fieldref var='OutputPercent'/>
<xdl:fieldref var='MainSwitch'/>
</xdl:page>
<field var='xdd session' type='hidden'>
<value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
</field>
<field var='FadeTimeMilliseconds' type='text-single' label='Fade Time (ms):'>
<desc>Time in milliseconds used to fade the light to the desired level.</desc>
<value>300</value>
<xdv:validate datatype='xs:int'>
<xdv:range min='0' max='4095'/>
</xdv:validate>
<xdd:notSame/>
</field>
<field var='OutputPercent' type='text-single' label='Output (%):'>
<desc>Dimmer output, in percent.</desc>
<value>100</value>
<xdv:validate datatype='xs:int'>
<xdv:range min='0' max='100'/>
</xdv:validate>
<xdd:notSame/>
</field>
<field var='MainSwitch' type='boolean' label='Main switch'>
<desc>If the dimmer is turned on or off.</desc>
<value>true</value>
<xdd:notSame/>
</field>
</x>
</iq>]]>
</example>
<p>
<strong>IMPORTANT:</strong> The device MUST mark all control parameters in the form as <strong>notSame</strong>, as defined in
<note>
XEP-0336: Dynamic Data Forms <<link url='http://xmpp.org/extensions/xep-0336.html'>http://xmpp.org/extensions/xep-0336.html</link>>
</note>. If an end user would open the control form and press OK (submitting the form) without having entered a value, no value
would be written, and no action taken. If only a few parameter would be edited, only those parameters would be sent to the device
and only the corresponding actions taken.
</p>
<p>
All parameters in the form MUST also have validation rules defined according to <link url='http://xmpp.org/extensions/xep-0122.html'>XEP-0122</link>,
specifically validation data types and ranges where appropriate. This to give type information to the client, which the client later can use to send
typed control commands directly, without the need to get and send data forms to the device to control it.
</p>
<p>
Also, the device SHOULD group control parameters that should be written together using pages and sections, as described in
<link url='http://xmpp.org/extensions/xep-0141.html'>XEP-0141</link>. Parameters
MUST also be ordered in a way so that when set in that order using the typed commands, the corresponding control actions can be successfully executed.
</p>
<p>
<strong>Note:</strong> There's a difference between node parameters, as described in XEP-0326
<link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>,
and control parameters as described in this document. For more information about this, please see
<link url='#nodeparamsvscontrolparams'>Difference between node parameters and node control parameters</link>.
</p>
</section3>
<section3 topic='Getting a control form, Failure'>
<p>
A device can reject a control form request. It does this returning an <strong>error</strong> iq stanza, as is shown in the following example:
</p>
<example caption='Getting a control form, Failure'>
<![CDATA[
<iq type='get'
from='primary@example.org/amr'
to='dimmer@example.org'
id='4'>
<getForm xmlns='urn:xmpp:iot:control' xml:lang='en'/>
</iq>
<iq type='error'
from='dimmer@example.org'
to='primary@example.org/amr'
id='4'>
<error type='cancel'>
<forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>Access denied.</text>
</error>
</iq>]]>
</example>
</section3>
<section3 topic='Setting a (partial) control form'>
<p>
Control actions can be requested by submitting a full or partial control form back to the device. Control parameters not edited MUST not be included
in the form, and the device in turn MUST ONLY invoke control actions corresponding to the parameters returned in the form.
</p>
<p>
The following example shows how control actions can be requested submitting a control parameters form to the device:
</p>
<example caption='Setting a (partial) control form'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='dimmer@example.org'
id='5'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<x type='submit' xmlns='jabber:x:data'>
<field var='xdd session' type='hidden'>
<value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
</field>
<field var='FadeTimeMilliseconds' type='text-single'>
<value>500</value>
</field>
<field var='OutputPercent' type='text-single'>
<value>10</value>
</field>
</x>
</set>
</iq>
<iq type='result'
from='dimmer@example.org'
to='primary@example.org/amr'
id='5'>
<setResponse xmlns='urn:xmpp:iot:control' />
</iq>]]>
</example>
<p>
In this example, the FadeTimeMilliseconds and OutputPercent control parameters are sent, while the MainSwitch control parameter is left as is. Fading is therefore
parformed only if the dimmer is switched on.
</p>
</section3>
<section3 topic='Setting a (partial) control form, Failure'>
<p>
A device can reject a control form submission. It does this returning an <strong>error</strong> iq stanza. If there are errors in the form, details are listed
using <strong>paramError</strong> elements in the response, as is shown in the following example:
</p>
<example caption='Setting a (partial) control form, Failure'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='dimmer@example.org'
id='6'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<x type='submit' xmlns='jabber:x:data'>
<field var='xdd session' type='hidden'>
<value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
</field>
<field var='FadeTimeMilliseconds' type='text-single'>
<value>500</value>
</field>
<field var='OutputPercent' type='text-single'>
<value>200</value>
</field>
</x>
</set>
</iq>
<iq type='error'
from='dimmer@example.org'
to='primary@example.org/amr'
id='6'>
<error type='modify'>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<paramError xmlns='urn:xmpp:iot:control' var='OutputPercent'>Invalid parameter value.</error>
</error>
</iq>]]>
</example>
</section3>
</section2>
<section2 topic='Controlling devices behind a concentrator' anchor='concentrator'>
<p>
Controlling devices behind a concentrator can be done by specifying what device(s) to control using <strong>node</strong> elements within the
command elements sent to the concentrator. The following sub-sections show examples of how this is done.
</p>
<section3 topic='Sending a control command to a node behind a concentrator'>
<p>
To send a control message to a specific node behind a concentrator, the <strong>node</strong> element can be used to identify the node,
as is shown in the following example:
</p>
<example caption='Sending a control command to a node behind a concentrator'>
<![CDATA[
<message from='primary@example.org/amr'
to='concentrator@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<node nodeId='DigitalOutput1'/>
<boolean name='Output' value='false'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Sending a control command to multiple nodes'>
<p>
The client can send the same control command to multiple nodes behind a concentrator by simply adding more <strong>node</strong> elements in the request,
as is shown in the following example:
</p>
<example caption='Sending a control command to multiple nodes'>
<![CDATA[
<message from='primary@example.org/amr'
to='concentrator@example.org'>
<set xmlns='urn:xmpp:iot:control'>
<node nodeId='DigitalOutput1'/>
<node nodeId='DigitalOutput2'/>
<node nodeId='DigitalOutput3'/>
<node nodeId='DigitalOutput4'/>
<boolean name='Output' value='false'/>
</set>
</message>]]>
</example>
</section3>
<section3 topic='Sending a control command to multiple nodes, Failure'>
<p>
By using an IQ stanza, the caller can receive an acknowledgement of the reception of the command, or error information if the command could not be processed.
When sending a control command to multiple nodes at a time the device must validate all parameters against all nodes before taking any control action. If
validation fails, an error message is returned and no control action is taken. The following example shows an example of an erroneous control message made to
multiple nodes on a device:
</p>
<example caption='Sending a control command to multiple nodes, Failure'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='concentrator@example.org'
id='7'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<node nodeId='DigitalOutput1'/>
<node nodeId='DigitalOutput2'/>
<node nodeId='DigitalOutput3'/>
<node nodeId='DigitalOutput4'/>
<node nodeId='AnalogOutput1'/>
<node nodeId='AnalogOutput2'/>
<node nodeId='AnalogOutput3'/>
<node nodeId='AnalogOutput4'/>
<boolean name='Output' value='true'/>
</set>
</iq>
<iq type='error'
from='concentrator@example.org'
to='primary@example.org/amr'
id='7'>
<error type='modify'>
<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<paramError xmlns='urn:xmpp:iot:control' var='Output'>Invalid parameter type.</error>
</error>
</iq>]]>
</example>
</section3>
<section3 topic='Getting a control form from multiple nodes'>
<p>
A client can get a control form containing available control parameters common between a set of nodes controlled by the concentrator. This is done
adding a sequence of <strong>node</strong> elements to a <strong>getForm</strong> command sent to the concentrator, as is shown in the following example:
</p>
<example caption='Getting a control form from multiple nodes'>
<![CDATA[
<iq type='get'
from='primary@example.org/amr'
to='concentrator@example.org'
id='8'>
<getForm xmlns='urn:xmpp:iot:control' xml:lang='en'>
<node nodeId='DigitalOutput1'/>
<node nodeId='DigitalOutput2'/>
<node nodeId='DigitalOutput3'/>
<node nodeId='DigitalOutput4'/>
</getForm>
</iq>
<iq type='result'
from='concentrator@example.org'
to='primary@example.org/amr'
id='8'>
<x type='form'
xmlns='jabber:x:data'
xmlns:xdv='http://jabber.org/protocol/xdata-validate'
xmlns:xdl:='http://jabber.org/protocol/xdata-layout'
xmlns:xdd:='urn:xmpp:xdata:dynamic'>
<title>DigitalOutput1, DigitalOutput2, ...</title>
<xdl:page label='Output'>
<xdl:fieldref var='Output'/>
</xdl:page>
<field var='xdd session' type='hidden'>
<value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
</field>
<field var='Output' type='boolean' label='Output'>
<desc>If the digital output is high (checked) or low (uncheckd).</desc>
<value>true</value>
<xdd:notSame/>
</field>
</x>
</iq>]]>
</example>
<p>
Note that only parameters that are common between the nodes defined in the request must be returned. However, all parameters must have the
<strong>notSame</strong> flag set, regardless of current output status.
</p>
</section3>
<section3 topic='Getting a control form from multiple nodes, Failure'>
<p>
A device can reject a control form request. It does this returning an <strong>error</strong> iq stanza. The following example shows the device rejecting
a control form request, because it does not support the handling of common parameters between multiple nodes:
</p>
<example caption='Getting a control form from multiple nodes, Failure'>
<![CDATA[
<iq type='get'
from='primary@example.org/amr'
to='concentrator@example.org'
id='9'>
<getForm xmlns='urn:xmpp:iot:control' xml:lang='en'>
<node nodeId='DigitalOutput1'/>
<node nodeId='DigitalOutput2'/>
<node nodeId='DigitalOutput3'/>
<node nodeId='DigitalOutput4'/>
</getForm>
</iq>
<iq type='error'
from='concentrator@example.org'
to='primary@example.org/amr'
id='9'>
<error type='cancel'>
<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
<text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>Cannot merge control forms from different nodes.</text>
</error>
</iq>]]>
</example>
</section3>
<section3 topic='Setting a (partial) control form to multiple nodes'>
<p>
You set a control form to multiple nodes controlled by a
concentrator by adding <strong>node</strong> elements to the
<strong>set</strong> command sent to the concentrator, as is
shown in the following example:
</p>
<example caption='Setting a (partial) control form to multiple nodes'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='concentrator@example.org'
id='10'>
<set xmlns='urn:xmpp:iot:control' xml:lang='en'>
<node nodeId='DigitalOutput1'/>
<node nodeId='DigitalOutput2'/>
<node nodeId='DigitalOutput3'/>
<node nodeId='DigitalOutput4'/>
<x type='submit' xmlns='jabber:x:data'>
<field var='xdd session' type='hidden'>
<value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
</field>
<field var='Output' type='boolean'>
<value>true</value>
</field>
</x>
</set>
</iq>
<iq type='result'
from='concentrator@example.org'
to='primary@example.org/amr'
id='10'>
<setResponse xmlns='urn:xmpp:iot:control' />
</iq>]]>
</example>
</section3>
<section3 topic='Setting a (partial) control form to multiple nodes, Failure'>
<p>
A device can reject a control form submission. It does this returning an <strong>error</strong> iq stanza. The following example shows the device rejecting a
control form submission because one of the control parameters, even though it exists on all nodes, is not of the same type on all nodes.
</p>
<example caption='Setting a (partial) control form to multiple nodes'>
<![CDATA[
<iq type='set'
from='primary@example.org/amr'
to='concentrator@example.org'