[IOT-1477] fix presenceclient sample for linux.
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 26 Oct 2016 00:02:19 +0000 (09:02 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 3 Nov 2016 05:13:23 +0000 (05:13 +0000)
There was some miss codes from
https://gerrit.iotivity.org/gerrit/#/c/13261

Change-Id: I04814c14084acbca13c40c983e2fe9addc29cc4d
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13669
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
(cherry picked from commit 4a0e8ff523c2266633580f6ec0f1ddc2a9c0d58b)
Reviewed-on: https://gerrit.iotivity.org/gerrit/13735
Reviewed-by: George Nash <george.nash@intel.com>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
resource/examples/presenceclient.cpp

index 2b3624f..55698d7 100644 (file)
@@ -90,6 +90,54 @@ void presenceHandler(OCStackResult result, const unsigned int nonce, const std::
     }
 }
 
+void receivedPlatformInfo(const OCRepresentation& rep)
+{
+    std::cout << "\nPlatform Information received ---->\n";
+    std::string value;
+    std::string values[] =
+    {
+        "pi",   "Platform ID                    ",
+        "mnmn", "Manufacturer name              ",
+        "mnml", "Manufacturer url               ",
+        "mnmo", "Manufacturer Model No          ",
+        "mndt", "Manufactured Date              ",
+        "mnpv", "Manufacturer Platform Version  ",
+        "mnos", "Manufacturer OS version        ",
+        "mnhw", "Manufacturer hardware version  ",
+        "mnfv", "Manufacturer firmware version  ",
+        "mnsl", "Manufacturer support url       ",
+        "st",   "Manufacturer system time       "
+    };
+
+    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]) ; i += 2)
+    {
+        if(rep.getValue(values[i], value))
+        {
+            std::cout << values[i + 1] << " : "<< value << std::endl;
+        }
+    }
+}
+
+void receivedDeviceInfo(const OCRepresentation& rep)
+{
+    std::cout << "\nDevice Information received ---->\n";
+    std::string value;
+    std::string values[] =
+    {
+        "di",  "Device ID        ",
+        "n",   "Device name      ",
+        "lcv", "Spec version url ",
+        "dmv", "Data Model Model ",
+    };
+
+    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]); i += 2)
+    {
+        if (rep.getValue(values[i], value))
+        {
+            std::cout << values[i + 1] << " : " << value << std::endl;
+        }
+    }
+}
 // Callback to found resources
 void foundResource(std::shared_ptr<OCResource> resource)
 {
@@ -133,34 +181,35 @@ void foundResource(std::shared_ptr<OCResource> resource)
                 std::cout << "\t\t" << resourceInterfaces << std::endl;
             }
 
-            OCStackResult ret;
+            std::cout << "Querying for platform information... " << std::endl;
 
-             std::cout << "Querying for platform information... " << std::endl;
+            OCStackResult ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI,
+                                                            resource->connectivityType(),
+                                                            &receivedPlatformInfo);
 
-             ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP, NULL);
-
-             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;
+            std::cout << "Querying for device information... " << std::endl;
 
-             ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                       resource->connectivityType(), NULL);
+            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")
             {