No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0325.xml 83KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Internet of Things - Control</title>
  10. <abstract>
  11. Note: This specification has been retracted by the author; new
  12. implementations are not recommended.
  13. This specification describes how to control devices or actuators in an
  14. XMPP-based sensor network.
  15. </abstract>
  16. &LEGALNOTICE;
  17. <number>0325</number>
  18. <status>Retracted</status>
  19. <type>Standards Track</type>
  20. <sig>Standards</sig>
  21. <approver>Council</approver>
  22. <dependencies>
  23. <spec>XEP-0001</spec>
  24. <spec>XEP-0004</spec>
  25. <spec>XEP-0030</spec>
  26. <spec>XEP-0122</spec>
  27. <spec>XEP-0137</spec>
  28. <spec>XEP-0141</spec>
  29. <spec>XEP-0323</spec>
  30. <spec>XEP-0324</spec>
  31. <spec>XEP-0331</spec>
  32. <spec>XEP-0336</spec>
  33. </dependencies>
  34. <supersedes/>
  35. <supersededby/>
  36. <shortname>sensor-network-control</shortname>
  37. &peterwaher;
  38. <revision>
  39. <version>0.5</version>
  40. <date>2017-05-20</date>
  41. <initials>XEP Editor: ssw</initials>
  42. <remark>Mark XEP as retracted by the author.</remark>
  43. </revision>
  44. <revision>
  45. <version>0.4</version>
  46. <date>2015-11-09</date>
  47. <initials>psa</initials>
  48. <remark>
  49. <p>Updated contact information.</p>
  50. <p>Updated example JIDs to example.org</p>
  51. </remark>
  52. </revision>
  53. <revision>
  54. <version>0.3</version>
  55. <date>2014-04-07</date>
  56. <initials>pw</initials>
  57. <remark>
  58. <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>
  59. <p>The <strong>getFormResponse</strong> element has been removed.</p>
  60. <p>The <strong>setResponse</strong> is now only used when configuration is successful.</p>
  61. <p>The <strong>parameter</strong> subelement to <strong>setResponse</strong> has been reintroduced. Examples are provided in XEP-0324.</p>
  62. <p>The element <strong>paramError</strong> has been introduced, and can be used to provide error information that are linked to control parameters.</p>
  63. <p>Added anchors to all second level subsections.</p>
  64. <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>
  65. <p>Harmonization of data types between XEP-0323 and XEP-0325.</p>
  66. <p>The attribute <strong>writable</strong> used to correlate fields in XEP-0323 with control parameters is described.</p>
  67. </remark>
  68. </revision>
  69. <revision>
  70. <version>0.2</version>
  71. <date>2014-03-10</date>
  72. <initials>pw</initials>
  73. <remark>
  74. <p>Namespace in dynamic form examples has been changed to urn:xmpp:xdata:dynamic.</p>
  75. <p>Corrected the namespace used for parameterGroup elements in the examples of the document.</p>
  76. <p>Added support for color values with alpha channel.</p>
  77. <p>Updated the schema to more strictly validate references to x-data forms.</p>
  78. <p>Schema was updated to reflect the correct relationship between the x-data subelement in a set operation.</p>
  79. <p>Fixed links to documents with new numbers.</p>
  80. <p>Changed namespace urn:xmpp:sn to urn:xmpp:iot</p>
  81. <p>Schema was corrected: The parameter sub-element in the setResponse element was removed.</p>
  82. </remark>
  83. </revision>
  84. <revision>
  85. <version>0.1</version>
  86. <date>2013-05-06</date>
  87. <initials>psa</initials>
  88. <remark>
  89. <p>Initial published version approved by the XMPP Council.</p>
  90. </remark>
  91. </revision>
  92. <revision>
  93. <version>0.0.1</version>
  94. <date>2013-03-27</date>
  95. <initials>pw</initials>
  96. <remark>
  97. <p>First draft.</p>
  98. </remark>
  99. </revision>
  100. </header>
  101. <section1 topic='Introduction' anchor='intro'>
  102. <p>
  103. 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,
  104. 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
  105. possible to integrate sensors and actuators of different brands, makes and models into larger Internet of Things applications.
  106. </p>
  107. <p>
  108. 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).
  109. Therefore, simplicity is of utmost importance. Furthermore, sensor networks can become huge, easily with millions of devices in peer-to-peer networks.
  110. </p>
  111. <p>
  112. 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:
  113. </p>
  114. <table caption='Sensor Network XEPs'>
  115. <tr>
  116. <th>XEP</th>
  117. <th>Description</th>
  118. </tr>
  119. <tr>
  120. <td>xep-0000-IoT-BatteryPoweredSensors</td>
  121. <td>Defines how to handle the peculiars related to battery powered devices, and other devices intermittently available on the network.</td>
  122. </tr>
  123. <tr>
  124. <td>xep-0000-IoT-Discovery</td>
  125. <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>
  126. </tr>
  127. <tr>
  128. <td>xep-0000-IoT-Events</td>
  129. <td>Defines how sensors send events, how event subscription, hysteresis levels, etc., are configured.</td>
  130. </tr>
  131. <tr>
  132. <td>xep-0000-IoT-Interoperability</td>
  133. <td>Defines guidelines for how to achieve interoperability in sensor networks, publishing interoperability interfaces for different types of devices.</td>
  134. </tr>
  135. <tr>
  136. <td>xep-0000-IoT-Multicast</td>
  137. <td>Defines how sensor data can be multicast in efficient ways.</td>
  138. </tr>
  139. <tr>
  140. <td>xep-0000-IoT-PubSub</td>
  141. <td>Defines how efficient publication of sensor data can be made in sensor networks.</td>
  142. </tr>
  143. <tr>
  144. <td>xep-0000-IoT-Chat</td>
  145. <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>
  146. </tr>
  147. <tr>
  148. <td>XEP-0322</td>
  149. <td>
  150. 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
  151. in all sensor network implementations where memory and packet size is an issue.
  152. </td>
  153. </tr>
  154. <tr>
  155. <td>XEP-0323</td>
  156. <td>
  157. Provides the underlying architecture, basic operations and data structures for sensor data communication over XMPP networks.
  158. It includes a hardware abstraction model, removing any technical detail implemented in underlying technologies. This XEP is used by all other sensor network XEPs.
  159. </td>
  160. </tr>
  161. <tr>
  162. <td>XEP-0324</td>
  163. <td>Defines how provisioning, the management of access privileges, etc., can be efficiently and easily implemented.</td>
  164. </tr>
  165. <tr>
  166. <td>XEP-0325</td>
  167. <td>This specification. Defines how to control actuators and other devices in Internet of Things.</td>
  168. </tr>
  169. <tr>
  170. <td>XEP-0326</td>
  171. <td>Defines how to handle architectures containing concentrators or servers handling multiple sensors.</td>
  172. </tr>
  173. <tr>
  174. <td>XEP-0331</td>
  175. <td>Defines extensions for how color parameters can be handled, based on &xep0004;</td>
  176. </tr>
  177. <tr>
  178. <td>XEP-0336</td>
  179. <td>Defines extensions for how dynamic forms can be created, based on &xep0004;, &xep0122;, &xep0137; and &xep0141;.</td>
  180. </tr>
  181. </table>
  182. </section1>
  183. <section1 topic='Glossary' anchor='glossary'>
  184. <p>The following table lists common terms and corresponding descriptions.</p>
  185. <dl>
  186. <di>
  187. <dt>Actuator</dt>
  188. <dd>Device containing at least one configurable property or output that can and should be controlled by some other entity or device.</dd>
  189. </di>
  190. <di>
  191. <dt>Computed Value</dt>
  192. <dd>A value that is computed instead of measured.</dd>
  193. </di>
  194. <di>
  195. <dt>Concentrator</dt>
  196. <dd>Device managing a set of devices which it publishes on the XMPP network.</dd>
  197. </di>
  198. <di>
  199. <dt>Field</dt>
  200. <dd>
  201. One item of sensor data. Contains information about: Node, Field Name, Value, Precision, Unit, Value Type, Status, Timestamp, Localization information, etc.
  202. Fields should be unique within the triple (Node ID, Field Name, Timestamp).
  203. </dd>
  204. </di>
  205. <di>
  206. <dt>Field Name</dt>
  207. <dd>Name of a field of sensor data. Examples: Energy, Volume, Flow, Power, etc.</dd>
  208. </di>
  209. <di>
  210. <dt>Field Type</dt>
  211. <dd>What type of value the field represents. Examples: Momentary Value, Status Value, Identification Value, Calculated Value, Peak Value, Historical Value, etc.</dd>
  212. </di>
  213. <di>
  214. <dt>Historical Value</dt>
  215. <dd>A value stored in memory from a previous timestamp.</dd>
  216. </di>
  217. <di>
  218. <dt>Identification Value</dt>
  219. <dd>A value that can be used for identification. (Serial numbers, meter IDs, locations, names, etc.)</dd>
  220. </di>
  221. <di>
  222. <dt>Localization information</dt>
  223. <dd>Optional information for a field, allowing the sensor to control how the information should be presented to human viewers.</dd>
  224. </di>
  225. <di>
  226. <dt>Meter</dt>
  227. <dd>A device possible containing multiple sensors, used in metering applications. Examples: Electricity meter, Water Meter, Heat Meter, Cooling Meter, etc.</dd>
  228. </di>
  229. <di>
  230. <dt>Momentary Value</dt>
  231. <dd>A momentary value represents a value measured at the time of the read-out.</dd>
  232. </di>
  233. <di>
  234. <dt>Node</dt>
  235. <dd>
  236. 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)
  237. 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.).
  238. Each Node has a Node ID.
  239. </dd>
  240. </di>
  241. <di>
  242. <dt>Node ID</dt>
  243. <dd>
  244. 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
  245. ID scheme.
  246. </dd>
  247. </di>
  248. <di>
  249. <dt>Parameter</dt>
  250. <dd>
  251. Readable and/or writable property on a node/device. The XEP-0326 &xep0326; deals with reading and writing parameters
  252. on nodes/devices. Fields are not parameters, and parameters are not fields.
  253. </dd>
  254. </di>
  255. <di>
  256. <dt>Peak Value</dt>
  257. <dd>A maximum or minimum value during a given period.</dd>
  258. </di>
  259. <di>
  260. <dt>Precision</dt>
  261. <dd>
  262. In physics, precision determines the number of digits of precision. In sensor networks however, this definition is not easily applicable. Instead, precision
  263. 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
  264. delivering field information in sensor networks should always retain the number of decimals in a message.
  265. </dd>
  266. </di>
  267. <di>
  268. <dt>Sensor</dt>
  269. <dd>
  270. 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.
  271. Sensor values are reported as fields during read-out. Each sensor has a unique Node ID.
  272. </dd>
  273. </di>
  274. <di>
  275. <dt>SN</dt>
  276. <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>
  277. </di>
  278. <di>
  279. <dt>Status Value</dt>
  280. <dd>A value displaying status information about something.</dd>
  281. </di>
  282. <di>
  283. <dt>Timestamp</dt>
  284. <dd>Timestamp of value, when the value was sampled or recorded.</dd>
  285. </di>
  286. <di>
  287. <dt>Token</dt>
  288. <dd>
  289. 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
  290. access rights with the provisioning server.
  291. </dd>
  292. </di>
  293. <di>
  294. <dt>Unit</dt>
  295. <dd>Physical unit of value. Example: MWh, l/s, etc.</dd>
  296. </di>
  297. <di>
  298. <dt>Value</dt>
  299. <dd>A field value.</dd>
  300. </di>
  301. <di>
  302. <dt>Value Status</dt>
  303. <dd>Status of field value. Contains important status information for Quality of Service purposes. Examples: Ok, Error, Warning, Time Shifted, Missing, Signed, etc.</dd>
  304. </di>
  305. <di>
  306. <dt>Value Type</dt>
  307. <dd>Can be numeric, string, boolean, Date &amp; Time, Time Span or Enumeration.</dd>
  308. </di>
  309. <di>
  310. <dt>WSN</dt>
  311. <dd>Wireless Sensor Network, a sensor network including wireless devices.</dd>
  312. </di>
  313. <di>
  314. <dt>XMPP Client</dt>
  315. <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>
  316. </di>
  317. </dl>
  318. </section1>
  319. <section1 topic='Use Cases' anchor='usecases'>
  320. <p>
  321. 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.
  322. If only a simple set operation is requested, a &lt;message&gt; stanza can be sent. If an acknowledgement (ACK) of the operation (or Not-acknowledgement NACK) of the operation
  323. is desired, an &lt;iq&gt; stanza can be used instead.
  324. </p>
  325. <p>
  326. 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:
  327. </p>
  328. <ul>
  329. <li>Using strongly typed parameters. This way performs best in EXI compression and automation.</li>
  330. <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
  331. available control parameters.</li>
  332. </ul>
  333. <p>
  334. What type of control parameters there are available in different types of devices is described in
  335. <note>
  336. XEP-xxxx: Internet of Things - Interoperability &lt;<link url='xep-0000-IoT-Interoperability.html'>xep-0000-IoT-Interoperability.html</link>&gt;
  337. </note>.
  338. </p>
  339. <p>
  340. If the device is a concentrator, as defined in <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>,
  341. an handles multiple nodes behind it, which node(s) to control is defined using <strong>node</strong> elements. If not a concentrator,
  342. the use of <strong>node</strong> elements is not necessary, and control commands are sent directly to the device itself.
  343. </p>
  344. <section2 topic='Control commands' anchor='controlcommands'>
  345. <section3 topic='Sending a control command using a message stanza'>
  346. <p>
  347. Following is an example of a control command sent using a message stanza:
  348. </p>
  349. <example caption='Message stanza for setting a value'>
  350. <![CDATA[
  351. <message from='master@example.org/amr'
  352. to='digital.output@example.org'>
  353. <set xmlns='urn:xmpp:iot:control'>
  354. <boolean name='Output' value='true'/>
  355. </set>
  356. </message>]]>
  357. </example>
  358. <p>
  359. 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
  360. control command could be issued using an IQ stanza instead:
  361. </p>
  362. </section3>
  363. <section3 topic='Sending a control command using an IQ stanza'>
  364. <p>
  365. Following is an example of a control command sent using an iq stanza:
  366. </p>
  367. <example caption='IQ stanza for setting a value'>
  368. <![CDATA[
  369. <iq type='set'
  370. from='master@example.org/amr'
  371. to='digital.output@example.org'
  372. id='1'>
  373. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  374. <boolean name='Output' value='true'/>
  375. </set>
  376. </iq>
  377. <iq type='result'
  378. from='digital.output@example.org'
  379. to='master@example.org/amr'
  380. id='1'>
  381. <setResponse xmlns='urn:xmpp:iot:control'/>
  382. </iq>]]>
  383. </example>
  384. <p>
  385. <strong>Note:</strong> An empty <strong>setResponse</strong> element means that the control command was executed as provided in the request. Sometimes, the device
  386. 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
  387. were finally used to perform the command. For examples of this, see &xep0324;.
  388. </p>
  389. <p>
  390. 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.
  391. </p>
  392. </section3>
  393. <section3 topic='Control failure response'>
  394. <p>
  395. 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.
  396. Following is an example of a control command sent using an iq stanza, where the receiver reports an error back to the caller:
  397. </p>
  398. <example caption='Control failure response'>
  399. <![CDATA[
  400. <iq type='set'
  401. from='master@example.org/amr'
  402. to='analog.output@example.org'
  403. id='2'>
  404. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  405. <boolean name='Output' value='true'/>
  406. </set>
  407. </iq>
  408. <iq type='error'
  409. from='analog.output@example.org'
  410. to='master@example.org/amr'
  411. id='2'>
  412. <error type='modify'>
  413. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  414. <paramError xmlns='urn:xmpp:iot:control' var='Output'>Invalid parameter type.</error>
  415. </error>
  416. </iq>]]>
  417. </example>
  418. <p>
  419. Here, the <strong>paramError</strong> element is used in the IQ Error response, to provide error information related to a specific control parameter.
  420. </p>
  421. </section3>
  422. </section2>
  423. <section2 topic='Setting control parameters' anchor='set'>
  424. <p>
  425. The following sub-sections illustrate how to set parameters of different types in a device.
  426. </p>
  427. <section3 topic='Setting a single boolean-valued control parameter'>
  428. <p>
  429. 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
  430. can be set in a device.
  431. </p>
  432. <example caption='Setting a single boolean-valued control parameter'>
  433. <![CDATA[
  434. <message from='master@example.org/amr'
  435. to='digital.output@example.org'>
  436. <set xmlns='urn:xmpp:iot:control'>
  437. <boolean name='Output' value='true'/>
  438. </set>
  439. </message>]]>
  440. </example>
  441. </section3>
  442. <section3 topic='Setting a single 32-bit integer-valued control parameter'>
  443. <p>
  444. 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
  445. can be set in a device.
  446. </p>
  447. <example caption='Setting a single 32-bit integer-valued control parameter'>
  448. <![CDATA[
  449. <message from='master@example.org/amr'
  450. to='analog.output@example.org'>
  451. <set xmlns='urn:xmpp:iot:control'>
  452. <int name='Output' value='50000'/>
  453. </set>
  454. </message>]]>
  455. </example>
  456. </section3>
  457. <section3 topic='Setting a single 64-bit integer-valued control parameter'>
  458. <p>
  459. 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,
  460. 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
  461. can be set in a device.
  462. </p>
  463. <example caption='Setting a single 64-bit integer-valued control parameter'>
  464. <![CDATA[
  465. <message from='master@example.org/amr'
  466. to='megaprecision.analog.output@example.org'>
  467. <set xmlns='urn:xmpp:iot:control'>
  468. <long name='Output' value='500000000000000'/>
  469. </set>
  470. </message>]]>
  471. </example>
  472. </section3>
  473. <section3 topic='Setting a single string-valued control parameter'>
  474. <p>
  475. 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
  476. can be set in a device.
  477. </p>
  478. <example caption='Setting a single string-valued control parameter'>
  479. <![CDATA[
  480. <message from='master@example.org/amr'
  481. to='text.display@example.org'>
  482. <set xmlns='urn:xmpp:iot:control'>
  483. <string name='Row1' value='Temperature: 21.4 °C'/>
  484. </set>
  485. </message>]]>
  486. </example>
  487. </section3>
  488. <section3 topic='Setting a single double-valued control parameter'>
  489. <p>
  490. 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
  491. can be set in a device.
  492. </p>
  493. <example caption='Setting a single double-valued control parameter'>
  494. <![CDATA[
  495. <message from='master@example.org/amr'
  496. to='analog.output2@example.org'>
  497. <set xmlns='urn:xmpp:iot:control'>
  498. <double name='4-20mA' value='8.192'/>
  499. </set>
  500. </message>]]>
  501. </example>
  502. </section3>
  503. <section3 topic='Setting a single date-valued control parameter'>
  504. <p>
  505. Setting date-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
  506. The following example shows how a date value can be set in a device.
  507. </p>
  508. <example caption='Setting a single date-valued control parameter'>
  509. <![CDATA[
  510. <message from='master@example.org/amr'
  511. to='alarm@example.org'>
  512. <set xmlns='urn:xmpp:iot:control'>
  513. <date name='TariffStartDate' value='2013-05-01'/>
  514. </set>
  515. </message>]]>
  516. </example>
  517. </section3>
  518. <section3 topic='Setting a single time-valued control parameter'>
  519. <p>
  520. Setting time-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
  521. The following example shows how a time value can be set in a device.
  522. </p>
  523. <example caption='Setting a single time-valued control parameter'>
  524. <![CDATA[
  525. <message from='master@example.org/amr'
  526. to='alarm@example.org'>
  527. <set xmlns='urn:xmpp:iot:control'>
  528. <time name='Alarm Time' value='08:00:00'/>
  529. </set>
  530. </message>]]>
  531. </example>
  532. </section3>
  533. <section3 topic='Setting a single date &amp; time-valued control parameter'>
  534. <p>
  535. Setting date &amp; time-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
  536. The following example shows how a date &amp; time value can be set in a device.
  537. </p>
  538. <example caption='Setting a single date &amp; time-valued control parameter'>
  539. <![CDATA[
  540. <message from='master@example.org/amr'
  541. to='alarm@example.org'>
  542. <set xmlns='urn:xmpp:iot:control'>
  543. <dateTime name='Alarm Time' value='2013-04-02T08:00:00'/>
  544. </set>
  545. </message>]]>
  546. </example>
  547. </section3>
  548. <section3 topic='Setting a single duration-valued control parameter'>
  549. <p>
  550. Setting duration-valued control parameters might be necessary when timing is an issue. Often it forms part of a larger context.
  551. The following example shows how a duration value can be set in a device.
  552. </p>
  553. <example caption='Setting a single duration-valued control parameter'>
  554. <![CDATA[
  555. <message from='master@example.org/amr'
  556. to='alarm@example.org'>
  557. <set xmlns='urn:xmpp:iot:control'>
  558. <duration name='Alarm Duration' value='PT3M30S'/>
  559. </set>
  560. </message>]]>
  561. </example>
  562. </section3>
  563. <section3 topic='Setting a single color-valued control parameter'>
  564. <p>
  565. 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
  566. or integer-valued parameters), and sometimes as a color property. The following example shows how a color value can be set in a device.
  567. </p>
  568. <example caption='Setting a single color-valued control parameter'>
  569. <![CDATA[
  570. <message from='master@example.org/amr'
  571. to='spotlight@example.org'>
  572. <set xmlns='urn:xmpp:iot:control'>
  573. <color name='Color' value='3399FF'/>
  574. </set>
  575. </message>]]>
  576. </example>
  577. </section3>
  578. <section3 topic='Setting multiple control parameters at once'>
  579. <p>
  580. Often, setting a single control parameter is not sufficient for a control action. In these cases, setting multiple control parameters at once is necessary.
  581. 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:
  582. </p>
  583. <example caption='Setting multiple control parameters at once'>
  584. <![CDATA[
  585. <message from='master@example.org/amr'
  586. to='dimmer@example.org'>
  587. <set xmlns='urn:xmpp:iot:control'>
  588. <int name='FadeTimeMilliseconds' value='500'/>
  589. <int name='OutputPercent' value='10'/>
  590. </set>
  591. </message>]]>
  592. </example>
  593. <p>
  594. 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.
  595. 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
  596. fade time set previously. If the FadeTimeMilliseconds control parameter would have been set after the OutputPercent parameter, the fading would have been started using
  597. the previous setting, which might be unknown.
  598. </p>
  599. <p>
  600. 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
  601. 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
  602. must be available for different interfaces, and if the order of control parameters is important.
  603. </p>
  604. </section3>
  605. </section2>
  606. <section2 topic='Control forms' anchor='forms'>
  607. <section3 topic='Getting a control form' anchor='controlform'>
  608. <p>
  609. A client can get a control form containing available control parameters of the device. This is done using the <strong>getForm</strong> command,
  610. as is shown in the following example:
  611. </p>
  612. <example caption='Getting a control form'>
  613. <![CDATA[
  614. <iq type='get'
  615. from='master@example.org/amr'
  616. to='dimmer@example.org'
  617. id='3'>
  618. <getForm xmlns='urn:xmpp:iot:control' xml:lang='en'/>
  619. </iq>
  620. <iq type='result'
  621. from='dimmer@example.org'
  622. to='master@example.org/amr'
  623. id='3'>
  624. <x type='form'
  625. xmlns='jabber:x:data'
  626. xmlns:xdv='http://jabber.org/protocol/xdata-validate'
  627. xmlns:xdl:='http://jabber.org/protocol/xdata-layout'
  628. xmlns:xdd:='urn:xmpp:xdata:dynamic'>
  629. <title>Dimmer</title>
  630. <xdl:page label='Output'>
  631. <xdl:fieldref var='FaceTimeMilliseconds'/>
  632. <xdl:fieldref var='OutputPercent'/>
  633. <xdl:fieldref var='MainSwitch'/>
  634. </xdl:page>
  635. <field var='xdd session' type='hidden'>
  636. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  637. </field>
  638. <field var='FadeTimeMilliseconds' type='text-single' label='Fade Time (ms):'>
  639. <desc>Time in milliseconds used to fade the light to the desired level.</desc>
  640. <value>300</value>
  641. <xdv:validate datatype='xs:int'>
  642. <xdv:range min='0' max='4095'/>
  643. </xdv:validate>
  644. <xdd:notSame/>
  645. </field>
  646. <field var='OutputPercent' type='text-single' label='Output (%):'>
  647. <desc>Dimmer output, in percent.</desc>
  648. <value>100</value>
  649. <xdv:validate datatype='xs:int'>
  650. <xdv:range min='0' max='100'/>
  651. </xdv:validate>
  652. <xdd:notSame/>
  653. </field>
  654. <field var='MainSwitch' type='boolean' label='Main switch'>
  655. <desc>If the dimmer is turned on or off.</desc>
  656. <value>true</value>
  657. <xdd:notSame/>
  658. </field>
  659. </x>
  660. </iq>]]>
  661. </example>
  662. <p>
  663. <strong>IMPORTANT:</strong> The device MUST mark all control parameters in the form as <strong>notSame</strong>, as defined in
  664. <note>
  665. XEP-0336: Dynamic Data Forms &lt;<link url='http://xmpp.org/extensions/xep-0336.html'>http://xmpp.org/extensions/xep-0336.html</link>&gt;
  666. </note>. If an end user would open the control form and press OK (submitting the form) without having entered a value, no value
  667. would be written, and no action taken. If only a few parameter would be edited, only those parameters would be sent to the device
  668. and only the corresponding actions taken.
  669. </p>
  670. <p>
  671. 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>,
  672. specifically validation data types and ranges where appropriate. This to give type information to the client, which the client later can use to send
  673. typed control commands directly, without the need to get and send data forms to the device to control it.
  674. </p>
  675. <p>
  676. Also, the device SHOULD group control parameters that should be written together using pages and sections, as described in
  677. <link url='http://xmpp.org/extensions/xep-0141.html'>XEP-0141</link>. Parameters
  678. 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.
  679. </p>
  680. <p>
  681. <strong>Note:</strong> There's a difference between node parameters, as described in XEP-0326
  682. <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>,
  683. and control parameters as described in this document. For more information about this, please see
  684. <link url='#nodeparamsvscontrolparams'>Difference between node parameters and node control parameters</link>.
  685. </p>
  686. </section3>
  687. <section3 topic='Getting a control form, Failure'>
  688. <p>
  689. 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:
  690. </p>
  691. <example caption='Getting a control form, Failure'>
  692. <![CDATA[
  693. <iq type='get'
  694. from='master@example.org/amr'
  695. to='dimmer@example.org'
  696. id='4'>
  697. <getForm xmlns='urn:xmpp:iot:control' xml:lang='en'/>
  698. </iq>
  699. <iq type='error'
  700. from='dimmer@example.org'
  701. to='master@example.org/amr'
  702. id='4'>
  703. <error type='cancel'>
  704. <forbidden xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  705. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>Access denied.</text>
  706. </error>
  707. </iq>]]>
  708. </example>
  709. </section3>
  710. <section3 topic='Setting a (partial) control form'>
  711. <p>
  712. 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
  713. in the form, and the device in turn MUST ONLY invoke control actions corresponding to the parameters returned in the form.
  714. </p>
  715. <p>
  716. The following example shows how control actions can be requested submitting a control parameters form to the device:
  717. </p>
  718. <example caption='Setting a (partial) control form'>
  719. <![CDATA[
  720. <iq type='set'
  721. from='master@example.org/amr'
  722. to='dimmer@example.org'
  723. id='5'>
  724. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  725. <x type='submit' xmlns='jabber:x:data'>
  726. <field var='xdd session' type='hidden'>
  727. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  728. </field>
  729. <field var='FadeTimeMilliseconds' type='text-single'>
  730. <value>500</value>
  731. </field>
  732. <field var='OutputPercent' type='text-single'>
  733. <value>10</value>
  734. </field>
  735. </x>
  736. </set>
  737. </iq>
  738. <iq type='result'
  739. from='dimmer@example.org'
  740. to='master@example.org/amr'
  741. id='5'>
  742. <setResponse xmlns='urn:xmpp:iot:control' />
  743. </iq>]]>
  744. </example>
  745. <p>
  746. In this example, the FadeTimeMilliseconds and OutputPercent control parameters are sent, while the MainSwitch control parameter is left as is. Fading is therefore
  747. parformed only if the dimmer is switched on.
  748. </p>
  749. </section3>
  750. <section3 topic='Setting a (partial) control form, Failure'>
  751. <p>
  752. 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
  753. using <strong>paramError</strong> elements in the response, as is shown in the following example:
  754. </p>
  755. <example caption='Setting a (partial) control form, Failure'>
  756. <![CDATA[
  757. <iq type='set'
  758. from='master@example.org/amr'
  759. to='dimmer@example.org'
  760. id='6'>
  761. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  762. <x type='submit' xmlns='jabber:x:data'>
  763. <field var='xdd session' type='hidden'>
  764. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  765. </field>
  766. <field var='FadeTimeMilliseconds' type='text-single'>
  767. <value>500</value>
  768. </field>
  769. <field var='OutputPercent' type='text-single'>
  770. <value>200</value>
  771. </field>
  772. </x>
  773. </set>
  774. </iq>
  775. <iq type='error'
  776. from='dimmer@example.org'
  777. to='master@example.org/amr'
  778. id='6'>
  779. <error type='modify'>
  780. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  781. <paramError xmlns='urn:xmpp:iot:control' var='OutputPercent'>Invalid parameter value.</error>
  782. </error>
  783. </iq>]]>
  784. </example>
  785. </section3>
  786. </section2>
  787. <section2 topic='Controlling devices behind a concentrator' anchor='concentrator'>
  788. <p>
  789. Controlling devices behind a concentrator can be done by specifying what device(s) to control using <strong>node</strong> elements within the
  790. command elements sent to the concentrator. The following sub-sections show examples of how this is done.
  791. </p>
  792. <section3 topic='Sending a control command to a node behind a concentrator'>
  793. <p>
  794. To send a control message to a specific node behind a concentrator, the <strong>node</strong> element can be used to identify the node,
  795. as is shown in the following example:
  796. </p>
  797. <example caption='Sending a control command to a node behind a concentrator'>
  798. <![CDATA[
  799. <message from='master@example.org/amr'
  800. to='concentrator@example.org'>
  801. <set xmlns='urn:xmpp:iot:control'>
  802. <node nodeId='DigitalOutput1'/>
  803. <boolean name='Output' value='false'/>
  804. </set>
  805. </message>]]>
  806. </example>
  807. </section3>
  808. <section3 topic='Sending a control command to multiple nodes'>
  809. <p>
  810. 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,
  811. as is shown in the following example:
  812. </p>
  813. <example caption='Sending a control command to multiple nodes'>
  814. <![CDATA[
  815. <message from='master@example.org/amr'
  816. to='concentrator@example.org'>
  817. <set xmlns='urn:xmpp:iot:control'>
  818. <node nodeId='DigitalOutput1'/>
  819. <node nodeId='DigitalOutput2'/>
  820. <node nodeId='DigitalOutput3'/>
  821. <node nodeId='DigitalOutput4'/>
  822. <boolean name='Output' value='false'/>
  823. </set>
  824. </message>]]>
  825. </example>
  826. </section3>
  827. <section3 topic='Sending a control command to multiple nodes, Failure'>
  828. <p>
  829. 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.
  830. 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
  831. 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
  832. multiple nodes on a device:
  833. </p>
  834. <example caption='Sending a control command to multiple nodes, Failure'>
  835. <![CDATA[
  836. <iq type='set'
  837. from='master@example.org/amr'
  838. to='concentrator@example.org'
  839. id='7'>
  840. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  841. <node nodeId='DigitalOutput1'/>
  842. <node nodeId='DigitalOutput2'/>
  843. <node nodeId='DigitalOutput3'/>
  844. <node nodeId='DigitalOutput4'/>
  845. <node nodeId='AnalogOutput1'/>
  846. <node nodeId='AnalogOutput2'/>
  847. <node nodeId='AnalogOutput3'/>
  848. <node nodeId='AnalogOutput4'/>
  849. <boolean name='Output' value='true'/>
  850. </set>
  851. </iq>
  852. <iq type='error'
  853. from='concentrator@example.org'
  854. to='master@example.org/amr'
  855. id='7'>
  856. <error type='modify'>
  857. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  858. <paramError xmlns='urn:xmpp:iot:control' var='Output'>Invalid parameter type.</error>
  859. </error>
  860. </iq>]]>
  861. </example>
  862. </section3>
  863. <section3 topic='Getting a control form from multiple nodes'>
  864. <p>
  865. A client can get a control form containing available control parameters common between a set of nodes controlled by the concentrator. This is done
  866. 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:
  867. </p>
  868. <example caption='Getting a control form from multiple nodes'>
  869. <![CDATA[
  870. <iq type='get'
  871. from='master@example.org/amr'
  872. to='concentrator@example.org'
  873. id='8'>
  874. <getForm xmlns='urn:xmpp:iot:control' xml:lang='en'>
  875. <node nodeId='DigitalOutput1'/>
  876. <node nodeId='DigitalOutput2'/>
  877. <node nodeId='DigitalOutput3'/>
  878. <node nodeId='DigitalOutput4'/>
  879. </getForm>
  880. </iq>
  881. <iq type='result'
  882. from='concentrator@example.org'
  883. to='master@example.org/amr'
  884. id='8'>
  885. <x type='form'
  886. xmlns='jabber:x:data'
  887. xmlns:xdv='http://jabber.org/protocol/xdata-validate'
  888. xmlns:xdl:='http://jabber.org/protocol/xdata-layout'
  889. xmlns:xdd:='urn:xmpp:xdata:dynamic'>
  890. <title>DigitalOutput1, DigitalOutput2, ...</title>
  891. <xdl:page label='Output'>
  892. <xdl:fieldref var='Output'/>
  893. </xdl:page>
  894. <field var='xdd session' type='hidden'>
  895. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  896. </field>
  897. <field var='Output' type='boolean' label='Output'>
  898. <desc>If the digital output is high (checked) or low (uncheckd).</desc>
  899. <value>true</value>
  900. <xdd:notSame/>
  901. </field>
  902. </x>
  903. </iq>]]>
  904. </example>
  905. <p>
  906. Note that only parameters that are common between the nodes defined in the request must be returned. However, all parameters must have the
  907. <strong>notSame</strong> flag set, regardless of current output status.
  908. </p>
  909. </section3>
  910. <section3 topic='Getting a control form from multiple nodes, Failure'>
  911. <p>
  912. 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
  913. a control form request, because it does not support the handling of common parameters between multiple nodes:
  914. </p>
  915. <example caption='Getting a control form from multiple nodes, Failure'>
  916. <![CDATA[
  917. <iq type='get'
  918. from='master@example.org/amr'
  919. to='concentrator@example.org'
  920. id='9'>
  921. <getForm xmlns='urn:xmpp:iot:control' xml:lang='en'>
  922. <node nodeId='DigitalOutput1'/>
  923. <node nodeId='DigitalOutput2'/>
  924. <node nodeId='DigitalOutput3'/>
  925. <node nodeId='DigitalOutput4'/>
  926. </getForm>
  927. </iq>
  928. <iq type='error'
  929. from='concentrator@example.org'
  930. to='master@example.org/amr'
  931. id='9'>
  932. <error type='cancel'>
  933. <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  934. <text xmlns='urn:ietf:params:xml:ns:xmpp-stanzas' xml:lang='en'>Cannot merge control forms from different nodes.</text>
  935. </error>
  936. </iq>]]>
  937. </example>
  938. </section3>
  939. <section3 topic='Setting a (partial) control form to multiple nodes'>
  940. <p>
  941. You set a control form to multiple nodes controlled by a
  942. concentrator by adding <strong>node</strong> elements to the
  943. <strong>set</strong> command sent to the concentrator, as is
  944. shown in the following example:
  945. </p>
  946. <example caption='Setting a (partial) control form to multiple nodes'>
  947. <![CDATA[
  948. <iq type='set'
  949. from='master@example.org/amr'
  950. to='concentrator@example.org'
  951. id='10'>
  952. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  953. <node nodeId='DigitalOutput1'/>
  954. <node nodeId='DigitalOutput2'/>
  955. <node nodeId='DigitalOutput3'/>
  956. <node nodeId='DigitalOutput4'/>
  957. <x type='submit' xmlns='jabber:x:data'>
  958. <field var='xdd session' type='hidden'>
  959. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  960. </field>
  961. <field var='Output' type='boolean'>
  962. <value>true</value>
  963. </field>
  964. </x>
  965. </set>
  966. </iq>
  967. <iq type='result'
  968. from='concentrator@example.org'
  969. to='master@example.org/amr'
  970. id='10'>
  971. <setResponse xmlns='urn:xmpp:iot:control' />
  972. </iq>]]>
  973. </example>
  974. </section3>
  975. <section3 topic='Setting a (partial) control form to multiple nodes, Failure'>
  976. <p>
  977. 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
  978. 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.
  979. </p>
  980. <example caption='Setting a (partial) control form to multiple nodes'>
  981. <![CDATA[
  982. <iq type='set'
  983. from='master@example.org/amr'
  984. to='concentrator@example.org'
  985. id='11'>
  986. <set xmlns='urn:xmpp:iot:control' xml:lang='en'>
  987. <node nodeId='DigitalOutput1'/>
  988. <node nodeId='DigitalOutput2'/>
  989. <node nodeId='DigitalOutput3'/>
  990. <node nodeId='DigitalOutput4'/>
  991. <node nodeId='AnalogOutput1'/>
  992. <node nodeId='AnalogOutput2'/>
  993. <node nodeId='AnalogOutput3'/>
  994. <node nodeId='AnalogOutput4'/>
  995. <x type='submit' xmlns='jabber:x:data'>
  996. <field var='xdd session' type='hidden'>
  997. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  998. </field>
  999. <field var='Output' type='boolean'>
  1000. <value>true</value>
  1001. </field>
  1002. </x>
  1003. </set>
  1004. </iq>
  1005. <iq type='error'
  1006. from='concentrator@example.org'
  1007. to='master@example.org/amr'
  1008. id='11'>
  1009. <error type='modify'>
  1010. <bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  1011. <paramError xmlns='urn:xmpp:iot:control' var='Output'>Invalid type.</error>
  1012. </error>
  1013. </iq>]]>
  1014. </example>
  1015. </section3>
  1016. </section2>
  1017. </section1>
  1018. <section1 topic='Determining Support' anchor='support'>
  1019. <p>If an entity supports the protocol specified herein, it MUST advertise that fact by returning a feature of "urn:xmpp:iot:control" in response to &xep0030; information requests.</p>
  1020. <example caption="Service discovery information request">
  1021. <![CDATA[
  1022. <iq type='get'
  1023. from='device@example.org/device'
  1024. to='provisioning@example.org'
  1025. id='disco1'>
  1026. <query xmlns='http://jabber.org/protocol/disco#info'/>
  1027. </iq>]]>
  1028. </example>
  1029. <example caption="Service discovery information response">
  1030. <![CDATA[
  1031. <iq type='result'
  1032. from='provisioning@example.org'
  1033. to='device@example.org/device'
  1034. id='disco1'>
  1035. <query xmlns='http://jabber.org/protocol/disco#info'>
  1036. ...
  1037. <feature var='urn:xmpp:iot:control'/>
  1038. ...
  1039. </query>
  1040. </iq>]]>
  1041. </example>
  1042. <p>
  1043. In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined
  1044. in &xep0115;. However, if an application has not received entity capabilities information from an entity, it SHOULD use explicit service discovery instead.
  1045. </p>
  1046. </section1>
  1047. <section1 topic='Implementation Notes' anchor='impl'>
  1048. <section2 topic='IQ Error Stanzas' anchor='errors'>
  1049. <p>
  1050. Depending on the reason for rejecting a control request, different XMPP errors can be returned, according to the description in the following table. The table also
  1051. lists recommended error type for each error. Error stanzas may also include <strong>paramError</strong> child elements to provide additional textual error information that
  1052. corresponds to a particular control parameter provided in the request. Any custom error message not related to control parameters is returned in a <strong>text</strong>
  1053. element.
  1054. </p>
  1055. <table caption='XMPP Errors when rejecting a readout request'>
  1056. <tr>
  1057. <th>Error Type</th>
  1058. <th>Error Element</th>
  1059. <th>Namespace</th>
  1060. <th>Description</th>
  1061. </tr>
  1062. <tr>
  1063. <td>cancel</td>
  1064. <td>forbidden</td>
  1065. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  1066. <td>If the caller lacks privileges to perform the action.</td>
  1067. </tr>
  1068. <tr>
  1069. <td>cancel</td>
  1070. <td>item-not-found</td>
  1071. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  1072. <td>If an item, parameter or data source could not be found.</td>
  1073. </tr>
  1074. <tr>
  1075. <td>modify</td>
  1076. <td>bad-request</td>
  1077. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  1078. <td>If the request was malformed. Examples can include trying to set a parameter to a value outside the allowed range.</td>
  1079. </tr>
  1080. <tr>
  1081. <td>cancel</td>
  1082. <td>feature-not-implemented</td>
  1083. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  1084. <td>If an action has not been implemented in the device.</td>
  1085. </tr>
  1086. <tr>
  1087. <td>wait</td>
  1088. <td>conflict</td>
  1089. <td>urn:ietf:params:xml:ns:xmpp-stanzas</td>
  1090. <td>If an item was locked by another user or process and could not be accessed. The operation can be retried at a later point in time.</td>
  1091. </tr>
  1092. </table>
  1093. </section2>
  1094. <section2 topic='Reading current control states' anchor='currentstates'>
  1095. <section3 topic='Using Control Forms'>
  1096. <p>
  1097. The simplest way to read the current control states of a device, is to request the control form of the device. The control form should contain the current
  1098. values for all avilable control parameters. However, since current states might not be available at the time of the request, the states might be delivered
  1099. asynchronously, using messages defined in &xep0336;.
  1100. </p>
  1101. <p>
  1102. Using this method has the advantage that a small actuator device does not need to implement other XEPs to support readout of current control states. If the device
  1103. contains all current states readily accessible, there's no need of asynchronous updates making readout simple and straightforward.
  1104. </p>
  1105. </section3>
  1106. <section3 topic='Using XEP-0323 (Sensor Data)'>
  1107. <p>
  1108. A second option is to use &xep0323; to deliver current control states. Since this XEP contains mechanisms allowing for asynchronous readout of control parameter
  1109. states. This makes readout of such parameters simpler. However, there's a need to map values between the two XEPs.
  1110. </p>
  1111. <p>
  1112. If a client wants to know the current status of control parameters using this method, it performs a readout of <strong>Momentary</strong> and <strong>Status</strong> values
  1113. from the device, and from the returned set of values take the current control parameter value according to the following rules, ordered by priority:
  1114. </p>
  1115. <ul>
  1116. <li>
  1117. <p>
  1118. If there's a field marked as momentary value, with an unlocalized field name equal to the unlocalized control parameter name and having a compatible
  1119. field value type (see table below) and a status field without the missing flag set, the value of the field should be considered the current value of
  1120. the control parameter.
  1121. </p>
  1122. </li>
  1123. <li>
  1124. <p>
  1125. If there's a field marked as status value, with an unlocalized field name equal to the unlocalized control parameter name and having a compatible
  1126. field value type (see table below) and a status field without the missing flag set, the value of the field should be considered the current value of
  1127. the control parameter.
  1128. </p>
  1129. </li>
  1130. <li>
  1131. <p>
  1132. To simplify mapping, a <strong>writable</strong> attribute can be used to inform the client if a field name corresponds to a control parameter or not. If the
  1133. attribute is available, it tells the client if it corresponds to a control parameter or not. If not available, no such deduction can be made.
  1134. </p>
  1135. </li>
  1136. </ul>
  1137. <p>
  1138. Even though getting the the control form could provide the client with a quicker and easier way of retrieving control parameter values, the form is not
  1139. guaranteed to contain correct current values, as described above.
  1140. </p>
  1141. <p>
  1142. The following table shows how corresponding field values should be converted to the corresponding control parameter value based on field type (x-axis) and
  1143. control parameter type (y-axis). An empty cell means conversion has no meaning and types are not compatible.
  1144. </p>
  1145. <table caption='Conversion of Field Value to Control Parameter Value based on types'>
  1146. <tr>
  1147. <th>325 \ 323</th>
  1148. <th>boolean</th>
  1149. <th>date</th>
  1150. <th>dateTime</th>
  1151. <th>duration</th>
  1152. <th>enum</th>
  1153. <th>int</th>
  1154. <th>long</th>
  1155. <th>numeric</th>
  1156. <th>string</th>
  1157. <th>time</th>
  1158. </tr>
  1159. <tr>
  1160. <th>boolean</th>
  1161. <td>x</td>
  1162. <td>&nbsp;</td>
  1163. <td>&nbsp;</td>
  1164. <td>&nbsp;</td>
  1165. <td>&nbsp;</td>
  1166. <td>!=0</td>
  1167. <td>!=0</td>
  1168. <td>!=0</td>
  1169. <td>&nbsp;</td>
  1170. <td>&nbsp;</td>
  1171. </tr>
  1172. <tr>
  1173. <th>color</th>
  1174. <td>&nbsp;</td>
  1175. <td>&nbsp;</td>
  1176. <td>&nbsp;</td>
  1177. <td>&nbsp;</td>
  1178. <td>&nbsp;</td>
  1179. <td>&nbsp;</td>
  1180. <td>&nbsp;</td>
  1181. <td>&nbsp;</td>
  1182. <td>RRGGBB or RRGGBBAA</td>
  1183. <td>&nbsp;</td>
  1184. </tr>
  1185. <tr>
  1186. <th>date</th>
  1187. <td>&nbsp;</td>
  1188. <td>x</td>
  1189. <td>Date part</td>
  1190. <td>&nbsp;</td>
  1191. <td>&nbsp;</td>
  1192. <td>&nbsp;</td>
  1193. <td>&nbsp;</td>
  1194. <td>&nbsp;</td>
  1195. <td>(1)</td>
  1196. <td>&nbsp;</td>
  1197. </tr>
  1198. <tr>
  1199. <th>dateTime</th>
  1200. <td>&nbsp;</td>
  1201. <td>x</td>
  1202. <td>x</td>
  1203. <td>&nbsp;</td>
  1204. <td>&nbsp;</td>
  1205. <td>&nbsp;</td>
  1206. <td>&nbsp;</td>
  1207. <td>&nbsp;</td>
  1208. <td>(2)</td>
  1209. <td>&nbsp;</td>
  1210. </tr>
  1211. <tr>
  1212. <th>double</th>
  1213. <td>Z2</td>
  1214. <td>&nbsp;</td>
  1215. <td>&nbsp;</td>
  1216. <td>&nbsp;</td>
  1217. <td>&nbsp;</td>
  1218. <td>x</td>
  1219. <td>x</td>
  1220. <td>x</td>
  1221. <td>(3)</td>
  1222. <td>&nbsp;</td>
  1223. </tr>
  1224. <tr>
  1225. <th>duration</th>
  1226. <td>&nbsp;</td>
  1227. <td>&nbsp;</td>
  1228. <td>&nbsp;</td>
  1229. <td>x</td>
  1230. <td>&nbsp;</td>
  1231. <td>&nbsp;</td>
  1232. <td>&nbsp;</td>
  1233. <td>&nbsp;</td>
  1234. <td>(4)</td>
  1235. <td>x</td>
  1236. </tr>
  1237. <tr>
  1238. <th>int</th>
  1239. <td>Z2</td>
  1240. <td>&nbsp;</td>
  1241. <td>&nbsp;</td>
  1242. <td>&nbsp;</td>
  1243. <td>Ordinal</td>
  1244. <td>x</td>
  1245. <td>Thunk</td>
  1246. <td>Thunk</td>
  1247. <td>(5)</td>
  1248. <td>&nbsp;</td>
  1249. </tr>
  1250. <tr>
  1251. <th>long</th>
  1252. <td>Z2</td>
  1253. <td>&nbsp;</td>
  1254. <td>&nbsp;</td>
  1255. <td>&nbsp;</td>
  1256. <td>Ordinal</td>
  1257. <td>x</td>
  1258. <td>x</td>
  1259. <td>Thunk</td>
  1260. <td>(5)</td>
  1261. <td>&nbsp;</td>
  1262. </tr>
  1263. <tr>
  1264. <th>string</th>
  1265. <td>xs:boolean</td>
  1266. <td>xs:date</td>
  1267. <td>xs:dateTime</td>
  1268. <td>xs:duration</td>
  1269. <td>x</td>
  1270. <td>xs:int</td>
  1271. <td>xs:long</td>
  1272. <td>(6)</td>
  1273. <td>x</td>
  1274. <td>xs:time</td>
  1275. </tr>
  1276. <tr>
  1277. <th>time</th>
  1278. <td>&nbsp;</td>
  1279. <td>&nbsp;</td>
  1280. <td>Time part</td>
  1281. <td>(7)</td>
  1282. <td>&nbsp;</td>
  1283. <td>&nbsp;</td>
  1284. <td>&nbsp;</td>
  1285. <td>&nbsp;</td>
  1286. <td>(8)</td>
  1287. <td>x</td>
  1288. </tr>
  1289. </table>
  1290. <p>
  1291. The following table lists notes with details on how to do conversion, if in doubt.
  1292. </p>
  1293. <table caption="Conversion rules">
  1294. <tr>
  1295. <th>Note</th>
  1296. <th>Description</th>
  1297. </tr>
  1298. <tr>
  1299. <td>(1)</td>
  1300. <td>
  1301. The client should try to convert the string to a date value, first according to the format specified by the XML data type xs:date, and if not possible
  1302. by RFC 822.
  1303. </td>
  1304. </tr>
  1305. <tr>
  1306. <td>(2)</td>
  1307. <td>
  1308. The client should try to convert the string to a date &amp; time value, first according to the format specified by the XML data type xs:dateTime, and if not possible
  1309. by RFC 822.
  1310. </td>
  1311. </tr>
  1312. <tr>
  1313. <td>(3)</td>
  1314. <td>
  1315. The client should try to convert the string to a double-precision floating-point value, first according to the format specified by the XML data type xs:double,
  1316. and if not possible using system-local string to floating-point conversion using local decimal and throusand separator settings.
  1317. </td>
  1318. </tr>
  1319. <tr>
  1320. <td>(4)</td>
  1321. <td>
  1322. The client should try to convert the string to a duration value, first according to the format specified by the XML data type xs:duration,
  1323. and if not possible using the XML data type xs:time.
  1324. </td>
  1325. </tr>
  1326. <tr>
  1327. <td>(5)</td>
  1328. <td>The client should try to convert the string to an integer value according to the corresponding XML data type formats xs:int and xs:long.</td>
  1329. </tr>
  1330. <tr>
  1331. <td>(6)</td>
  1332. <td>
  1333. The numeric field value consists of three parts: Numeric value, number of decimals and optional unit. If no unit is provided, only the numeric value should
  1334. be converted to a string (compatible with the XML data type xs:double), using exactly the number of decimals provided in the field. If a unit is provided
  1335. (non-empty string) it must not be appended to the value, if the value is to be used for control output. For presentation purposes however, a space could be
  1336. appended to the number and the unit appended after the space.
  1337. </td>
  1338. </tr>
  1339. <tr>
  1340. <td>(7)</td>
  1341. <td>
  1342. A duration field value contains a xs:duration value. The xs:duration has a larger domain than xs:time, and contains all xs:time values, but xs:time does
  1343. not contain all possible xs:duration values. So, conversion of an xs:duration value to an xs:time value should be performed only if a duration lies
  1344. between 00:00:00 and 23:59:59.
  1345. </td>
  1346. </tr>
  1347. <tr>
  1348. <td>(8)</td>
  1349. <td>
  1350. The client should try to convert the string to a time value according to the format specified by the XML data type xs:time.
  1351. </td>
  1352. </tr>
  1353. <tr>
  1354. <td>x</td>
  1355. <td>Use the canonical conversion method.</td>
  1356. </tr>
  1357. <tr>
  1358. <td>Z2</td>
  1359. <td>true = 1, false = 0.</td>
  1360. </tr>
  1361. <tr>
  1362. <td>!=0</td>
  1363. <td>Nonzero = true, Zero = false.</td>
  1364. </tr>
  1365. <tr>
  1366. <td>RRGGBB</td>
  1367. <td>A string of six hexadecimal characters, the first two the red component of the color, the next two the green component and the last two the blue component.</td>
  1368. </tr>
  1369. <tr>
  1370. <td>RRGGBBAA</td>
  1371. <td>A string of eight hexadecimal characters, the first two the red component of the color, the next two the green component, the following two the blue component and the last two the alpha channel.</td>
  1372. </tr>
  1373. <tr>
  1374. <td>Date part</td>
  1375. <td>Only the date part of the xs:dateTime value should be used.</td>
  1376. </tr>
  1377. <tr>
  1378. <td>Time part</td>
  1379. <td>Only the time part of the xs:dateTime value should be used.</td>
  1380. </tr>
  1381. <tr>
  1382. <td>Ordinal</td>
  1383. <td>Each enumeration value may in the implementation correspond to an ordinal number.</td>
  1384. </tr>
  1385. <tr>
  1386. <td>Thunk</td>
  1387. <td>The value is thunked down to lower precision in the canonical way.</td>
  1388. </tr>
  1389. <tr>
  1390. <td>xs:boolean</td>
  1391. <td>Conversion to a string should follow the rules specified for the XML datatype xs:boolean.</td>
  1392. </tr>
  1393. <tr>
  1394. <td>xs:dateTime</td>
  1395. <td>Conversion to a string should follow the rules specified for the XML datatype xs:dateTime.</td>
  1396. </tr>
  1397. <tr>
  1398. <td>xs:duration</td>
  1399. <td>Conversion to a string should follow the rules specified for the XML datatype xs:duration.</td>
  1400. </tr>
  1401. </table>
  1402. <p>
  1403. <strong>Note:</strong> the namespace prefix <strong>xs</strong> is here supposed to be linked with the XML Schema namespace
  1404. <link url="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</link>.
  1405. </p>
  1406. </section3>
  1407. <section3 topic='Harmonization with XEP-0323 (Sensor Data)' anchor='harmonization'>
  1408. <p>
  1409. When representing control parameters as momentary field values, it is important to note the similarities and differences between XEP-0323 (Sensor Data) and XEP-0325 (this document):
  1410. </p>
  1411. <p>
  1412. The <strong>enum</strong> field value data type is not available in XEP-0325 (this document). Instead enumeration valued parameters are represented as <strong>string</strong> control
  1413. parameters, while the control form explicitly lists available options for the parameter. Options are not available in XEP-0323, since it would not be practical to list all options
  1414. every time the corresponding parameter was read out. Instead, the <strong>enum</strong> element contains a data type attribute, that can be used to identify the type of the enumeration.
  1415. </p>
  1416. <p>
  1417. The <strong>numeric</strong> field value data type is not available in XEP-0325 (this document). The reason is that a controller is not assumed to understand unit conversion. Any
  1418. floating-point valued control parameters are represented by <strong>double</strong> control parameters, which lack a unit attribute. They are assumed to have the same unit as
  1419. the corresponding <strong>numeric</strong> field value. On the other hand, floating point valued control parameters without units, are reported using the <strong>numeric</strong>
  1420. field element, but leaving the unit blank.
  1421. </p>
  1422. <p>
  1423. Control pameters of type <strong>color</strong> have no corresponding field value data type. The color value must be represented in another way, and is implementation specific.
  1424. Possibilities include representing the color as a string, using a specific pattern (for instance RRGGBBAA), or report it using multiple fields, one for each component for instance.
  1425. </p>
  1426. <p>
  1427. The <strong>boolean</strong>, <strong>date</strong>, <strong>dateTime</strong>, <strong>duration</strong>, <strong>int</strong>, <strong>long</strong>, <strong>string</strong>
  1428. and <strong>time</strong> field value data types correspond to control parameters having the same types and same element names.
  1429. </p>
  1430. </section3>
  1431. </section2>
  1432. <section2 topic='Difference between node parameters and node control parameters' anchor='nodeparamsvscontrolparams'>
  1433. <p>
  1434. A node defined in a concentrator, as defined by <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>, supporting control has
  1435. two sets of parameters that are different: First a set of node parameters and then a set of control parameters.
  1436. </p>
  1437. <p>
  1438. Node parameters are defined by the node type in the concentrator, as described in <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>,
  1439. and they are typically used by the concentrator to define the node and how to communicate or interact with the underlying device. The important part here is to know
  1440. that the node parameters are maintained by the concentrator, not the underlying device.
  1441. </p>
  1442. <p>
  1443. Control parameters however, are parameters that reside on the underlying device. When set, they change the actual state or behaviour of the underlying device.
  1444. The connection to the device however, controlled by the concentrator, remains unchanged by such a control parameter update.
  1445. </p>
  1446. </section2>
  1447. <section2 topic='Grouping control parameters' anchor='parametergroups'>
  1448. <p>
  1449. Many control actions available in a device can be controlled using only one control parameter. If a device only publishes such control parameters, the order
  1450. of control parameters is not that important.
  1451. </p>
  1452. <p>
  1453. However, there are many control actions that require the client to set multiple control parameters at the same time, for the device to have a complete understanding
  1454. what the client wants to do.
  1455. </p>
  1456. <p>
  1457. <link url='http://xmpp.org/extensions/xep-0141.html'>XEP-0141</link> defines a way to group parameters in a data form by including the concept of pages and sections.
  1458. Even though these pages and sections are used for layout purposes, it should be used by devices to mark parameters that should be used together to perform control actions.
  1459. </p>
  1460. <p>
  1461. The following set of rules should be adhered to, by devices as well as clients, to minimize confusion and resulting errors:
  1462. </p>
  1463. <ul>
  1464. <li>
  1465. <p>
  1466. Control parameters should be listed in control forms in the order the device expects the client to write them back.
  1467. </p>
  1468. </li>
  1469. <li>
  1470. <p>
  1471. Clients should set control parameters in the order they are listed in the corresponding control forms.
  1472. </p>
  1473. </li>
  1474. <li>
  1475. <p>
  1476. Control actions that require multiple control parameters should report these together, grouped by pages or sections within pages,
  1477. to make clear that the parameters belong together.
  1478. </p>
  1479. </li>
  1480. <li>
  1481. <p>
  1482. For control actions requiring multiple control parameters, devices should strive to publish default values for all parameters involved.
  1483. These default values should then be used by the device if a client happens to write only a subset of the control parameters required for
  1484. a control action. The default value could be the current state of the parameter.
  1485. </p>
  1486. </li>
  1487. </ul>
  1488. <p>
  1489. Note however, that one cannot always make the assumption that parameters on the same page or same section in a control form belong to the same control action.
  1490. For instance, a PLC with 16 digital outputs might publish a control form containing a single page with 16 check boxes on (boolean parameters), that can be
  1491. controlled individually.
  1492. </p>
  1493. <p>
  1494. To solve the problem of grouping parameters together, so a client can know which parameters belong together, a new element is defined that can be used in
  1495. data forms: <strong>parameterGroup</strong>. It is optional, but can be added to control parameters in forms, as a way to tell the client that parameters
  1496. having the same <strong>parameterGroup</strong> belong together and should be written together.
  1497. </p>
  1498. <p>
  1499. <strong>Note:</strong> If used, the server must not include a parameter in more than one parameter group at a time. The form may contain multiple group, but each
  1500. parameter must only have at most one <strong>parameterGroup</strong> element.
  1501. </p>
  1502. <p>
  1503. The following example illustrates the use of the <strong>parameterGroup</strong> element to group parameters together.
  1504. </p>
  1505. <example caption='Grouping control parameters'>
  1506. <![CDATA[
  1507. <iq type='get'
  1508. from='master@example.org/amr'
  1509. to='spotlight@example.org'
  1510. id='12'>
  1511. <getForm xmlns='urn:xmpp:iot:control' xml:lang='en'/>
  1512. </iq>
  1513. <iq type='result'
  1514. from='spotlight@example.org'
  1515. to='master@example.org/amr'
  1516. id='12'>
  1517. <x type='form'
  1518. xmlns='jabber:x:data'
  1519. xmlns:xdv='http://jabber.org/protocol/xdata-validate'
  1520. xmlns:xdl:='http://jabber.org/protocol/xdata-layout'
  1521. xmlns:xdd:='urn:xmpp:xdata:dynamic'>
  1522. <title>Spotlight</title>
  1523. <xdl:page label='Output'>
  1524. <xdl:fieldref var='MainSwitch'/>
  1525. </xdl:page>
  1526. <xdl:page label='Direction'>
  1527. <xdl:fieldref var='HorizontalAngle'/>
  1528. <xdl:fieldref var='ElevationAngle'/>
  1529. </xdl:page>
  1530. <field var='xdd session' type='hidden'>
  1531. <value>325ED0F3-9A9A-45A4-9634-4E0D41C5EA06</value>
  1532. </field>
  1533. <field var='MainSwitch' type='boolean' label='Main switch'>
  1534. <desc>If the spotlight is turned on or off.</desc>
  1535. <value>true</value>
  1536. <xdd:notSame/>
  1537. </field>
  1538. <field var='HorizontalAngle' type='text-single' label='Horizontal angle:'>
  1539. <desc>Horizontal angle of the spotlight.</desc>
  1540. <value>0</value>
  1541. <xdv:validate datatype='xs:double'>
  1542. <xdv:range min='-180' max='180'/>
  1543. </xdv:validate>
  1544. <xdd:notSame/>
  1545. <parameterGroup xmlns='urn:xmpp:iot:control' name='direction'/>
  1546. </field>
  1547. <field var='ElevationAngle' type='text-single' label='Elevation angle:'>
  1548. <desc>Elevation angle of the spotlight.</desc>
  1549. <value>0</value>
  1550. <xdv:validate datatype='xs:double'>
  1551. <xdv:range min='-90' max='90'/>
  1552. </xdv:validate>
  1553. <xdd:notSame/>
  1554. <parameterGroup xmlns='urn:xmpp:iot:control' name='direction'/>
  1555. </field>
  1556. </x>
  1557. </iq>]]>
  1558. </example>
  1559. <p>
  1560. The above example informs the client that the two parameters HorizontalAngle and ElevationAngle should be written together to control a control action
  1561. (named direction).
  1562. </p>
  1563. <p>
  1564. For more information about common control actions and their parameters, see <link url='xep-0000-IoT-Interoperability.html'>xep-0000-IoT-Interoperability.html</link>,
  1565. which defines a set of interoperable interfaces and their abilities.
  1566. </p>
  1567. </section2>
  1568. <section2 topic='Node commands vs. control parameters' anchor='commandsvsparameters'>
  1569. <p>
  1570. Nodes behind a concentrator, as defined in <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>, have an additional means of
  1571. publishing control interfaces: Node Commands.
  1572. </p>
  1573. <p>
  1574. However, there are many differences between Node Commands and Control Parameters, as shown in the following list:
  1575. </p>
  1576. <ul>
  1577. <li>
  1578. <p>
  1579. Node Commands are defined by the node type in the concentrator, and not by the device itself.
  1580. </p>
  1581. </li>
  1582. <li>
  1583. <p>
  1584. Node Commands may do many different things, not only performing control actions.
  1585. </p>
  1586. </li>
  1587. <li>
  1588. <p>
  1589. Parametrized Node Commands require the client to always get a parameter data form, and write back values. There's no way to send simple
  1590. control messages using Node Commands.
  1591. </p>
  1592. </li>
  1593. <li>
  1594. <p>
  1595. Node Commands can be partitioned, grouped and sorted separately.
  1596. </p>
  1597. </li>
  1598. <li>
  1599. <p>
  1600. Each Parametrized Node Command has a separate parameter form, which makes grouping of parameters normal.
  1601. </p>
  1602. </li>
  1603. <li>
  1604. <p>
  1605. Node Commands are only available for nodes controlled by a concentrator.
  1606. </p>
  1607. </li>
  1608. </ul>
  1609. <p>
  1610. If implementing a device with many complex control actions (like an advanced PLC), consideration should be made to divide the device into logical groups and
  1611. implement the concentrators interface as well. Then the more complex control actions could be implemented as Node Commands instead of control actions
  1612. as defined in this document, and implementing the simpler more intuitive control actions as described in this document.
  1613. </p>
  1614. </section2>
  1615. <section2 topic='Tokens' anchor='tokens'>
  1616. <p>
  1617. If control interaction is performed in a context of delegated trust, as defined in the Sensor Network Provisioning XEP-0324 &xep0324;,
  1618. tokens should always be included in all calls. This to allow devices to check privileges with provisioning servers.
  1619. </p>
  1620. <p>
  1621. The <strong>set</strong> and <strong>getForm</strong> commands support the following token attributes:
  1622. </p>
  1623. <ul>
  1624. <li>
  1625. <strong>serviceToken</strong>
  1626. </li>
  1627. <li>
  1628. <strong>deviceToken</strong>
  1629. </li>
  1630. <li>
  1631. <strong>userToken</strong>
  1632. </li>
  1633. </ul>
  1634. <p>
  1635. For more information about provisioning, see <link url='http://xmpp.org/extensions/xep-0324.html'>Internet of Things - Provisioning</link>.
  1636. </p>
  1637. </section2>
  1638. <section2 topic='Controlling devices in large subsystems' anchor='largesubsystems'>
  1639. <p>
  1640. Most examples in this document have been simplified examples where a few devices containing a few control parameters have been used. However, in many cases large subsystems with
  1641. very many actuators containing many different control actions have to be controlled, as is documented in
  1642. <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>.
  1643. In such cases, a node may have to be specified using two or perhaps even three ID's: a <strong>sourceId</strong> identifying the data source controlling the device, a possible
  1644. <strong>cacheType</strong> narrowing down the search to a specific kind of node, and the common <strong>nodeId</strong>. For more information about this, see
  1645. <link url='http://xmpp.org/extensions/xep-0326.html'>Internet of Things - Concentrators</link>.
  1646. </p>
  1647. <p>
  1648. <strong>Note:</strong> For cases where the <strong>nodeId</strong> is sufficient to uniquely identify the node, it is sufficient to provide this attribute in the request.
  1649. If there is ambiguity in the request, the receptor must treat the request as a request with a set of nodes, all with the corresponding <strong>nodeId</strong> as requested.
  1650. </p>
  1651. </section2>
  1652. </section1>
  1653. <section1 topic='Internationalization Considerations' anchor='i18n'>
  1654. <section2 topic='Time Zones' anchor='timezones'>
  1655. <p>
  1656. All timestamps and dateTime values use the XML data type xs:dateTime to specify values. These values include a date, an optional time and an optional time zone.
  1657. </p>
  1658. <p>
  1659. <strong>Note:</strong> If time zone is not available, it is supposed to be undefined. The client reading the sensor that reports fields without time zone information
  1660. should assume the sensor has the same time zone as the client, if not explicitly configured otherwise on the client side.
  1661. </p>
  1662. <p>
  1663. If devices report time zone, this information should be propagated throughout the system. Otherwise, comparing timestamps from different time zones will be impossible.
  1664. </p>
  1665. </section2>
  1666. <section2 topic='xml:lang' anchor='lang'>
  1667. <p>
  1668. Control commands sent using IQ stanzas instead of messages, should consider using the <strong>xml:lang</strong> attribute to specify the desired language
  1669. used (if possible) when returning information back to the caller, like error messages, localized control forms, etc.
  1670. </p>
  1671. </section2>
  1672. </section1>
  1673. <section1 topic='Security Considerations' anchor='security'>
  1674. <p>
  1675. Controlling devices in a large sensor network is a hackers wet dream. Therefore, consideration of how network security is implemented should not be underestimated.
  1676. The following sections provide some general items that should be considered.
  1677. </p>
  1678. <section2 topic='Encryption &amp; Authentication' anchor='encauth'>
  1679. <p>
  1680. Consider to always use an encrypted connection with any XMPP Server used in the network. Also, make sure the server is properly authenticated and any server
  1681. certificate properly validated.
  1682. </p>
  1683. <p>
  1684. Control commands should only be accepted by trusted parties. A minimum is to make sure only authenticated and validated clients (friends) can perform control actions
  1685. on the device.
  1686. </p>
  1687. </section2>
  1688. <section2 topic='Provisioning' anchor='provisioning'>
  1689. <p>
  1690. Consider using provisioning servers to allow for detailed control of who can do what in a sensor network. Implementing proper provisioning support decreases
  1691. the risk for adverse effects, not only from intentional hacking, but also from unintentional errors.
  1692. </p>
  1693. <p>
  1694. If using delegated trust, make sure the provisioning servers are properly authenticated and validated before trusting them.
  1695. </p>
  1696. <p>
  1697. More information about provisioning can be found in <link url='http://xmpp.org/extensions/xep-0324.html'>Internet of Things - Provisioning</link>.
  1698. </p>
  1699. </section2>
  1700. </section1>
  1701. <section1 topic='IANA Considerations' anchor='iana'>
  1702. <p>This document requires no interaction with &IANA;.</p>
  1703. </section1>
  1704. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  1705. <p>
  1706. The <link url="#schema">protocol schema</link> needs to be added to the list of <link url="http://xmpp.org/resources/schemas/">XMPP protocol schemas</link>.
  1707. </p>
  1708. </section1>
  1709. <section1 topic='XML Schema' anchor='schema'>
  1710. <code>
  1711. <![CDATA[
  1712. <?xml version='1.0' encoding='UTF-8'?>
  1713. <xs:schema
  1714. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  1715. targetNamespace='urn:xmpp:iot:control'
  1716. xmlns='urn:xmpp:iot:control'
  1717. xmlns:sn='urn:xmpp:iot:sensordata'
  1718. xmlns:xd="jabber:x:data"
  1719. xmlns:xdv="http://jabber.org/protocol/xdata-validate"
  1720. xmlns:xdl="http://jabber.org/protocol/xdata-layout"
  1721. elementFormDefault='qualified'>
  1722. <xs:import namespace='urn:xmpp:iot:sensordata'/>
  1723. <xs:import namespace='jabber:x:data'/>
  1724. <xs:import namespace='http://jabber.org/protocol/xdata-validate'/>
  1725. <xs:import namespace='http://jabber.org/protocol/xdata-layout'/>
  1726. <xs:element name='set'>
  1727. <xs:complexType>
  1728. <xs:choice minOccurs='0' maxOccurs='unbounded'>
  1729. <xs:element name='node' type='NodeReference'/>
  1730. <xs:element name='boolean' type='BooleanParameter'/>
  1731. <xs:element name='color' type='ColorParameter'/>
  1732. <xs:element name='date' type='DateParameter'/>
  1733. <xs:element name='dateTime' type='DateTimeParameter'/>
  1734. <xs:element name='double' type='DoubleParameter'/>
  1735. <xs:element name='duration' type='DurationParameter'/>
  1736. <xs:element name='int' type='IntParameter'/>
  1737. <xs:element name='long' type='LongParameter'/>
  1738. <xs:element name='string' type='StringParameter'/>
  1739. <xs:element name='time' type='TimeParameter'/>
  1740. <xs:element ref='xd:x'/>
  1741. </xs:choice>
  1742. <xs:attributeGroup ref='tokens'/>
  1743. </xs:complexType>
  1744. </xs:element>
  1745. <xs:element name='setResponse'>
  1746. <xs:complexType>
  1747. <xs:choice minOccurs='0' maxOccurs='unbounded'>
  1748. <xs:element name='node' type='NodeReference'/>
  1749. <xs:element name='parameter' type='Parameter'/>
  1750. </xs:choice>
  1751. </xs:complexType>
  1752. </xs:element>
  1753. <xs:element name='paramError' type='ParameterError'/>
  1754. <xs:element name='getForm'>
  1755. <xs:complexType>
  1756. <xs:sequence minOccurs='0' maxOccurs='unbounded'>
  1757. <xs:element name='node' type='NodeReference'/>
  1758. </xs:sequence>
  1759. <xs:attributeGroup ref='tokens'/>
  1760. </xs:complexType>
  1761. </xs:element>
  1762. <xs:element name='parameterGroup'>
  1763. <xs:complexType>
  1764. <xs:attribute name='name' type='xs:string' use='required'/>
  1765. </xs:complexType>
  1766. </xs:element>
  1767. <xs:attributeGroup name='nodeReference'>
  1768. <xs:attribute name='nodeId' type='xs:string' use='required'/>
  1769. <xs:attribute name='sourceId' type='xs:string' use='optional'/>
  1770. <xs:attribute name='cacheType' type='xs:string' use='optional'/>
  1771. </xs:attributeGroup>
  1772. <xs:attributeGroup name='tokens'>
  1773. <xs:attribute name='serviceToken' type='xs:string' use='optional'/>
  1774. <xs:attribute name='deviceToken' type='xs:string' use='optional'/>
  1775. <xs:attribute name='userToken' type='xs:string' use='optional'/>
  1776. </xs:attributeGroup>
  1777. <xs:complexType name='Parameter'>
  1778. <xs:attribute name='name' type='xs:string' use='required'/>
  1779. </xs:complexType>
  1780. <xs:complexType name='BooleanParameter'>
  1781. <xs:complexContent>
  1782. <xs:extension base='Parameter'>
  1783. <xs:attribute name='value' type='xs:boolean' use='required'/>
  1784. </xs:extension>
  1785. </xs:complexContent>
  1786. </xs:complexType>
  1787. <xs:complexType name='ColorParameter'>
  1788. <xs:complexContent>
  1789. <xs:extension base='Parameter'>
  1790. <xs:attribute name='value' type='Color' use='required'/>
  1791. </xs:extension>
  1792. </xs:complexContent>
  1793. </xs:complexType>
  1794. <xs:complexType name='DateParameter'>
  1795. <xs:complexContent>
  1796. <xs:extension base='Parameter'>
  1797. <xs:attribute name='value' type='xs:date' use='required'/>
  1798. </xs:extension>
  1799. </xs:complexContent>
  1800. </xs:complexType>
  1801. <xs:complexType name='DateTimeParameter'>
  1802. <xs:complexContent>
  1803. <xs:extension base='Parameter'>
  1804. <xs:attribute name='value' type='xs:dateTime' use='required'/>
  1805. </xs:extension>
  1806. </xs:complexContent>
  1807. </xs:complexType>
  1808. <xs:complexType name='DoubleParameter'>
  1809. <xs:complexContent>
  1810. <xs:extension base='Parameter'>
  1811. <xs:attribute name='value' type='xs:double' use='required'/>
  1812. </xs:extension>
  1813. </xs:complexContent>
  1814. </xs:complexType>
  1815. <xs:complexType name='DurationParameter'>
  1816. <xs:complexContent>
  1817. <xs:extension base='Parameter'>
  1818. <xs:attribute name='value' type='xs:duration' use='required'/>
  1819. </xs:extension>
  1820. </xs:complexContent>
  1821. </xs:complexType>
  1822. <xs:complexType name='IntParameter'>
  1823. <xs:complexContent>
  1824. <xs:extension base='Parameter'>
  1825. <xs:attribute name='value' type='xs:int' use='required'/>
  1826. </xs:extension>
  1827. </xs:complexContent>
  1828. </xs:complexType>
  1829. <xs:complexType name='LongParameter'>
  1830. <xs:complexContent>
  1831. <xs:extension base='Parameter'>
  1832. <xs:attribute name='value' type='xs:long' use='required'/>
  1833. </xs:extension>
  1834. </xs:complexContent>
  1835. </xs:complexType>
  1836. <xs:complexType name='StringParameter'>
  1837. <xs:complexContent>
  1838. <xs:extension base='Parameter'>
  1839. <xs:attribute name='value' type='xs:string' use='required'/>
  1840. </xs:extension>
  1841. </xs:complexContent>
  1842. </xs:complexType>
  1843. <xs:complexType name='TimeParameter'>
  1844. <xs:complexContent>
  1845. <xs:extension base='Parameter'>
  1846. <xs:attribute name='value' type='xs:time' use='required'/>
  1847. </xs:extension>
  1848. </xs:complexContent>
  1849. </xs:complexType>
  1850. <xs:complexType name='ParameterError'>
  1851. <xs:simpleContent>
  1852. <xs:extension base='xs:string'>
  1853. <xs:attribute name='var' type='xs:string' use='required'/>
  1854. </xs:extension>
  1855. </xs:simpleContent>
  1856. </xs:complexType>
  1857. <xs:complexType name='NodeReference'>
  1858. <xs:attributeGroup ref='nodeReference'/>
  1859. </xs:complexType>
  1860. <xs:simpleType name='Color'>
  1861. <xs:restriction base='xs:string'>
  1862. <xs:pattern value='^([0-9a-fA-F]{6})|([0-9a-fA-F]{8})$'/>
  1863. </xs:restriction>
  1864. </xs:simpleType>
  1865. </xs:schema>]]>
  1866. </code>
  1867. </section1>
  1868. <section1 topic='For more information' anchor='moreinfo'>
  1869. <p>
  1870. For more information, please see the following resources:
  1871. </p>
  1872. <ul>
  1873. <li>
  1874. <p>
  1875. The <link url='http://wiki.xmpp.org/web/Tech_pages/SensorNetworks'>Sensor Network section of the XMPP Wiki</link> contains further information about the
  1876. use of the sensor network XEPs, links to implementations, discussions, etc.
  1877. </p>
  1878. </li>
  1879. <li>
  1880. <p>
  1881. The XEP's and related projects are also available on <link url='https://github.com/joachimlindborg/'>github</link>, thanks to Joachim Lindborg.
  1882. </p>
  1883. </li>
  1884. <li>
  1885. <p>
  1886. A presentation giving an overview of all extensions related to Internet of Things can be found here:
  1887. <link url='http://prezi.com/esosntqhewhs/iot-xmpp/'>http://prezi.com/esosntqhewhs/iot-xmpp/</link>.
  1888. </p>
  1889. </li>
  1890. </ul>
  1891. </section1>
  1892. <section1 topic='Acknowledgements' anchor='ack'>
  1893. <p>Thanks to Joachim Lindborg and Tina Beckman for all valuable feedback.</p>
  1894. </section1>
  1895. </xep>