Update soft-sensor-manager to use updated OIC Virtual Resource definitions
authorMinji Park <minjii.park@samsung.com>
Thu, 16 Jul 2015 05:32:46 +0000 (14:32 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 16 Jul 2015 08:24:11 +0000 (08:24 +0000)
modify ssm resource finder to use changed OIC Virtual Resource
and to get connectivity type of found resources

Change-Id: Ia91fa7e1aed17f614c1dbc5bae9cc37668091174
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1686
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h
service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h
service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h

index 73cbe581bde80011e18f1c4a79e2e6aa000f7b49..42b62b381a4fad02c0bec556585c137fea99e99d 100644 (file)
@@ -57,13 +57,14 @@ class ISSMResource
         ISSMResource(const std::string &n, const std::string &t) :
             name(n), type(t)
         {
-               location = SENSOR_LOCATION_LOCAL;
+            location = SENSOR_LOCATION_LOCAL;
         }
         SENSOR_LOCATION location;
         std::string name;
         std::string type;
         std::string friendlyName;
         std::string ip;
+        int connectivityType;
         std::vector<std::string> inputList;
         std::vector<std::map<std::string, std::string> > outputProperty;
 };
index a11a6ae16aabf64d3c275f352072ec31879d6a59..a4c51d9ec95b6317a3a33f5176c1e1af81b76164 100644 (file)
@@ -19,6 +19,8 @@
  ******************************************************************/
 #include "ResourceFinder.h"
 
+OCConnectivityType g_connectivityType = CT_DEFAULT;
+
 SSMRESULT CResourceFinder::finalConstruct()
 {
     SSMRESULT res = SSM_E_FAIL;
@@ -76,9 +78,9 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
     switch (result)
     {
         case OC_STACK_OK:
-            requestURI << "coap://" << hostAddress << "/oc/core?rt=SSManager.Sensor";
+            requestURI << "coap://" << hostAddress << OC_RSRVD_WELL_KNOWN_URI << "?rt=SSManager.Sensor";
 
-            ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
+            ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
                                                std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
 
             if (ret != OC_STACK_OK)
@@ -105,7 +107,7 @@ void CResourceFinder::presenceHandler(OCStackResult result, const unsigned int n
         case OC_STACK_PRESENCE_TIMEOUT:
             break;
 
-        case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
+        case OC_STACK_PRESENCE_DO_NOT_HANDLE:
             break;
 
         default:
@@ -127,14 +129,14 @@ SSMRESULT CResourceFinder::startResourceFinder()
     std::ostringstream multicastPresenceURI;
     multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
 
-    ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
+    ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
                                        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, multicastPresenceURI.str(),
-                                            "SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
+                                            "SSManager.Sensor", g_connectivityType, std::bind(&CResourceFinder::presenceHandler, this,
                                                     std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
 
     if (ret != OC_STACK_OK)
@@ -194,7 +196,7 @@ void CResourceFinder::onExecute(void *pArg)
             pResourceHandler = new OICResourceHandler();
 
             res = pResourceHandler->initHandler(*pResource, this);
-            if(res != SSM_S_OK)
+            if (res != SSM_S_OK)
             {
                 SAFE_DELETE(pResourceHandler);
                 SSM_CLEANUP_ASSERT(res);
@@ -222,8 +224,9 @@ void CResourceFinder::onExecute(void *pArg)
                 m_mapResourcePresenceHandles.end())
             {
                 ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
-                                                        "SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
-                                                                std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+                                                        "SSManager.Sensor", (OCConnectivityType)(((ISSMResource *)pMessage[1])->connectivityType),
+                                                        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);
@@ -233,9 +236,6 @@ void CResourceFinder::onExecute(void *pArg)
 
             m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);
 
-            if (ret != OC_STACK_OK)
-                SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-
             break;
 
         case RESOURCE_DISCOVER_UNINSTALL_RESOURCE:
index d9ea15fec10ad85cf67c22900e7e55685a05ba11..8aa7fc074ed89a56a150361edde7e93040412a9e 100644 (file)
@@ -146,7 +146,7 @@ CLEANUP: return res;
                 }
 
                 void onGetResourceProfile(const OC::HeaderOptions &headerOptions,
-                                          const OC::OCRepresentation &representation, const int &eCode)
+                                          const OC::OCRepresentation &representation, const int eCode)
                 {
                     //unpack attributeMap
 
@@ -156,6 +156,7 @@ CLEANUP: return res;
                     m_SSMResource.name = m_pResource->host() + m_pResource->uri();
                     m_SSMResource.type = m_pResource->uri().substr(1);
                     m_SSMResource.ip = m_pResource->host();
+                    m_SSMResource.connectivityType = m_pResource->connectivityType();
 
                     //bind default properties
                     outputProperty["name"] = "lifetime";
index acb6e65e81f4cbded3788c63ea137cc06b64d2d4..4df0e973b02f221c016785a5421d82e9b787e187 100644 (file)
@@ -68,8 +68,6 @@ class TemphumidResource
 
             printf("Running thing as %s\n", m_resourceUri.c_str());
             m_resourceRep.setUri(m_resourceUri);
-            m_resourceRep.setResourceTypes(m_resourceTypes);
-            m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
         }
 
         ~TemphumidResource()
index 60316d471561d51f4685fbd77e686fb3a84036cc..9a45dc4960db04c273b61aff427a3e3989402c95 100644 (file)
@@ -68,8 +68,6 @@ class TemphumidResource
 
             printf("Running thing as %s\n", m_resourceUri.c_str());
             m_resourceRep.setUri(m_resourceUri);
-            m_resourceRep.setResourceTypes(m_resourceTypes);
-            m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
         }
 
         ~TemphumidResource()