clarify limitations with IotProvider and PublishSubscribeService

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

Branch: refs/heads/master
Commit: f31b98cf4dbe3d1571552c6fdcb154130ac8f04b
Parents: 5926814
Author: Dale LaBossiere <dlab...@us.ibm.com>
Authored: Fri Feb 24 19:24:10 2017 -0500
Committer: Dale LaBossiere <dlab...@us.ibm.com>
Committed: Fri Feb 24 21:53:41 2017 -0500

----------------------------------------------------------------------
 .../apache/edgent/apps/iot/PubSubIotDevice.java | 18 +++++++++++++----
 .../edgent/connectors/iotp/IotpGateway.java     | 10 ++++++++++
 .../iotp/runtime/IotpGWConnector.java           |  1 +
 .../samples/connectors/iotp/IotpAppClient.java  | 21 ++++++++++++++------
 4 files changed, 40 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/f31b98cf/apps/iot/src/main/java/org/apache/edgent/apps/iot/PubSubIotDevice.java
----------------------------------------------------------------------
diff --git 
a/apps/iot/src/main/java/org/apache/edgent/apps/iot/PubSubIotDevice.java 
b/apps/iot/src/main/java/org/apache/edgent/apps/iot/PubSubIotDevice.java
index e6a64b3..c45a71a 100644
--- a/apps/iot/src/main/java/org/apache/edgent/apps/iot/PubSubIotDevice.java
+++ b/apps/iot/src/main/java/org/apache/edgent/apps/iot/PubSubIotDevice.java
@@ -121,16 +121,26 @@ class PubSubIotDevice implements IotDevice {
         return commandsStream;
     }
 
+    /**
+     * {@inheritDoc}
+     * <p>
+     * <b>Not yet implemented.  
+     * Returns a canned string instead of the backing IotDevice's info.</b> 
+     */
     @Override
     public String getDeviceType() {
-      // TODO Auto-generated method stub
-      return null;
+      return "NYI_PubSubIotDevice_DEVICE_TYPE";
     }
 
+    /**
+     * {@inheritDoc}
+     * <p>
+     * <b>Not yet implemented.  
+     * Returns a canned string instead of the backing IotDevice's info.</b> 
+     */
     @Override
     public String getDeviceId() {
-      // TODO Auto-generated method stub
-      return null;
+      return "NYI_PubSubIotDevice_DEVICE_ID";
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/f31b98cf/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/IotpGateway.java
----------------------------------------------------------------------
diff --git 
a/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/IotpGateway.java
 
b/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/IotpGateway.java
index b2137f2..7a2b293 100644
--- 
a/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/IotpGateway.java
+++ 
b/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/IotpGateway.java
@@ -16,6 +16,7 @@ import 
org.apache.edgent.connectors.iotp.runtime.IotpGWDeviceEventsFixed;
 import org.apache.edgent.connectors.iotp.runtime.IotpGWDeviceEventsFunction;
 import org.apache.edgent.connectors.iotp.runtime.IotpGWEventsFixed;
 import org.apache.edgent.connectors.iotp.runtime.IotpGWEventsFunction;
+import org.apache.edgent.connectors.pubsub.service.PublishSubscribeService;
 import org.apache.edgent.function.Function;
 import org.apache.edgent.function.UnaryOperator;
 import org.apache.edgent.topology.TSink;
@@ -40,6 +41,15 @@ import com.ibm.iotf.client.gateway.GatewayClient;
  * An application can use 
  * {@link #setExternalCallbackHandler(GatewayCallback) 
setExternalCallbackHandler}
  * to also receive and process callbacks.
+ * <p>
+ * Limitations:
+ * <ul>
+ * <li>{@link IotProvider} and {@link PublishSubscribeService} do not yet 
support
+ * the gateway model.  An IotProvider may be initialized with an IotpGateway
+ * but the PublishSubscribeService mechanism will only publish events and 
receive
+ * commands for the gateway device, not any of its connected devices.
+ * </li>
+ * </ul>
  */
 public class IotpGateway implements IotGateway {
 

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/f31b98cf/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/runtime/IotpGWConnector.java
----------------------------------------------------------------------
diff --git 
a/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/runtime/IotpGWConnector.java
 
b/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/runtime/IotpGWConnector.java
index 84e7631..8ae5f84 100644
--- 
a/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/runtime/IotpGWConnector.java
+++ 
b/connectors/iotp/src/main/java/org/apache/edgent/connectors/iotp/runtime/IotpGWConnector.java
@@ -207,6 +207,7 @@ public class IotpGWConnector implements Serializable, 
AutoCloseable {
         }
     }
 
+// See https://github.com/ibm-watson-iot/iot-java/issues/83
 //    void publishHttpDeviceEvent(String eventId, JsonObject event) {
 //        try {
 //            APIClient api = getClient().api();

http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/f31b98cf/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
----------------------------------------------------------------------
diff --git 
a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
 
b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
index 3511dc3..959f218 100644
--- 
a/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
+++ 
b/samples/connectors/src/main/java/org/apache/edgent/samples/connectors/iotp/IotpAppClient.java
@@ -58,12 +58,12 @@ public class IotpAppClient {
     Properties cfgProps = new Properties();
     cfgProps.load(new FileReader(new File(deviceCfgPath)));
     
-    String iotpOrg = cfgProps.getProperty("org");
-    String iotpAppId = cfgProps.getProperty("id");
-    String iotpAppKey = cfgProps.getProperty("auth-key");
-    System.out.println("org:  " + iotpOrg);
-    System.out.println("id:   " + iotpAppId);
-    System.out.println("key:  " + iotpAppKey);
+    String iotpOrg = getProperty(cfgProps, "Organization-ID", "org");
+    String iotpAppId = getProperty(cfgProps, "id");
+    String iotpApiKey = getProperty(cfgProps, "API-Key", "auth-key");
+    System.out.println("org:     " + iotpOrg);
+    System.out.println("id:      " + iotpAppId);
+    System.out.println("ApiKey:  " + iotpApiKey);
 
     String iotpDevType = cfgProps.getProperty("deviceType");
     String iotpDevId = cfgProps.getProperty("deviceId");
@@ -132,5 +132,14 @@ public class IotpAppClient {
     
     System.out.println("Sent: " + (ok ? "OK" : "NOT-OK"));
   }
+  
+  private static String getProperty(Properties props, String... keys) {
+    for (String key : keys) {
+      String val = props.getProperty(key);
+      if (val != null)
+        return val;
+    }
+    return null;
+  }
 
 }

Reply via email to