Apply the 'CA_INT' of Connectivity Abstraction for Things Manager.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Mon, 26 Jan 2015 08:22:50 +0000 (17:22 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 30 Jan 2015 06:03:05 +0000 (06:03 +0000)
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 <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/244
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/things-manager/sdk/src/GroupManager.cpp
service/things-manager/sdk/src/GroupSynchronization.cpp

index a860711..90e3eb3 100644 (file)
@@ -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)
         {
index 4210a00..f641f4b 100644 (file)
@@ -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;