Update sample and Group for CA.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Wed, 15 Apr 2015 08:37:56 +0000 (17:37 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 15 Apr 2015 10:56:21 +0000 (10:56 +0000)
We cannot use OC_ALL.
So we call the findResource API twice using OC_ETHERNET and OC_WIFI.

Change-Id: I303c56e7f15c36da3ee0519f9f9a00c092a83928
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/728
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/things-manager/sampleapp/linux/groupsyncaction/group.cpp
service/things-manager/sampleapp/linux/groupsyncaction/phone.cpp
service/things-manager/sdk/src/GroupManager.cpp
service/things-manager/sdk/src/GroupSynchronization.cpp

index 8965c4b..45c1ced 100644 (file)
@@ -75,7 +75,6 @@ void onFindResource(std::shared_ptr< OCResource > resource)
 
 int main(int argc, char* argv[])
 {
-
     // Create PlatformConfig object
     PlatformConfig cfg
     { OC::ServiceType::InProc, OC::ModeType::Both/*OC::ModeType::Server*/, "0.0.0.0", 0,
@@ -113,8 +112,12 @@ int main(int argc, char* argv[])
             }
             else if (selectedMenu == 11)
             {
+                ostringstream query;
+                query << OC_WELL_KNOWN_QUERY << "?rt=core.musicplayer";
+
+                cout << query.str() << endl;
                 result = OCPlatform::findResource("",
-                            "coap://224.0.1.187/oc/core?rt=core.musicplayer",
+                            query.str(),
                             OC_ETHERNET,
                             onFindResource);
 
@@ -134,12 +137,14 @@ int main(int argc, char* argv[])
             }
             else if (selectedMenu == 12)
             {
-                result = OCPlatform::findResource("", 
-                            "coap://224.0.1.187/oc/core?rt=core.speaker",
+                ostringstream query;
+                query << OC_WELL_KNOWN_QUERY << "?rt=core.speaker";
+                result = OCPlatform::findResource("",
+                            query.str(),
                             OC_ETHERNET,
                             onFindResource);
-                
-                result = OCPlatform::findResource("", 
+
+                result = OCPlatform::findResource("",
                             "coap://224.0.1.187/oc/core?rt=core.speaker",
                             OC_WIFI,
                             onFindResource);
index 177399d..d3729a9 100644 (file)
@@ -249,7 +249,9 @@ int main(int argc, char* argv[])
                 std::string resourceInterface = DEFAULT_INTERFACE;
 
                 result = OCPlatform::registerResource(gPhoneResourceHandle, resourceURi,
-                        resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
+                        resourceTypeName, resourceInterface,
+                        NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
+
                 if (OC_STACK_OK == result)
                 {
                     cout << "To register phone resource was successful\n";
index 091621a..30720f0 100755 (executable)
@@ -227,19 +227,19 @@ OCStackResult GroupManager::findCandidateResources(
         query.append("?rt=");
         query.append(resourceTypes.at(i));
 
-        OCPlatform::findResource("", 
+        OCPlatform::findResource("",
                 query,
                 OC_ETHERNET,
                 std::function < void(std::shared_ptr < OCResource > resource)
                         > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
                                 waitsec)));
 
-        // OCPlatform::findResource("",
-        //         query,
-        //         OC_WIFI,
-        //         std::function < void(std::shared_ptr < OCResource > resource)
-        //                 > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
-        //                         waitsec)));
+        OCPlatform::findResource("",
+                query,
+                OC_WIFI,
+                std::function < void(std::shared_ptr < OCResource > resource)
+                        > (std::bind(&GroupManager::onFoundResource, this, std::placeholders::_1,
+                                waitsec)));
     }
 
     if (waitsec >= 0)
@@ -374,6 +374,17 @@ void GroupManager::checkCollectionRepresentation(const OCRepresentation& rep,
                                 std::placeholders::_1, std::placeholders::_2,
                                 std::placeholders::_3, hostAddress, oit->getUri())));
 
+        result = OCPlatform::subscribePresence(presenceHandle, hostAddress,
+                // resourceType,
+                resourceTypes.front(),
+                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())));
+
         if (result == OC_STACK_OK)
         {
             presenceCallbacks.insert(std::make_pair(oit->getUri(), callback));
index ca6819f..bfae87f 100644 (file)
@@ -83,9 +83,9 @@ namespace OIC
                     OC_ETHERNET,
                     std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
 
-            // OCPlatform::findResource("", query,
-            //         OC_WIFI,
-            //         std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
+            OCPlatform::findResource("", query,
+                    OC_WIFI,
+                    std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
         }
 
         bIsFinding = true;
@@ -708,10 +708,10 @@ OCStackResult GroupSynchronization::leaveGroup(
                                 std::bind(&GroupSynchronization::onFindResource, this,
                                         std::placeholders::_1));
 
-                        // OCPlatform::findResource("", resourceName,
-                        //         OC_WIFI,
-                        //         std::bind(&GroupSynchronization::onFindResource, this,
-                        //                 std::placeholders::_1));
+                        OCPlatform::findResource("", resourceName,
+                                OC_WIFI,
+                                std::bind(&GroupSynchronization::onFindResource, this,
+                                        std::placeholders::_1));
 
                         return OC_EH_SLOW;
                     }