[SSM] Change to make SSM work with Connectivity Abstraction
authorMinji Park <minjii.park@samsung.com>
Fri, 23 Jan 2015 07:13:58 +0000 (16:13 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 23 Jan 2015 08:28:04 +0000 (08:28 +0000)
Modify ResourceFinder to find Resources and check presence status with connectivity type

Change-Id: I2478904ff08b28ef2cbe131e06b95e3f059618fb
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/232
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp

index 9920eda..c687b06 100644 (file)
@@ -75,9 +75,15 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
     switch (result)
     {
         case OC_STACK_OK:
+#ifdef CA_INT
+            ret = OC::OCPlatform::findResource("",
+                                               "coap://" + hostAddress + ":5298" + "/oc/core?rt=SoftSensorManager.Sensor", OC_ALL,
+                                               std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+#else
             ret = OC::OCPlatform::findResource("",
                                                "coap://" + hostAddress + "/oc/core?rt=SoftSensorManager.Sensor",
                                                std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+#endif
 
             if (ret != OC_STACK_OK)
                 SSM_CLEANUP_ASSERT(SSM_E_FAIL);
@@ -117,16 +123,29 @@ SSMRESULT CResourceFinder::startResourceFinder()
     SSMRESULT res = SSM_E_FAIL;
     OCStackResult ret = OC_STACK_ERROR;
 
+#ifdef CA_INT
+    ret = OC::OCPlatform::findResource("",
+                                       "coap://224.0.1.187:5298/oc/core?rt=SoftSensorManager.Sensor", OC_ALL,
+                                       std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+#else
     ret = OC::OCPlatform::findResource("", "coap://224.0.1.187/oc/core?rt=SoftSensorManager.Sensor",
                                        std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+#endif
 
     if (ret != OC_STACK_OK)
         SSM_CLEANUP_ASSERT(SSM_E_FAIL);
 
+#ifdef CA_INT
+    ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, "coap://224.0.1.187",
+                                            "SoftSensorManager.Sensor", OC_ALL,
+                                            std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1,
+                                                    std::placeholders::_2, std::placeholders::_3));
+#else
     ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, "coap://224.0.1.187",
                                             "SoftSensorManager.Sensor",
                                             std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1,
                                                     std::placeholders::_2, std::placeholders::_3));
+#endif
 
     if (ret != OC_STACK_OK)
         SSM_CLEANUP_ASSERT(SSM_E_FAIL);
@@ -207,10 +226,17 @@ void CResourceFinder::onExecute(IN void *pArg)
             if (m_mapResourcePresenceHandles.find(((ISSMResource *)pMessage[1])->ip) ==
                 m_mapResourcePresenceHandles.end())
             {
+#ifdef CA_INT
+                ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
+                                                        "SoftSensorManager.Sensor", OC_ALL,
+                                                        std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1,
+                                                                std::placeholders::_2, std::placeholders::_3));
+#else
                 ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
                                                         "SoftSensorManager.Sensor",
                                                         std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1,
                                                                 std::placeholders::_2, std::placeholders::_3));
+#endif
 
                 if (ret != OC_STACK_OK)
                     SSM_CLEANUP_ASSERT(SSM_E_FAIL);