[IOT-1482] fix getPlatformInfo and getDeviceInfo of C++-SDK sample app.
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 26 Oct 2016 04:21:59 +0000 (13:21 +0900)
committerZiran Sun <ziran.sun@samsung.com>
Mon, 31 Oct 2016 15:35:04 +0000 (15:35 +0000)
cause patch : https://gerrit.iotivity.org/gerrit/#/c/12909/

Change-Id: If50cba713a67239619047ccb012678f73fb42682
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/13677
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: Jaewook Jung <jw0213.jung@samsung.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
(cherry picked from commit dfb723819d6a26571df5b7c8e308eb8944bd24d6)
Reviewed-on: https://gerrit.iotivity.org/gerrit/13875

resource/examples/fridgeclient.cpp
resource/examples/garageclient.cpp
resource/examples/roomclient.cpp
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp
resource/examples/winuiclient.cpp

index b5af26fc82041f3005afb971aa2d16e53fb69405..3641992de892f5f6f483d015dc74b8288c686bb3 100644 (file)
@@ -73,6 +73,55 @@ class ClientFridge
     }
 
     private:
+    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;
+            }
+        }
+    }
+
     void foundDevice(std::shared_ptr<OCResource> resource)
     {
         using namespace OC::OCPlatform;
@@ -89,7 +138,10 @@ class ClientFridge
 
         std::cout << "Querying for platform information... " << std::endl;
 
-        ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP, NULL);
+        ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                          resource->connectivityType(),
+                                          std::bind(&ClientFridge::receivedPlatformInfo,
+                                                    this, PH::_1));
 
         if (ret == OC_STACK_OK)
         {
@@ -102,8 +154,10 @@ class ClientFridge
 
         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(),
+                                        std::bind(&ClientFridge::receivedDeviceInfo,
+                                                  this, PH::_1));
 
         if (ret == OC_STACK_OK)
         {
index b1962f9c9e0b42504a9f3d4e0af3da436b1227d0..0cd8844b5253234caf8d5abd4917a4e62f91673f 100644 (file)
@@ -229,6 +229,55 @@ void getLightRepresentation(std::shared_ptr<OCResource> resource)
     }
 }
 
+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)
 {
@@ -275,7 +324,9 @@ void foundResource(std::shared_ptr<OCResource> resource)
             OCStackResult ret;
             std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP, NULL);
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                              resource->connectivityType(),
+                                              &receivedPlatformInfo);
 
             if (ret == OC_STACK_OK)
             {
@@ -289,7 +340,8 @@ void foundResource(std::shared_ptr<OCResource> resource)
             std::cout << "Querying for device information... " << std::endl;
 
             ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                    resource->connectivityType(), NULL);
+                                            resource->connectivityType(),
+                                            &receivedDeviceInfo);
 
             if (ret == OC_STACK_OK)
             {
index a7587ec99d8ecb84445d133e13d18056fc30ecf0..9a5016799b82ec936d3340b9ad3c543acfdcb7ef 100644 (file)
@@ -167,6 +167,55 @@ void onPut(const HeaderOptions& /*headerOptions*/, const OCRepresentation& rep,
     }
 }
 
+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)
 {
@@ -212,7 +261,9 @@ void foundResource(std::shared_ptr<OCResource> resource)
             OCStackResult ret;
             std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP, NULL);
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                              resource->connectivityType(),
+                                              &receivedPlatformInfo);
 
             if (ret == OC_STACK_OK)
             {
@@ -226,7 +277,8 @@ void foundResource(std::shared_ptr<OCResource> resource)
             std::cout << "Querying for device information... " << std::endl;
 
             ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,
-                                       resource->connectivityType(), NULL);
+                                            resource->connectivityType(),
+                                            &receivedDeviceInfo);
             if (ret == OC_STACK_OK)
             {
                 std::cout << "Getting device information is done." << std::endl;
index a4c44164f3d2c3f8f89557611583c395db758290..8e16f45d300dedab140933bd003d6882e7c3139a 100644 (file)
@@ -357,7 +357,7 @@ void receivedPlatformInfo(const OCRepresentation& rep)
         "st",   "Manufacturer system time       "
     };
 
-    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]) ; i += 2)
+    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]); i += 2)
     {
         if(rep.getValue(values[i], value))
         {
@@ -435,8 +435,9 @@ void foundResource(std::shared_ptr<OCResource> resource)
 
             std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP,
-                    &receivedPlatformInfo);
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                              resource->connectivityType(),
+                                              &receivedPlatformInfo);
 
             if (ret == OC_STACK_OK)
             {
index 3977cee2bd1f778674ee9e2069a9bec1e92ea2cc..d75a84ae4812f2720d019fa67f05dc6286c356f4 100644 (file)
@@ -321,7 +321,7 @@ void receivedPlatformInfo(const OCRepresentation& rep)
         "st",   "Manufacturer system time       "
     };
 
-    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]) ; i += 2)
+    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]); i += 2)
     {
         if(rep.getValue(values[i], value))
         {
@@ -397,8 +397,9 @@ void foundResource(std::shared_ptr<OCResource> resource)
 
             std::cout << "Querying for platform information... " << std::endl;
 
-            ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP,
-                    &receivedPlatformInfo);
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,
+                                              resource->connectivityType(),
+                                              &receivedPlatformInfo);
 
             if (ret == OC_STACK_OK)
             {
index 57fdaa036ca00646fbe3e87917a70da1245b8f6a..bc677cb8ef2c7728dab59d3253dae4966ae376ac 100644 (file)
@@ -101,7 +101,7 @@ void receivedPlatformInfo(const OCRepresentation& rep)
         "st",   "Manufacturer system time       "\r
     };\r
 \r
-    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]) ; i += 2)\r
+    for (unsigned int i = 0; i < sizeof(values) / sizeof(values[0]); i += 2)\r
     {\r
         if(rep.getValue(values[i], value))\r
         {\r
@@ -199,8 +199,9 @@ void WinUIClientApp::foundResource(std::shared_ptr<OCResource> resource)
             OCStackResult ret;\r
             std::cout << "Querying for platform information... " << std::endl;\r
 \r
-            ret = OCPlatform::getPlatformInfo("", platformDiscoveryURI, CT_ADAPTER_IP,\r
-                    &receivedPlatformInfo);\r
+            ret = OCPlatform::getPlatformInfo(resource->host(), platformDiscoveryURI,\r
+                                              resource->connectivityType(),\r
+                                              &receivedPlatformInfo);\r
 \r
             if (ret == OC_STACK_OK)\r
             {\r
@@ -214,7 +215,8 @@ void WinUIClientApp::foundResource(std::shared_ptr<OCResource> resource)
             std::cout << "Querying for device information... " << std::endl;\r
 \r
             ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI,\r
-                                       resource->connectivityType(), &receivedDeviceInfo);\r
+                                            resource->connectivityType(),\r
+                                            &receivedDeviceInfo);\r
 \r
 \r
             if (ret == OC_STACK_OK)\r