flesh out new methods in EchoIotDevice and MqttDevice

Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/5926814c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/5926814c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/5926814c

Branch: refs/heads/master
Commit: 5926814c28a754fed90b9bac94073b2f05d7f695
Parents: 47becd2
Author: Dale LaBossiere <dlab...@us.ibm.com>
Authored: Fri Feb 24 08:23:15 2017 -0500
Committer: Dale LaBossiere <dlab...@us.ibm.com>
Committed: Fri Feb 24 21:53:41 2017 -0500

----------------------------------------------------------------------
 .../apache/edgent/test/apps/iot/EchoIotDevice.java    | 10 ++++++----
 .../apache/edgent/connectors/mqtt/iot/MqttDevice.java | 14 ++++++++++----
 2 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/5926814c/apps/iot/src/test/java/org/apache/edgent/test/apps/iot/EchoIotDevice.java
----------------------------------------------------------------------
diff --git 
a/apps/iot/src/test/java/org/apache/edgent/test/apps/iot/EchoIotDevice.java 
b/apps/iot/src/test/java/org/apache/edgent/test/apps/iot/EchoIotDevice.java
index 95d62d2..055efca 100644
--- a/apps/iot/src/test/java/org/apache/edgent/test/apps/iot/EchoIotDevice.java
+++ b/apps/iot/src/test/java/org/apache/edgent/test/apps/iot/EchoIotDevice.java
@@ -44,6 +44,9 @@ import com.google.gson.JsonObject;
 public class EchoIotDevice implements IotDevice {
     
     public static final String EVENT_CMD_ID = "cmdId";
+    public static final String MY_DEVICE_TYPE = "echoDeviceType";
+    public static final String MY_FQDEVICE_ID = MY_DEVICE_TYPE+"/echoDeviceId";
+    public static final String EVENT_CMD_DEVICE = MY_FQDEVICE_ID;
 
     private final Topology topology;
     private TStream<JsonObject> echoCmds;
@@ -64,6 +67,7 @@ public class EchoIotDevice implements IotDevice {
         stream = stream.map(e -> {
             JsonObject c = new JsonObject();
             JsonObject evPayload = payload.apply(e);
+            c.addProperty(CMD_DEVICE, EVENT_CMD_DEVICE);
             c.addProperty(CMD_ID, getCommandIdFromEvent(eventId.apply(e), 
evPayload));
             c.add(CMD_PAYLOAD, evPayload);
             c.addProperty(CMD_FORMAT, "json");
@@ -117,14 +121,12 @@ public class EchoIotDevice implements IotDevice {
 
     @Override
     public String getDeviceType() {
-      // TODO Auto-generated method stub
-      return null;
+      return MY_DEVICE_TYPE;
     }
 
     @Override
     public String getDeviceId() {
-      // TODO Auto-generated method stub
-      return null;
+      return MY_FQDEVICE_ID;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/5926814c/connectors/mqtt/src/main/java/org/apache/edgent/connectors/mqtt/iot/MqttDevice.java
----------------------------------------------------------------------
diff --git 
a/connectors/mqtt/src/main/java/org/apache/edgent/connectors/mqtt/iot/MqttDevice.java
 
b/connectors/mqtt/src/main/java/org/apache/edgent/connectors/mqtt/iot/MqttDevice.java
index 6df2c5b..f283607 100644
--- 
a/connectors/mqtt/src/main/java/org/apache/edgent/connectors/mqtt/iot/MqttDevice.java
+++ 
b/connectors/mqtt/src/main/java/org/apache/edgent/connectors/mqtt/iot/MqttDevice.java
@@ -242,6 +242,7 @@ public class MqttDevice implements IotDevice {
             commandStream = connector.subscribe(topicFilter, commandQoS,
                     (topic, payload) -> {
                         JsonObject jo = new JsonObject();
+                        jo.addProperty(CMD_DEVICE, deviceId);
                         jo.addProperty(CMD_ID, extractCmd(topic));
                         jo.addProperty(CMD_TS, System.currentTimeMillis());
                         String fmt = extractCmdFmt(topic);
@@ -277,15 +278,20 @@ public class MqttDevice implements IotDevice {
         return topology;
     }
 
+    /**
+     * {@inheritDoc}
+     * <p> 
+     * This connector does not support the notion of a device-type
+     * as part of its device id model.  An empty string is returned.
+     */
     @Override
     public String getDeviceType() {
-      // TODO Auto-generated method stub
-      return null;
+      // not part of this connector's device identifier model
+      return "";
     }
 
     @Override
     public String getDeviceId() {
-      // TODO Auto-generated method stub
-      return null;
+      return deviceId;
     }
 }

Reply via email to