Commit 5974ec47 authored by Peter Waher's avatar Peter Waher

Event subscription documentation.

parent ca9e565a
This diff is collapsed.
@startuml
Client -> Device : iq set(subscribe)
Activate Device
Client <- Device : iq result(accepted)
group While subscription active
== Wait for event to trigger ==
Device -> Device : start readout
Activate Device
opt
Client <- Device : message(started)
note right
If readout slow, client can
be alerted that readout has
begun.
end note
end
group Variable number of fragments
== Delay ==
Client <- Device : message(resp[more=true])
note right
Sensor data transmission
can be fragmented into
multiple messages.
end note
end
== Delay ==
Client <- Device : message(resp[more=false])
Deactivate Device
end
Client -> Device : iq set(unsubscribe)
Client <- Device : iq result()
Deactivate Device
@enduml
\ No newline at end of file
@startuml
Subscription "1" --> "*" Node
Subscription "1" --> "*" Field
Subscription : Id
Subscription : Categories
Subscription : Max Age
Subscription : Max Interval
Subscription : Min Interval
Subscription : Tokens
Subscription : Request
Node : Node ID
Node : Source ID
Node : Partition
Field : Name
Field : Current Value
Field : Change By
Field : Change Up
Field : Change Down
@enduml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="329px" preserveAspectRatio="none" style="width:209px;height:329px;" version="1.1" viewBox="0 0 209 329" width="209px" zoomAndPan="magnify"><defs><filter height="300%" id="fririlqtczj7e" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"/><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/></filter></defs><g><!--class Subscription--><rect fill="#FEFECE" filter="url(#fririlqtczj7e)" height="137.6328" id="Subscription" style="stroke: #A80036; stroke-width: 1.5;" width="110" x="41.5" y="8"/><ellipse cx="56.5" cy="24" fill="#ADD1B2" rx="11" ry="11" style="stroke: #A80036; stroke-width: 1.0;"/><path d="M58.8438,19.6719 L59.0156,19.75 C59.2344,19.4375 59.4375,19.3438 59.7344,19.3438 C60.0313,19.3438 60.3125,19.4844 60.4688,19.75 C60.5625,19.9063 60.5781,20.0313 60.5781,20.4688 L60.5781,21.8906 C60.5781,22.3125 60.5469,22.5 60.4375,22.6563 C60.2656,22.875 60,23.0156 59.7344,23.0156 C59.5156,23.0156 59.2813,22.9063 59.1406,22.7656 C59,22.6406 58.9688,22.5156 58.9063,22.1094 C58.8125,21.7031 58.6406,21.4844 58.1563,21.2031 C57.6875,20.9531 57.0781,20.7969 56.5,20.7969 C54.7656,20.7969 53.5156,22.1094 53.5156,23.8906 L53.5156,24.9844 C53.5156,26.6875 54.8125,27.7813 56.8594,27.7813 C57.625,27.7813 58.3125,27.6563 58.7344,27.3906 C58.9219,27.2969 58.9219,27.2969 59.375,26.8125 C59.5625,26.625 59.7656,26.5469 59.9844,26.5469 C60.4531,26.5469 60.8438,26.9375 60.8438,27.3906 C60.8438,27.7813 60.5156,28.2344 59.9375,28.6406 C59.1875,29.1875 58.0313,29.4844 56.8125,29.4844 C53.9219,29.4844 51.8125,27.5938 51.8125,25.0156 L51.8125,23.8906 C51.8125,21.1719 53.8125,19.0938 56.4375,19.0938 C57.3125,19.0938 57.9063,19.2344 58.8438,19.6719 Z "/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="78" x="70.5" y="28.1543">Subscription</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="42.5" x2="150.5" y1="40" y2="40"/><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="10" x="47.5" y="54.2104">Id</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="62" x="47.5" y="67.0151">Categories</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="47" x="47.5" y="79.8198">Max Age</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="68" x="47.5" y="92.6245">Max Interval</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="65" x="47.5" y="105.4292">Min Interval</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="41" x="47.5" y="118.2339">Tokens</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="46" x="47.5" y="131.0386">Request</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="42.5" x2="150.5" y1="137.6328" y2="137.6328"/><!--class Node--><rect fill="#FEFECE" filter="url(#fririlqtczj7e)" height="86.4141" id="Node" style="stroke: #A80036; stroke-width: 1.5;" width="67" x="6" y="219"/><ellipse cx="21.9" cy="235" fill="#ADD1B2" rx="11" ry="11" style="stroke: #A80036; stroke-width: 1.0;"/><path d="M24.2438,230.6719 L24.4156,230.75 C24.6344,230.4375 24.8375,230.3438 25.1344,230.3438 C25.4313,230.3438 25.7125,230.4844 25.8688,230.75 C25.9625,230.9063 25.9781,231.0313 25.9781,231.4688 L25.9781,232.8906 C25.9781,233.3125 25.9469,233.5 25.8375,233.6563 C25.6656,233.875 25.4,234.0156 25.1344,234.0156 C24.9156,234.0156 24.6813,233.9063 24.5406,233.7656 C24.4,233.6406 24.3688,233.5156 24.3063,233.1094 C24.2125,232.7031 24.0406,232.4844 23.5563,232.2031 C23.0875,231.9531 22.4781,231.7969 21.9,231.7969 C20.1656,231.7969 18.9156,233.1094 18.9156,234.8906 L18.9156,235.9844 C18.9156,237.6875 20.2125,238.7813 22.2594,238.7813 C23.025,238.7813 23.7125,238.6563 24.1344,238.3906 C24.3219,238.2969 24.3219,238.2969 24.775,237.8125 C24.9625,237.625 25.1656,237.5469 25.3844,237.5469 C25.8531,237.5469 26.2438,237.9375 26.2438,238.3906 C26.2438,238.7813 25.9156,239.2344 25.3375,239.6406 C24.5875,240.1875 23.4313,240.4844 22.2125,240.4844 C19.3219,240.4844 17.2125,238.5938 17.2125,236.0156 L17.2125,234.8906 C17.2125,232.1719 19.2125,230.0938 21.8375,230.0938 C22.7125,230.0938 23.3063,230.2344 24.2438,230.6719 Z "/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="33" x="36.1" y="239.1543">Node</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="7" x2="72" y1="251" y2="251"/><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="44" x="12" y="265.2104">Node ID</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="55" x="12" y="278.0151">Source ID</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="47" x="12" y="290.8198">Partition</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="7" x2="72" y1="297.4141" y2="297.4141"/><!--class Field--><rect fill="#FEFECE" filter="url(#fririlqtczj7e)" height="112.0234" id="Field" style="stroke: #A80036; stroke-width: 1.5;" width="90" x="108.5" y="206"/><ellipse cx="136.55" cy="222" fill="#ADD1B2" rx="11" ry="11" style="stroke: #A80036; stroke-width: 1.0;"/><path d="M138.8938,217.6719 L139.0656,217.75 C139.2844,217.4375 139.4875,217.3438 139.7844,217.3438 C140.0813,217.3438 140.3625,217.4844 140.5188,217.75 C140.6125,217.9063 140.6281,218.0313 140.6281,218.4688 L140.6281,219.8906 C140.6281,220.3125 140.5969,220.5 140.4875,220.6563 C140.3156,220.875 140.05,221.0156 139.7844,221.0156 C139.5656,221.0156 139.3313,220.9063 139.1906,220.7656 C139.05,220.6406 139.0188,220.5156 138.9563,220.1094 C138.8625,219.7031 138.6906,219.4844 138.2063,219.2031 C137.7375,218.9531 137.1281,218.7969 136.55,218.7969 C134.8156,218.7969 133.5656,220.1094 133.5656,221.8906 L133.5656,222.9844 C133.5656,224.6875 134.8625,225.7813 136.9094,225.7813 C137.675,225.7813 138.3625,225.6563 138.7844,225.3906 C138.9719,225.2969 138.9719,225.2969 139.425,224.8125 C139.6125,224.625 139.8156,224.5469 140.0344,224.5469 C140.5031,224.5469 140.8938,224.9375 140.8938,225.3906 C140.8938,225.7813 140.5656,226.2344 139.9875,226.6406 C139.2375,227.1875 138.0813,227.4844 136.8625,227.4844 C133.9719,227.4844 131.8625,225.5938 131.8625,223.0156 L131.8625,221.8906 C131.8625,219.1719 133.8625,217.0938 136.4875,217.0938 C137.3625,217.0938 137.9563,217.2344 138.8938,217.6719 Z "/><text fill="#000000" font-family="sans-serif" font-size="12" lengthAdjust="spacingAndGlyphs" textLength="29" x="153.45" y="226.1543">Field</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="109.5" x2="197.5" y1="238" y2="238"/><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="33" x="114.5" y="252.2104">Name</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="78" x="114.5" y="265.0151">Current Value</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="61" x="114.5" y="277.8198">Change By</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="62" x="114.5" y="290.6245">Change Up</text><text fill="#000000" font-family="sans-serif" font-size="11" lengthAdjust="spacingAndGlyphs" textLength="78" x="114.5" y="303.4292">Change Down</text><line style="stroke: #A80036; stroke-width: 1.5;" x1="109.5" x2="197.5" y1="310.0234" y2="310.0234"/><!--link Subscription to Node--><path d="M75.2753,146.142 C68.2426,168.721 60.5765,193.333 54.1511,213.962 " fill="none" id="Subscription-Node" style="stroke: #A80036; stroke-width: 1.0;"/><polygon fill="#A80036" points="52.6306,218.8438,59.1244,211.439,54.1164,214.0697,51.4858,209.0617,52.6306,218.8438" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="8" x="64.7922" y="165.778">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="7" x="47.1655" y="207.8152">*</text><!--link Subscription to Field--><path d="M117.725,146.142 C123.338,164.163 129.354,183.478 134.821,201.03 " fill="none" id="Subscription-Field" style="stroke: #A80036; stroke-width: 1.0;"/><polygon fill="#A80036" points="136.347,205.931,137.4886,196.1485,134.8596,201.1574,129.8508,198.5284,136.347,205.931" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="8" x="111.4206" y="165.778">1</text><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="7" x="126.7008" y="194.8601">*</text><!--
@startuml
Subscription "1" - -> "*" Node
Subscription "1" - -> "*" Field
Subscription : Id
Subscription : Categories
Subscription : Max Age
Subscription : Max Interval
Subscription : Min Interval
Subscription : Tokens
Subscription : Request
Node : Node ID
Node : Source ID
Node : Partition
Field : Name
Field : Current Value
Field : Change By
Field : Change Up
Field : Change Down
@enduml
PlantUML version 1.2017.18beta8(Unknown compile time)
(GPL source distribution)
Java Runtime: Java(TM) SE Runtime Environment
JVM: Java HotSpot(TM) 64-Bit Server VM
Java Version: 1.7.0_25-b15
Operating System: Linux
Default Encoding: UTF-8
Language: en
Country: US
--></g></svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="360px" preserveAspectRatio="none" style="width:337px;height:360px;" version="1.1" viewBox="0 0 337 360" width="337px" zoomAndPan="magnify"><defs><filter height="300%" id="f1hv116gmwjzjd" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"/><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/></filter></defs><g><rect fill="#FFFFFF" filter="url(#f1hv116gmwjzjd)" height="232.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="197.5" y="69.2969"/><rect fill="#FFFFFF" filter="url(#f1hv116gmwjzjd)" height="34.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="202.5" y="202.8281"/><rect fill="#FFFFFF" filter="url(#f1hv116gmwjzjd)" height="131.5313" style="stroke: #000000; stroke-width: 2.0;" width="302.5" x="13" y="113.5625"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="51" x2="51" y1="38.2969" y2="320.3594"/><line style="stroke: #A80036; stroke-width: 1.0; stroke-dasharray: 5.0,5.0;" x1="202" x2="202" y1="38.2969" y2="320.3594"/><rect fill="#FEFECE" filter="url(#f1hv116gmwjzjd)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="53" x="23" y="3"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="39" x="30" y="22.9951">Client</text><rect fill="#FEFECE" filter="url(#f1hv116gmwjzjd)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="53" x="23" y="319.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="39" x="30" y="339.3545">Client</text><rect fill="#FEFECE" filter="url(#f1hv116gmwjzjd)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="61" x="170" y="3"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="47" x="177" y="22.9951">Device</text><rect fill="#FEFECE" filter="url(#f1hv116gmwjzjd)" height="30.2969" style="stroke: #A80036; stroke-width: 1.5;" width="61" x="170" y="319.3594"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacingAndGlyphs" textLength="47" x="177" y="339.3545">Device</text><rect fill="#FFFFFF" filter="url(#f1hv116gmwjzjd)" height="232.9297" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="197.5" y="69.2969"/><rect fill="#FFFFFF" filter="url(#f1hv116gmwjzjd)" height="34.1328" style="stroke: #A80036; stroke-width: 1.0;" width="10" x="202.5" y="202.8281"/><polygon fill="#A80036" points="185.5,65.2969,195.5,69.2969,185.5,73.2969,189.5,69.2969" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="51.5" x2="191.5" y1="69.2969" y2="69.2969"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="106" x="58.5" y="64.3638">iq set(subscribe)</text><polygon fill="#A80036" points="62.5,94.4297,52.5,98.4297,62.5,102.4297,58.5,98.4297" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="56.5" x2="196.5" y1="98.4297" y2="98.4297"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="120" x="68.5" y="93.4966">iq result(accepted)</text><rect fill="none" height="131.5313" style="stroke: #000000; stroke-width: 2.0;" width="302.5" x="13" y="113.5625"/><polygon fill="#EEEEEE" points="13,113.5625,243,113.5625,243,120.5625,233,130.5625,13,130.5625,13,113.5625" style="stroke: #000000; stroke-width: 2.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="185" x="28" y="126.6294">While subscription active</text><rect fill="#EEEEEE" filter="url(#f1hv116gmwjzjd)" height="3" style="stroke: #EEEEEE; stroke-width: 1.0;" width="322.5" x="3" y="151.2617"/><line style="stroke: #000000; stroke-width: 1.0;" x1="3" x2="325.5" y1="151.2617" y2="151.2617"/><line style="stroke: #000000; stroke-width: 1.0;" x1="3" x2="325.5" y1="154.2617" y2="154.2617"/><rect fill="#EEEEEE" filter="url(#f1hv116gmwjzjd)" height="23.1328" style="stroke: #000000; stroke-width: 2.0;" width="200" x="64.25" y="140.6953"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacingAndGlyphs" textLength="181" x="70.25" y="156.7622">Wait for event to trigger</text><line style="stroke: #A80036; stroke-width: 1.0;" x1="207.5" x2="254.5" y1="189.9609" y2="189.9609"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="254.5" x2="254.5" y1="189.9609" y2="202.9609"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="213.5" x2="254.5" y1="202.9609" y2="202.9609"/><polygon fill="#A80036" points="223.5,198.9609,213.5,202.9609,223.5,206.9609,219.5,202.9609" style="stroke: #A80036; stroke-width: 1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="84" x="219.5" y="184.895">start readout</text><polygon fill="#A80036" points="62.5,232.9609,52.5,236.9609,62.5,240.9609,58.5,236.9609" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="56.5" x2="196.5" y1="236.9609" y2="236.9609"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="97" x="68.5" y="232.0278">message(resp)</text><polygon fill="#A80036" points="185.5,269.0938,195.5,273.0938,185.5,277.0938,189.5,273.0938" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="51.5" x2="191.5" y1="273.0938" y2="273.0938"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="122" x="58.5" y="268.1606">iq set(unsubscribe)</text><polygon fill="#A80036" points="62.5,298.2266,52.5,302.2266,62.5,306.2266,58.5,302.2266" style="stroke: #A80036; stroke-width: 1.0;"/><line style="stroke: #A80036; stroke-width: 1.0;" x1="56.5" x2="201.5" y1="302.2266" y2="302.2266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacingAndGlyphs" textLength="61" x="68.5" y="297.2935">iq result()</text><!--
@startuml
Client -> Device : iq set(subscribe)
Activate Device
Client <- Device : iq result(accepted)
group While subscription active
== Wait for event to trigger ==
Device -> Device : start readout
Activate Device
Client <- Device : message(resp)
Deactivate Device
end
Client -> Device : iq set(unsubscribe)
Client <- Device : iq result()
Deactivate Device
@enduml
PlantUML version 1.2017.18beta8(Unknown compile time)
(GPL source distribution)
Java Runtime: Java(TM) SE Runtime Environment
JVM: Java HotSpot(TM) 64-Bit Server VM
Java Version: 1.7.0_25-b15
Operating System: Linux
Default Encoding: UTF-8
Language: en
Country: US
--></g></svg>
\ No newline at end of file
@startuml
Client -> Device : iq set(subscribe)
Activate Device
Client <- Device : iq result(accepted)
group While subscription active
== Wait for event to trigger ==
Device -> Device : start readout
Activate Device
Client <- Device : message(resp)
Deactivate Device
end
Client -> Device : iq set(unsubscribe)
Client <- Device : iq result()
Deactivate Device
@enduml
\ No newline at end of file
......@@ -15,6 +15,7 @@ Communication Patterns
----------------------------
* [Sensor Data Request/Response communication pattern](SensorDataRequestResponse.md)
* [Sensor Data Event Subscription communication pattern](SensorDataEventSubscription.md)
Schemas
......@@ -29,7 +30,7 @@ Implementations
### Sensor data related libraries.
| Project | Language | Environment | Description |
|------------------------------------------------------------------------------------------------------|----------|--------------|------------------------------|
| [Waher.Networking.XMPP.Sensor](https://www.nuget.org/packages/Waher.Networking.XMPP.Sensor/) | C# | .NET Std 1.3 | Sensor data library. |
| [Waher.Networking.XMPP.Sensor.UWP](https://www.nuget.org/packages/Waher.Networking.XMPP.Sensor.UWP/) | C# | UWP | Sensor data library for UWP. |
| Project | Language | Environment | Description |
|------------------------------------------------------------------------------------------------------|----------|--------------|-------------------------------------------------------------------------------------------------|
| [Waher.Networking.XMPP.Sensor](https://www.nuget.org/packages/Waher.Networking.XMPP.Sensor/) | C# | .NET Std 1.3 | Sensor data library. Handles both sensor data requests, as well as event subscriptions. |
| [Waher.Networking.XMPP.Sensor.UWP](https://www.nuget.org/packages/Waher.Networking.XMPP.Sensor.UWP/) | C# | UWP | Sensor data library for UWP. Handles both sensor data requests, as well as event subscriptions. |
This diff is collapsed.
Sensor Data Request/Response communication pattern
========================================================
You can retrieve sensor data from a device, nodes in a device, by sending an request to the device. This document describes this pattern.
You can retrieve sensor data from a device, or nodes in a device, by sending an request to the device. This document describes this pattern.
This document outlines the XML representation of sensor data, as defined by the IEEE XMPP IoT Working Group. The XML representation is modelled using
an annotated XML Schema:
| Sensor Data ||
| ------------|----------------------------------|
| Namespace: | urn:ieee:iot:sd |
| Schema: | [SensorData.xsd](SensorData.xsd) |
Motivation and design goal
----------------------------
......@@ -19,7 +27,7 @@ The request/response pattern for sensor data described in this document, is desi
Building the request
-------------------------
The request is sent using an `iq get` stanza with a `req` element to the device. This request may optionally include references to nodes
The request is sent using an `iq[type=get]` stanza with a `req` element to the device. This request may optionally include references to nodes
(if the device supports nodes) and field names the request should be limited to. If no field names are provided, all fields names are implied.
If no node references are provided, only devices not supporting nodes are implied. Concentrators should interpret this as an empty request, readong zero nodes.
......@@ -43,7 +51,7 @@ use of [tokens](#tokens).
| | | | `h` | `xs:boolean` | Optional | Include historical values. |
| | | | `all` | `xs:boolean` | Optional | Include all categories of fields. |
| | | | `from` | `xs:dateTime` | Optional | Only return fields not older than this timestamp. |
| | | | `to ` | `xs:dateTime` | Optional | Only return fields not newer than this timestamp. |
| | | | `to` | `xs:dateTime` | Optional | Only return fields not newer than this timestamp. |
| | | | `when` | `xs:dateTime` | Optional | Timestamp of when the request is to be executed. |
| | | | `st` | `xs:string` | Optional | Service token. |
| | | | `dt` | `xs:string` | Optional | Device token. |
......@@ -51,7 +59,7 @@ use of [tokens](#tokens).
| Node | `nd` | Optional | `id` | `xs:string` | Required | Node identity. |
| | | | `src` | `xs:string` | Optional | Source identity. |
| | | | `pt` | `xs:string` | Optional | Partition. |
| Field | `f` | Optional | `f` | `xs:string` | Required | Unlocalized field name. |
| Field | `f` | Optional | `n` | `xs:string` | Required | Unlocalized field name. |
Responses
......@@ -66,14 +74,14 @@ When receiving a request, a device can respond in several manners:
### Returning sensor data immediately
A simple readout just returns the sensor data in a `iq result` stanza with a `resp` element. This is typically the pattern of small devices having
A simple readout just returns the sensor data in a `iq[type=result]` stanza with a `resp` element. This is typically the pattern of small devices having
the current values in internal memory.
![Simple Readout](Diagrams/SimpleReadout.png)
### Slow responses
If it takes time to collect the data to return, the device returns a `started` element in an `iq result` stanza immediately to the client. This allows the
If it takes time to collect the data to return, the device returns a `started` element in an `iq[type=result]` stanza immediately to the client. This allows the
client to know the request has been accepted and started, and that data will be sent later. When data is available, it is sent asynchronously to the client,
using the `message` stanza containing a `resp` element.
......@@ -81,7 +89,7 @@ using the `message` stanza containing a `resp` element.
### Scheduled or queued responses
If a request is scheduled or queued for some reason, the device returns an `accepted` element in an `iq result` stanza back to the client. The client then knows
If a request is scheduled or queued for some reason, the device returns an `accepted` element in an `iq[type=result]` stanza back to the client. The client then knows
the request has been accepted, and either scheduled for execution at a later time, or queued for execution as soon as the device is able. The `accepted` element
has a `queued` attribute that can be used to let the client know the request has been queued.
......@@ -114,8 +122,8 @@ element can be sent in a `message` stanza back to the client, to notify the clie
### Cancelling request
A request that has been scheduled or queued, can be cancelled. Cancelling a request is done by sending a `iq set` stanza with a `cancel` element to the
device, with the identifier used to identify the request. The device responds with an empty `iq result` stanza. Optionally, a device may also support the
A request that has been scheduled or queued, can be cancelled. Cancelling a request is done by sending a `iq[type=set]` stanza with a `cancel` element to the
device, with the identifier used to identify the request. The device responds with an empty `iq[type=result]` stanza. Optionally, a device may also support the
cancellation of ongoing readouts.
![Cancel Readout](Diagrams/CancelReadout.png)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment