| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (1.8.0_112) on Mon Dec 18 11:25:21 EST 2017 --> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>MqttDevice (Apache Edgent (incubating) v1.2.0 API)</title> |
| <meta name="date" content="2017-12-18"> |
| <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../../../../script.js"></script> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="MqttDevice (Apache Edgent (incubating) v1.2.0 API)"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10,"i7":10,"i8":10}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/MqttDevice.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li>Prev Class</li> |
| <li>Next Class</li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/edgent/connectors/mqtt/iot/MqttDevice.html" target="_top">Frames</a></li> |
| <li><a href="MqttDevice.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">org.apache.edgent.connectors.mqtt.iot</div> |
| <h2 title="Class MqttDevice" class="title">Class MqttDevice</h2> |
| </div> |
| <div class="contentContainer"> |
| <ul class="inheritance"> |
| <li><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li> |
| <li> |
| <ul class="inheritance"> |
| <li>org.apache.edgent.connectors.mqtt.iot.MqttDevice</li> |
| </ul> |
| </li> |
| </ul> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt>All Implemented Interfaces:</dt> |
| <dd><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a>, <a href="../../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a></dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public class <span class="typeNameLabel">MqttDevice</span> |
| extends <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a> |
| implements <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></pre> |
| <div class="block">An MQTT based Edgent <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot"><code>IotDevice</code></a> connector. |
| <p> |
| The MQTT <code>IotDevice</code> is an abstraction on top of |
| the <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttStreams.html" title="class in org.apache.edgent.connectors.mqtt"><code>MqttStreams</code></a> connector. |
| <p> |
| The connector doesn't presume a particular pattern for |
| Device MQTT "event" and "command" topics though default |
| patterns are provided. |
| <p> |
| The MQTT message content for device events and device commands must be JSON. |
| The contents of the JSON are under the control of the collaborating MQTT clients. |
| Typically a device to defines its event and command schemas |
| and the other clients to adapt accordingly. |
| See <a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#commands-java.lang.String...-"><code>commands(String...)</code></a> and <a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#events-org.apache.edgent.topology.TStream-java.lang.String-int-"><code>events()</code></a> |
| for a description of how MQTT messages are converted to and from stream tuples. |
| <p> |
| Connector configuration Properties fall into two categories: |
| <ul> |
| <li>MQTT Device abstraction properties</li> |
| <li>Base MQTT connector properties - see <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html#fromProperties-java.util.Properties-"><code>MqttConfig.fromProperties(Properties)</code></a> |
| </ul> |
| |
| <h3>Device properties</h3> |
| <ul> |
| <li>mqttDevice.id - Required. An identifier that uniquely identifies |
| the device in the device event and device command MQTT topic namespaces. |
| </li> |
| <li>mqttDevice.topic.prefix - A optional prefix that by default is used when |
| composing device event and command MQTT topics, and the client's MQTT |
| clientId. The default is no prefix.</li> |
| <li>mqttDevice.event.topic.pattern - Optional. The topic pattern used |
| for MQTT device event topics. |
| Defaults to <code>{mqttDevice.topic.prefix}id/{mqttDevice.id}/evt/{EVENTID}/fmt/json</code> |
| The pattern must include {EVENTID} and must end with "/fmt/json". |
| </li> |
| <li>mqttDevice.command.topic.pattern - Optional. The topic pattern used |
| for MQTT device command topics. |
| Defaults to <code>{mqttDevice.topic.prefix}id/{mqttDevice.id}/cmd/{COMMAND}/fmt/json</code> |
| The pattern must include {COMMAND} and must end with "/fmt/json". |
| </li> |
| <li>mqttDevice.command.qos - An optional MQTT QoS value for commands. Defaults to 0.</li> |
| <li>mqttDevice.events.retain - Optional MQTT "retain" behavior for published events. Defaults to false.</li> |
| <li>mqttDevice.mqtt.clientId - Optional value to use for the MQTT clientId. |
| Defaults to {mqttDevice.topic.prefix}id/{mqttDevice.id}.</li> |
| </ul> |
| Sample use: |
| <pre><code> |
| // assuming a properties file containing at least: |
| // mqttDevice.id=012345678 |
| // mqtt.serverURLs=tcp://myMqttBrokerHost:1883 |
| |
| String propsPath = <path to properties file>; |
| Properties properties = new Properties(); |
| properties.load(Files.newBufferedReader(new File(propsPath).toPath())); |
| |
| Topology t = new DirectProvider(); |
| MqttDevice mqttDevice = new MqttDevice(t, properties); |
| |
| // publish JSON "status" device event tuples every hour |
| TStream<JsonObject> myStatusEvents = t.poll(myGetStatusAsJson(), 1, TimeUnit.HOURS); |
| mqttDevice.events(myStatusEvents, "status", QoS.FIRE_AND_FORGET); |
| |
| // handle a device command. In this example the payload is expected |
| // to be JSON and have a "value" property containing the new threshold. |
| mqttDevice.command("setSensorThreshold") |
| .sink(json -> setSensorThreshold(json.get(CMD_PAYLOAD).getAsJsonObject().get("value").getAsString()); |
| </code></pre></div> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- =========== FIELD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="field.summary"> |
| <!-- --> |
| </a> |
| <h3>Field Summary</h3> |
| <ul class="blockList"> |
| <li class="blockList"><a name="fields.inherited.from.class.org.apache.edgent.connectors.iot.IotDevice"> |
| <!-- --> |
| </a> |
| <h3>Fields inherited from interface org.apache.edgent.connectors.iot.<a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></h3> |
| <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_DEVICE">CMD_DEVICE</a>, <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_FORMAT">CMD_FORMAT</a>, <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_ID">CMD_ID</a>, <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_PAYLOAD">CMD_PAYLOAD</a>, <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_TS">CMD_TS</a>, <a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#RESERVED_ID_PREFIX">RESERVED_ID_PREFIX</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.summary"> |
| <!-- --> |
| </a> |
| <h3>Constructor Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> |
| <caption><span>Constructors</span><span class="tabEnd"> </span></caption> |
| <tr> |
| <th class="colOne" scope="col">Constructor and Description</th> |
| </tr> |
| <tr class="altColor"> |
| <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#MqttDevice-org.apache.edgent.topology.Topology-java.util.Properties-">MqttDevice</a></span>(<a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a> topology, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Properties.html?is-external=true" title="class or interface in java.util">Properties</a> properties)</code> |
| <div class="block">Create an MqttDevice connector.</div> |
| </td> |
| </tr> |
| <tr class="rowColor"> |
| <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#MqttDevice-org.apache.edgent.topology.Topology-java.util.Properties-org.apache.edgent.connectors.mqtt.MqttConfig-">MqttDevice</a></span>(<a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a> topology, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Properties.html?is-external=true" title="class or interface in java.util">Properties</a> properties, |
| <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt">MqttConfig</a> mqttConfig)</code> |
| <div class="block">Create an MqttDevice connector.</div> |
| </td> |
| </tr> |
| </table> |
| </li> |
| </ul> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#commands-java.lang.String...-">commands</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>... commands)</code> |
| <div class="block">Create a stream of device commands as JSON objects.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#commandTopic-java.lang.String-">commandTopic</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> command)</code> |
| <div class="block">Get the MQTT topic for a command.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><com.google.gson.JsonObject></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#events-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.UnaryOperator-org.apache.edgent.function.Function-">events</a></span>(<a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject> stream, |
| <a href="../../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><com.google.gson.JsonObject,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> eventId, |
| <a href="../../../../../../org/apache/edgent/function/UnaryOperator.html" title="interface in org.apache.edgent.function">UnaryOperator</a><com.google.gson.JsonObject> payload, |
| <a href="../../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><com.google.gson.JsonObject,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</a>> qos)</code> |
| <div class="block">Publish a stream's tuples as device events.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><com.google.gson.JsonObject></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#events-org.apache.edgent.topology.TStream-java.lang.String-int-">events</a></span>(<a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject> stream, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> eventId, |
| int qos)</code> |
| <div class="block">Publish a stream's tuples as device events.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#eventTopic-java.lang.String-">eventTopic</a></span>(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> eventId)</code> |
| <div class="block">Get the MQTT topic for an device event.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#getDeviceId--">getDeviceId</a></span>()</code> |
| <div class="block">Get the device's unique opaque device identifier.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#getDeviceType--">getDeviceType</a></span>()</code> |
| <div class="block">Get the device's opaque device type identifier.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt">MqttConfig</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#getMqttConfig--">getMqttConfig</a></span>()</code> |
| <div class="block">Get the device's <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt"><code>MqttConfig</code></a></div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code><a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../../org/apache/edgent/connectors/mqtt/iot/MqttDevice.html#topology--">topology</a></span>()</code> |
| <div class="block">Topology this element is contained in.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from class java.lang.<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3> |
| <code><a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="constructor.detail"> |
| <!-- --> |
| </a> |
| <h3>Constructor Detail</h3> |
| <a name="MqttDevice-org.apache.edgent.topology.Topology-java.util.Properties-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>MqttDevice</h4> |
| <pre>public MqttDevice(<a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a> topology, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Properties.html?is-external=true" title="class or interface in java.util">Properties</a> properties)</pre> |
| <div class="block">Create an MqttDevice connector. |
| <p> |
| All configuration information comes from <code>properties</code>.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topology</code> - topology to add the connector to.</dd> |
| <dd><code>properties</code> - connector properties.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="MqttDevice-org.apache.edgent.topology.Topology-java.util.Properties-org.apache.edgent.connectors.mqtt.MqttConfig-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>MqttDevice</h4> |
| <pre>public MqttDevice(<a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a> topology, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Properties.html?is-external=true" title="class or interface in java.util">Properties</a> properties, |
| <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt">MqttConfig</a> mqttConfig)</pre> |
| <div class="block">Create an MqttDevice connector. |
| <p> |
| Uses <code>mattConfig</code> for the base MQTT connector configuration |
| and uses <code>properties</code> only for MQTT Device properties.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>topology</code> - topology to add the connector to.</dd> |
| <dd><code>properties</code> - connector properties. Properties beyond those |
| noted in the Device properties section above are ignored.</dd> |
| <dd><code>mqttConfig</code> - base MQTT configuration. may be null.</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="eventTopic-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>eventTopic</h4> |
| <pre>public <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> eventTopic(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> eventId)</pre> |
| <div class="block">Get the MQTT topic for an device event.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>eventId</code> - the event id. |
| if null, returns a topic filter for all of the device's events.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the topic</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="commandTopic-java.lang.String-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>commandTopic</h4> |
| <pre>public <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> commandTopic(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> command)</pre> |
| <div class="block">Get the MQTT topic for a command.</div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>command</code> - the command id. |
| if null, returns a topic filter for all of the device's commands.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the topic</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getMqttConfig--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getMqttConfig</h4> |
| <pre>public <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt">MqttConfig</a> getMqttConfig()</pre> |
| <div class="block">Get the device's <a href="../../../../../../org/apache/edgent/connectors/mqtt/MqttConfig.html" title="class in org.apache.edgent.connectors.mqtt"><code>MqttConfig</code></a></div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the config</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="events-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.UnaryOperator-org.apache.edgent.function.Function-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>events</h4> |
| <pre>public <a href="../../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><com.google.gson.JsonObject> events(<a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject> stream, |
| <a href="../../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><com.google.gson.JsonObject,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>> eventId, |
| <a href="../../../../../../org/apache/edgent/function/UnaryOperator.html" title="interface in org.apache.edgent.function">UnaryOperator</a><com.google.gson.JsonObject> payload, |
| <a href="../../../../../../org/apache/edgent/function/Function.html" title="interface in org.apache.edgent.function">Function</a><com.google.gson.JsonObject,<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html?is-external=true" title="class or interface in java.lang">Integer</a>> qos)</pre> |
| <div class="block">Publish a stream's tuples as device events. |
| <p> |
| Each tuple is published as a device event with the supplied functions |
| providing the event identifier, payload and QoS. The event identifier and |
| QoS can be generated based upon the tuple. |
| |
| <p>The event is published to the configured MQTT <code>mqttDevice.event.topic.pattern</code>, |
| as described in the above class documentation, substituting the value returned |
| by the <code>eventId</code> function for "{EVENTID}" in the pattern. |
| The MQTT message's payload is the JSON representation |
| of the JsonObject stream tuple.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#events-org.apache.edgent.topology.TStream-org.apache.edgent.function.Function-org.apache.edgent.function.UnaryOperator-org.apache.edgent.function.Function-">events</a></code> in interface <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></code></dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>stream</code> - Stream to be published.</dd> |
| <dd><code>eventId</code> - function to supply the event identifier.</dd> |
| <dd><code>payload</code> - function to supply the event's payload.</dd> |
| <dd><code>qos</code> - function to supply the event's delivery Quality of Service.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>TSink sink element representing termination of this stream.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="events-org.apache.edgent.topology.TStream-java.lang.String-int-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>events</h4> |
| <pre>public <a href="../../../../../../org/apache/edgent/topology/TSink.html" title="interface in org.apache.edgent.topology">TSink</a><com.google.gson.JsonObject> events(<a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject> stream, |
| <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> eventId, |
| int qos)</pre> |
| <div class="block">Publish a stream's tuples as device events. |
| <p> |
| Each tuple is published as a device event with fixed event identifier and |
| QoS. |
| |
| <p>The event is published to the configured MQTT <code>mqttDevice.event.topic.pattern</code>, |
| as described in the above class documentation, substituting the <code>eventId</code> for |
| "{EVENTID}" in the pattern. |
| The MQTT message's payload is the JSON representation |
| of the JsonObject stream tuple.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#events-org.apache.edgent.topology.TStream-java.lang.String-int-">events</a></code> in interface <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></code></dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>stream</code> - Stream to be published.</dd> |
| <dd><code>eventId</code> - Event identifier.</dd> |
| <dd><code>qos</code> - Event's delivery Quality of Service.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>TSink sink element representing termination of this stream.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="commands-java.lang.String...-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>commands</h4> |
| <pre>public <a href="../../../../../../org/apache/edgent/topology/TStream.html" title="interface in org.apache.edgent.topology">TStream</a><com.google.gson.JsonObject> commands(<a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>... commands)</pre> |
| <div class="block">Create a stream of device commands as JSON objects. |
| Each command sent to the device matching <code>commands</code> will result in a tuple |
| on the stream. The JSON object has these keys: |
| <UL> |
| <LI><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_DEVICE"><code>device</code></a> - Command's opaque target device's id String. |
| <LI><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_ID"><code>command</code></a> - Command identifier as a String</LI> |
| <LI><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_TS"><code>tsms</code></a> - Timestamp of the command in milliseconds since the 1970/1/1 epoch.</LI> |
| <LI><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_FORMAT"><code>format</code></a> - Format of the command as a String</LI> |
| <LI><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#CMD_PAYLOAD"><code>payload</code></a> - Payload of the command |
| <UL> |
| <LI>If <code>format</code> is <code>json</code> then <code>payload</code> is JSON</LI> |
| <LI>Otherwise <code>payload</code> is String</LI> |
| </UL> |
| </LI> |
| </UL> |
| |
| <p> |
| Subscribes to the configured MQTT <code>mqttDevice.command.topic.pattern</code> |
| as described in the above class documentation. |
| The received MQTT message's payload is required to be JSON. |
| The message's JSON payload is converted to a JsonObject and |
| set as the <code>payload</code> key's value in the stream tuple JsonObject.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#commands-java.lang.String...-">commands</a></code> in interface <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></code></dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>commands</code> - Command identifiers to include. If no command identifiers are provided then the |
| stream will contain all of this IotDevice's device commands.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Stream containing device commands.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="topology--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>topology</h4> |
| <pre>public <a href="../../../../../../org/apache/edgent/topology/Topology.html" title="interface in org.apache.edgent.topology">Topology</a> topology()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from interface: <code><a href="../../../../../../org/apache/edgent/topology/TopologyElement.html#topology--">TopologyElement</a></code></span></div> |
| <div class="block">Topology this element is contained in.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/topology/TopologyElement.html#topology--">topology</a></code> in interface <code><a href="../../../../../../org/apache/edgent/topology/TopologyElement.html" title="interface in org.apache.edgent.topology">TopologyElement</a></code></dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>Topology this element is contained in.</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getDeviceType--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getDeviceType</h4> |
| <pre>public <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> getDeviceType()</pre> |
| <div class="block">Get the device's opaque device type identifier. |
| <p> |
| This connector does not support the notion of a device-type |
| as part of its device id model. An empty string is returned.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#getDeviceType--">getDeviceType</a></code> in interface <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></code></dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the device's type</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getDeviceId--"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>getDeviceId</h4> |
| <pre>public <a href="http://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a> getDeviceId()</pre> |
| <div class="block"><span class="descfrmTypeLabel">Description copied from interface: <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#getDeviceId--">IotDevice</a></code></span></div> |
| <div class="block">Get the device's unique opaque device identifier.</div> |
| <dl> |
| <dt><span class="overrideSpecifyLabel">Specified by:</span></dt> |
| <dd><code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html#getDeviceId--">getDeviceId</a></code> in interface <code><a href="../../../../../../org/apache/edgent/connectors/iot/IotDevice.html" title="interface in org.apache.edgent.connectors.iot">IotDevice</a></code></dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the device's id</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="class-use/MqttDevice.html">Use</a></li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../../../../index-all.html">Index</a></li> |
| <li><a href="../../../../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li>Prev Class</li> |
| <li>Next Class</li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../../../../index.html?org/apache/edgent/connectors/mqtt/iot/MqttDevice.html" target="_top">Frames</a></li> |
| <li><a href="MqttDevice.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor.summary">Constr</a> | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor.detail">Constr</a> | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| <p class="legalCopy"><small>Copyright © 2016–2017 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> |
| </body> |
| </html> |