Expose PISetup() API in Plugin Interface.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Thu, 8 Oct 2015 23:38:31 +0000 (16:38 -0700)
committerJon A. Cruz <jonc@osg.samsung.com>
Tue, 17 Nov 2015 18:53:59 +0000 (18:53 +0000)
This puts the onus on the application layer to perform discovery
operations for their radio(s).  This way the discovery operations can be
triggered via the appropriate actions for the application.

Change-Id: If5140b436159c74260dc30ac3d33401e62478b25
Signed-off-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3779
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
plugins/include/plugininterface.h
plugins/src/plugininterface.c

index e66d1d9..ac417d3 100644 (file)
@@ -62,6 +62,16 @@ OCStackResult PIStopAll();
 
 /**
  *
+ * Performs any required work on this specific plugin to initiate it's respective
+ * discovery operation.
+ *
+ * @param[in] plugin The plugin to initiate it's discovery operation on.
+ *
+ */
+OCStackResult PISetup(PIPlugin * plugin);
+
+/**
+ *
  * Called in main loop of application. Gives cycles for Plugin Interface'
  * internal operation.
  *
index d617a87..489ded0 100644 (file)
@@ -181,10 +181,10 @@ OCStackResult PIStartPlugin(const char * comPort, PIPluginType pluginType, PIPlu
         {
             return OC_STACK_ERROR;
         }
-        result = AddPlugin((PIPluginBase *) *plugin);
-        if (result == OC_STACK_OK)
+        result = AddPlugin((PIPluginBase *)*plugin);
+        if(result != OC_STACK_OK)
         {
-            result = ZigbeeDiscover((PIPlugin_Zigbee *) plugin);
+            return result;
         }
     }
     return result;
@@ -205,6 +205,24 @@ OCStackResult PIStopAll()
     return DeletePluginList();
 }
 
+OCStackResult PISetup(PIPlugin * plugin)
+{
+    if (!plugin)
+    {
+        return OC_STACK_INVALID_PARAM;
+    }
+    OCStackResult result = OC_STACK_ERROR;
+    if (((PIPluginBase *)plugin)->type == PLUGIN_ZIGBEE)
+    {
+        result = ZigbeeDiscover((PIPlugin_Zigbee *) plugin);
+        if( result != OC_STACK_OK)
+        {
+            return result;
+        }
+    }
+    return result;
+}
+
 OCStackResult PIProcess(PIPlugin * p_plugin)
 {
     PIPluginBase * plugin = (PIPluginBase *) p_plugin;