Modify soft sensor manager resource presence handling
authorMinji Park <minjii.park@samsung.com>
Fri, 17 Apr 2015 07:32:28 +0000 (16:32 +0900)
committerUze Choi <uzchoi@samsung.com>
Mon, 20 Apr 2015 10:28:28 +0000 (10:28 +0000)
Modify SSM resource finder for resource presence status handling

Change-Id: Idae7ea380189120809fca45e079493a85318c5d6
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/764
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 fc1fbff..48ba5d0 100644 (file)
@@ -76,8 +76,7 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
     switch (result)
     {
         case OC_STACK_OK:
-            requestURI << "coap://" << hostAddress << ":" << OC_MULTICAST_PORT <<
-                       "/oc/core?rt=SSManager.Sensor";
+            requestURI << "coap://" << hostAddress << "/oc/core?rt=SSManager.Sensor";
 
             ret = OC::OCPlatform::findResource("", requestURI.str(), OC_WIFI,
                                                std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
@@ -85,16 +84,15 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
             if (ret != OC_STACK_OK)
                 SSM_CLEANUP_ASSERT(SSM_E_FAIL);
 
-            ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET,\r
-                                               std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));\r
-\r
-            if (ret != OC_STACK_OK)\r
-                SSM_CLEANUP_ASSERT(SSM_E_FAIL);\r
-\r
+            ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET,
+                                               std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+
+            if (ret != OC_STACK_OK)
+                SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
             break;
 
         case OC_STACK_PRESENCE_STOPPED:
-        case OC_STACK_PRESENCE_TIMEOUT:
             if (m_mapResources.find(hostAddress) != m_mapResources.end())
             {
                 while (!m_mapResources[hostAddress].empty())
@@ -110,6 +108,9 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
             }
             break;
 
+        case OC_STACK_PRESENCE_TIMEOUT:
+            break;
+
         case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
             break;
 
@@ -135,12 +136,12 @@ SSMRESULT CResourceFinder::startResourceFinder()
     if (ret != OC_STACK_OK)
         SSM_CLEANUP_ASSERT(SSM_E_FAIL);
 
-    ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET,\r
-                                       std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));\r
-\r
-    if (ret != OC_STACK_OK)\r
-        SSM_CLEANUP_ASSERT(SSM_E_FAIL);\r
-\r
+    ret = OC::OCPlatform::findResource("", requestURI.str(), OC_ETHERNET,
+                                       std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+
+    if (ret != OC_STACK_OK)
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
     ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, OC_MULTICAST_IP,
                                             "SSManager.Sensor", OC_WIFI, std::bind(&CResourceFinder::presenceHandler, this,
                                                     std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
@@ -148,13 +149,13 @@ SSMRESULT CResourceFinder::startResourceFinder()
     if (ret != OC_STACK_OK)
         SSM_CLEANUP_ASSERT(SSM_E_FAIL);
 
-    ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, OC_MULTICAST_IP,\r
-                                            "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this,\r
-                                                    std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));\r
-\r
-    if (ret != OC_STACK_OK)\r
-        SSM_CLEANUP_ASSERT(SSM_E_FAIL);\r
-\r
+    ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, OC_MULTICAST_IP,
+                                            "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this,
+                                                    std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+
+    if (ret != OC_STACK_OK)
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
     res = SSM_S_OK;
 
 CLEANUP:
@@ -237,21 +238,21 @@ void CResourceFinder::onExecute(void *pArg)
                 if (ret != OC_STACK_OK)
                     SSM_CLEANUP_ASSERT(SSM_E_FAIL);
 
-                ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,\r
-                                                        "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this,\r
-                                                                std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));\r
-\r
-                if (ret != OC_STACK_OK)\r
-                    SSM_CLEANUP_ASSERT(SSM_E_FAIL);\r
-\r
+                ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
+                                                        "SSManager.Sensor", OC_ETHERNET, std::bind(&CResourceFinder::presenceHandler, this,
+                                                                std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+
+                if (ret != OC_STACK_OK)
+                    SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
                 m_mapResourcePresenceHandles[((ISSMResource *)pMessage[1])->ip] = presenceHandle;
             }
 
-            m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);\r
-\r
-            if (ret != OC_STACK_OK)\r
-                SSM_CLEANUP_ASSERT(SSM_E_FAIL);\r
-\r
+            m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);
+
+            if (ret != OC_STACK_OK)
+                SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+
             break;
 
         case RESOURCE_DISCOVER_UNINSTALL_RESOURCE: