From: Minji Park Date: Thu, 16 Jul 2015 05:32:46 +0000 (+0900) Subject: Update soft-sensor-manager to use updated OIC Virtual Resource definitions X-Git-Tag: 0.9.2-beta~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1503c9caacfc486e7208e6a71b3293ad282ab2b1;p=contrib%2Fiotivity.git Update soft-sensor-manager to use updated OIC Virtual Resource definitions 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/1686 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h index 73cbe58..42b62b3 100644 --- a/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h +++ b/service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h @@ -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 inputList; std::vector > outputProperty; }; diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp index a11a6ae..a4c51d9 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp @@ -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: diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h index d9ea15f..8aa7fc0 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h @@ -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"; diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h index acb6e65..4df0e97 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h @@ -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() diff --git a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h index 60316d4..9a45dc4 100644 --- a/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h +++ b/service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h @@ -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()