[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 b5af26f..3641992 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 b1962f9..0cd8844 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 a7587ec..9a50167 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 a4c4416..8e16f45 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 3977cee..d75a84a 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 57fdaa0..bc677cb 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