From 3deba10f91d5d5990bf29cab4f6283e98dacf12a Mon Sep 17 00:00:00 2001 From: HyunJun Kim Date: Mon, 26 Jan 2015 17:22:50 +0900 Subject: [PATCH] Apply the 'CA_INT' of Connectivity Abstraction for Things Manager. The Thing Manager does not prepare for the CA. So we provide different function of CA in the same API. Change-Id: I8b64608e352a19fddedf42beef647003d18e61f8 Signed-off-by: HyunJun Kim Reviewed-on: https://gerrit.iotivity.org/gerrit/244 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- service/things-manager/sdk/src/GroupManager.cpp | 30 +++++++++++++++++++--- .../sdk/src/GroupSynchronization.cpp | 6 +++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/service/things-manager/sdk/src/GroupManager.cpp b/service/things-manager/sdk/src/GroupManager.cpp index a860711..90e3eb3 100644 --- a/service/things-manager/sdk/src/GroupManager.cpp +++ b/service/things-manager/sdk/src/GroupManager.cpp @@ -217,13 +217,22 @@ OCStackResult GroupManager::findCandidateResources(std::vector< std::string > re for (unsigned int i = 0; i < resourceTypes.size(); ++i) { - std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl; - std::string query = "coap://224.0.1.187/oc/core?rt="; + std::string query = "coap://224.0.1.187:5298/oc/core?rt="; + // std::cout << "resourceTypes : " << resourceTypes.at(i) << std::endl; query.append(resourceTypes.at(i)); + +#ifdef CA_INT + OCPlatform::findResource("", query.c_str(), + OC_ETHERNET | OC_WIFI, + std::function < void(std::shared_ptr < OCResource > resource) + > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1, + waitsec))); +#else OCPlatform::findResource("", query.c_str(), std::function < void(std::shared_ptr < OCResource > resource) - > (std::bind(&GroupManager::onFoundResource, this, - std::placeholders::_1, waitsec))); + > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1, + waitsec))); +#endif } if (waitsec >= 0) @@ -345,6 +354,18 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep, std::cout << "\t\tconvertRT : " << resourceType << std::endl; std::cout << "\t\thost : " << hostAddress << std::endl; OCPlatform::OCPresenceHandle presenceHandle; + +#ifdef CA_INT + OCStackResult result = OCPlatform::subscribePresence(presenceHandle, hostAddress, + resourceType, + OC_ETHERNET | OC_WIFI, + std::function< + void(OCStackResult result, const unsigned int nonce, + const std::string& hostAddress) >( + std::bind(&GroupManager::collectionPresenceHandler, this, + std::placeholders::_1, std::placeholders::_2, + std::placeholders::_3, hostAddress, oit->getUri()))); +#else OCStackResult result = OCPlatform::subscribePresence(presenceHandle, hostAddress, resourceType, std::function< @@ -353,6 +374,7 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep, std::bind(&GroupManager::collectionPresenceHandler, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, hostAddress, oit->getUri()))); +#endif if (result == OC_STACK_OK) { diff --git a/service/things-manager/sdk/src/GroupSynchronization.cpp b/service/things-manager/sdk/src/GroupSynchronization.cpp index 4210a00..f641f4b 100644 --- a/service/things-manager/sdk/src/GroupSynchronization.cpp +++ b/service/things-manager/sdk/src/GroupSynchronization.cpp @@ -273,8 +273,14 @@ namespace OIC std::vector< std::string > resourceInterface; resourceInterface.push_back(DEFAULT_INTERFACE); + +#ifdef CA_INT + OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri, + OC_ETHERNET | OC_WIFI, 1, resourceTypes, resourceInterface); +#else OCResource::Ptr groupSyncResource = OCPlatform::constructResourceObject(host, uri, 1, resourceTypes, resourceInterface); +#endif groupSyncResourceList[type[0]] = groupSyncResource; cout << "GroupSynchronization::joinGroup : creating groupSyncResource." << endl; -- 2.7.4