From 13e2c508b0505d9996211c28d6d109740cf04701 Mon Sep 17 00:00:00 2001 From: Minji Park Date: Fri, 23 Jan 2015 16:13:58 +0900 Subject: [PATCH] [SSM] Change to make SSM work with Connectivity Abstraction Modify ResourceFinder to find Resources and check presence status with connectivity type Change-Id: I2478904ff08b28ef2cbe131e06b95e3f059618fb Signed-off-by: Minji Park Reviewed-on: https://gerrit.iotivity.org/gerrit/232 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../SSMCore/src/SensorProcessor/ResourceFinder.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp index 9920eda..c687b06 100644 --- a/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp +++ b/service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp @@ -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); -- 2.7.4