fix Sample App related getPlatformInfo/getDeviceInfo
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 16 Nov 2016 06:08:17 +0000 (15:08 +0900)
committerZiran Sun <ziran.sun@samsung.com>
Thu, 17 Nov 2016 09:57:00 +0000 (09:57 +0000)
Change-Id: I07e2e0e24241f0c5dd53259f8333eccc722d4e39
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/14405
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
resource/examples/fridgeclient.cpp
resource/examples/garageclient.cpp
resource/examples/presenceclient.cpp
resource/examples/roomclient.cpp
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/winuiclient.cpp

index 3641992..2fe4a29 100644 (file)
@@ -136,38 +136,43 @@ class ClientFridge
 
         OCStackResult ret;
 
-        std::cout << "Querying for platform information... " << std::endl;
+        if (0 == strcmp(resource->uri().c_str(), platformDiscoveryURI.c_str()))
+        {
+            std::cout << "Querying for platform information... " << std::endl;
 
-        ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
-                                          resource->connectivityType(),
-                                          std::bind(&ClientFridge::receivedPlatformInfo,
-                                                    this, PH::_1));
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                              resource->connectivityType(),
+                                              std::bind(&ClientFridge::receivedPlatformInfo,
+                                                        this, PH::_1));
 
-        if (ret == OC_STACK_OK)
-        {
-            std::cout << "Get platform information is done." << std::endl;
-        }
-        else
-        {
-            std::cout << "Get platform information failed." << std::endl;
+            if (ret == OC_STACK_OK)
+            {
+                std::cout << "Get platform information is done." << std::endl;
+            }
+            else
+            {
+                std::cout << "Get platform information failed." << std::endl;
+            }
         }
 
-        std::cout << "Querying for device information... " << std::endl;
+        if (0 == strcmp(resource->uri().c_str(), deviceDiscoveryURI.c_str()))
+        {
+            std::cout << "Querying for device information... " << std::endl;
 
-        ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                        resource->connectivityType(),
-                                        std::bind(&ClientFridge::receivedDeviceInfo,
-                                                  this, PH::_1));
+            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
+                                            resource->connectivityType(),
+                                            std::bind(&ClientFridge::receivedDeviceInfo,
+                                                      this, PH::_1));
 
-        if (ret == OC_STACK_OK)
-        {
-            std::cout << "Getting device information is done." << std::endl;
-        }
-        else
-        {
-            std::cout << "Getting device information failed." << std::endl;
+            if (ret == OC_STACK_OK)
+            {
+                std::cout << "Getting device information is done." << std::endl;
+            }
+            else
+            {
+                std::cout << "Getting device information failed." << std::endl;
+            }
         }
-
         // we have now found a resource, so lets create a few resource objects
         // for the other resources that we KNOW are associated with the intel.fridge
         // server, and query them.
index 0cd8844..a544d2a 100644 (file)
@@ -322,34 +322,41 @@ void foundResource(std::shared_ptr<OCResource> resource)
             }
 
             OCStackResult ret;
-            std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
-                                              resource->connectivityType(),
-                                              &receivedPlatformInfo);
-
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Get platform information is done." << std::endl;
-            }
-            else
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))
             {
-                std::cout << "Get platform information failed." << std::endl;
-            }
-
-            std::cout << "Querying for device information... " << std::endl;
+                std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                            resource->connectivityType(),
-                                            &receivedDeviceInfo);
+                ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                                  resource->connectivityType(),
+                                                  &receivedPlatformInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Getting device information is done." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Get platform information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Get platform information failed." << std::endl;
+                }
             }
-            else
+
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))
             {
-                std::cout << "Getting device information failed." << std::endl;
+                std::cout << "Querying for device information... " << std::endl;
+
+                ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
+                                                resource->connectivityType(),
+                                                &receivedDeviceInfo);
+
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Getting device information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Getting device information failed." << std::endl;
+                }
             }
 
             if(resourceURI == "/a/garage")
index 55698d7..329c321 100644 (file)
@@ -181,34 +181,41 @@ void foundResource(std::shared_ptr<OCResource> resource)
                 std::cout << "\t\t" << resourceInterfaces << std::endl;
             }
 
-            std::cout << "Querying for platform information... " << std::endl;
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))
+            {
+                std::cout << "Querying for platform information... " << std::endl;
 
-            OCStackResult ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI,
-                                                            resource->connectivityType(),
-                                                            &receivedPlatformInfo);
+                OCStackResult ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI,
+                                                                resource->connectivityType(),
+                                                                &receivedPlatformInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Get platform information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Get platform information failed." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Get platform information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Get platform information failed." << std::endl;
+                }
             }
 
-            std::cout << "Querying for device information... " << std::endl;
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))
+            {
+                std::cout << "Querying for device information... " << std::endl;
 
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                            resource->connectivityType(),
-                                            &receivedDeviceInfo);
+                OCStackResult ret = OCPlatform::getDeviceInfo(resource->host(),
+                                                              deviceDiscoveryURI,
+                                                              resource->connectivityType(),
+                                                              &receivedDeviceInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Getting device information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Getting device information failed." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Getting device information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Getting device information failed." << std::endl;
+                }
             }
 
             if(resourceURI == "/a/light")
index 50c5584..c6bdac0 100644 (file)
@@ -258,33 +258,40 @@ void foundResource(std::shared_ptr<OCResource> resource)
             }
 
             OCStackResult ret;
-            std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
-                                              resource->connectivityType(),
-                                              &receivedPlatformInfo);
-
-            if (ret == OC_STACK_OK)
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))
             {
-                std::cout << "Get platform information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Get platform information failed." << std::endl;
-            }
+                std::cout << "Querying for platform information... " << std::endl;
 
-            std::cout << "Querying for device information... " << std::endl;
+                ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                                  resource->connectivityType(),
+                                                  &receivedPlatformInfo);
 
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                            resource->connectivityType(),
-                                            &receivedDeviceInfo);
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Getting device information is done." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Get platform information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Get platform information failed." << std::endl;
+                }
             }
-            else
+
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))
             {
-                std::cout << "Getting device information failed." << std::endl;
+                std::cout << "Querying for device information... " << std::endl;
+
+                ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
+                                                resource->connectivityType(),
+                                                &receivedDeviceInfo);
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Getting device information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Getting device information failed." << std::endl;
+                }
             }
 
             if(resourceURI == "/a/room")
index 8e16f45..4eeba94 100644 (file)
@@ -431,35 +431,40 @@ void foundResource(std::shared_ptr<OCResource> resource)
             hostAddress = resource->host();
             std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
 
-            OCStackResult ret;
-
-            std::cout << "Querying for platform information... " << std::endl;
-
-            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
-                                              resource->connectivityType(),
-                                              &receivedPlatformInfo);
-
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Get platform information is done." << std::endl;
-            }
-            else
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))
             {
-                std::cout << "Get platform information failed." << std::endl;
+                std::cout << "Querying for platform information... " << std::endl;
+                OCStackResult ret = OCPlatform::getPlatformInfo(resource->host(),
+                                                                platformDiscoveryURI,
+                                                                resource->connectivityType(),
+                                                                &receivedPlatformInfo);
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Get platform information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Get platform information failed." << std::endl;
+                }
             }
 
-            std::cout << "Querying for device information... " << std::endl;
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))
+            {
+                std::cout << "Querying for device information... " << std::endl;
 
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                        resource->connectivityType(), &receivedDeviceInfo);
+                OCStackResult ret = OCPlatform::getDeviceInfo(resource->host(),
+                                                              deviceDiscoveryURI,
+                                                              resource->connectivityType(),
+                                                              &receivedDeviceInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Getting device information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Getting device information failed." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Getting device information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Getting device information failed." << std::endl;
+                }
             }
 
             // Get the resource types
index d75a84a..d6c482a 100644 (file)
@@ -394,34 +394,39 @@ void foundResource(std::shared_ptr<OCResource> resource)
             std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
 
             OCStackResult ret;
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))
+            {
+                std::cout << "Querying for platform information... " << std::endl;
 
-            std::cout << "Querying for platform information... " << std::endl;
-
-            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
-                                              resource->connectivityType(),
-                                              &receivedPlatformInfo);
+                ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                                  resource->connectivityType(),
+                                                  &receivedPlatformInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Get platform information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Get platform information failed." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Get platform information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Get platform information failed." << std::endl;
+                }
             }
 
-            std::cout << "Querying for device information... " << std::endl;
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))
+            {
+                std::cout << "Querying for device information... " << std::endl;
 
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                       resource->connectivityType(), &receivedDeviceInfo);
+                ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
+                                           resource->connectivityType(), &receivedDeviceInfo);
 
-            if (ret == OC_STACK_OK)
-            {
-                std::cout << "Getting device information is done." << std::endl;
-            }
-            else
-            {
-                std::cout << "Getting device information failed." << std::endl;
+                if (ret == OC_STACK_OK)
+                {
+                    std::cout << "Getting device information is done." << std::endl;
+                }
+                else
+                {
+                    std::cout << "Getting device information failed." << std::endl;
+                }
             }
 
             // Get the resource types
index bc677cb..95d2f79 100644 (file)
@@ -197,35 +197,41 @@ void WinUIClientApp::foundResource(std::shared_ptr<OCResource> resource)
             }\r
 \r
             OCStackResult ret;\r
-            std::cout << "Querying for platform information... " << std::endl;\r
-\r
-            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,\r
-                                              resource->connectivityType(),\r
-                                              &receivedPlatformInfo);\r
-\r
-            if (ret == OC_STACK_OK)\r
-            {\r
-                std::cout << "Get platform information is done." << std::endl;\r
-            }\r
-            else\r
+            if (0 == strcmp(resourceURI.c_str(), platformDiscoveryURI.c_str()))\r
             {\r
-                std::cout << "Get platform information failed." << std::endl;\r
+                std::cout << "Querying for platform information... " << std::endl;\r
+\r
+                ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,\r
+                                                  resource->connectivityType(),\r
+                                                  &receivedPlatformInfo);\r
+\r
+                if (ret == OC_STACK_OK)\r
+                {\r
+                    std::cout << "Get platform information is done." << std::endl;\r
+                }\r
+                else\r
+                {\r
+                    std::cout << "Get platform information failed." << std::endl;\r
+                }\r
             }\r
 \r
-            std::cout << "Querying for device information... " << std::endl;\r
+            if (0 == strcmp(resourceURI.c_str(), deviceDiscoveryURI.c_str()))\r
+            {\r
+                std::cout << "Querying for device information... " << std::endl;\r
 \r
-            ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,\r
-                                            resource->connectivityType(),\r
-                                            &receivedDeviceInfo);\r
+                ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,\r
+                                                resource->connectivityType(),\r
+                                                &receivedDeviceInfo);\r
 \r
 \r
-            if (ret == OC_STACK_OK)\r
-            {\r
-                std::cout << "Getting device information is done." << std::endl;\r
-            }\r
-            else\r
-            {\r
-                std::cout << "Getting device information failed." << std::endl;\r
+                if (ret == OC_STACK_OK)\r
+                {\r
+                    std::cout << "Getting device information is done." << std::endl;\r
+                }\r
+                else\r
+                {\r
+                    std::cout << "Getting device information failed." << std::endl;\r
+                }\r
             }\r
 \r
             if (resourceURI == "/a/media")\r