From c5b006ffffd6866c529388cbe357ebb4bdcb09f8 Mon Sep 17 00:00:00 2001 From: "jihwan.seo" Date: Wed, 26 Oct 2016 13:21:59 +0900 Subject: [PATCH] [IOT-1482] fix getPlatformInfo and getDeviceInfo of C++-SDK sample app. cause patch : https://gerrit.iotivity.org/gerrit/#/c/12909/ Change-Id: If50cba713a67239619047ccb012678f73fb42682 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/13677 Tested-by: jenkins-iotivity Reviewed-by: Jaehong Jo Reviewed-by: Jaewook Jung Reviewed-by: Ziran Sun (cherry picked from commit dfb723819d6a26571df5b7c8e308eb8944bd24d6) Reviewed-on: https://gerrit.iotivity.org/gerrit/13875 --- resource/examples/fridgeclient.cpp | 60 ++++++++++++++++++++++++++++++++++-- resource/examples/garageclient.cpp | 56 +++++++++++++++++++++++++++++++-- resource/examples/roomclient.cpp | 56 +++++++++++++++++++++++++++++++-- resource/examples/simpleclient.cpp | 7 +++-- resource/examples/simpleclientHQ.cpp | 7 +++-- resource/examples/winuiclient.cpp | 10 +++--- 6 files changed, 179 insertions(+), 17 deletions(-) diff --git a/resource/examples/fridgeclient.cpp b/resource/examples/fridgeclient.cpp index b5af26f..3641992 100644 --- a/resource/examples/fridgeclient.cpp +++ b/resource/examples/fridgeclient.cpp @@ -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 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) { diff --git a/resource/examples/garageclient.cpp b/resource/examples/garageclient.cpp index b1962f9..0cd8844 100644 --- a/resource/examples/garageclient.cpp +++ b/resource/examples/garageclient.cpp @@ -229,6 +229,55 @@ void getLightRepresentation(std::shared_ptr 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 resource) { @@ -275,7 +324,9 @@ void foundResource(std::shared_ptr 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 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) { diff --git a/resource/examples/roomclient.cpp b/resource/examples/roomclient.cpp index a7587ec..9a50167 100644 --- a/resource/examples/roomclient.cpp +++ b/resource/examples/roomclient.cpp @@ -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 resource) { @@ -212,7 +261,9 @@ void foundResource(std::shared_ptr 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 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; diff --git a/resource/examples/simpleclient.cpp b/resource/examples/simpleclient.cpp index a4c4416..8e16f45 100644 --- a/resource/examples/simpleclient.cpp +++ b/resource/examples/simpleclient.cpp @@ -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 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) { diff --git a/resource/examples/simpleclientHQ.cpp b/resource/examples/simpleclientHQ.cpp index 3977cee..d75a84a 100644 --- a/resource/examples/simpleclientHQ.cpp +++ b/resource/examples/simpleclientHQ.cpp @@ -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 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) { diff --git a/resource/examples/winuiclient.cpp b/resource/examples/winuiclient.cpp index 57fdaa0..bc677cb 100644 --- a/resource/examples/winuiclient.cpp +++ b/resource/examples/winuiclient.cpp @@ -101,7 +101,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)) { @@ -199,8 +199,9 @@ void WinUIClientApp::foundResource(std::shared_ptr resource) OCStackResult ret; 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) { @@ -214,7 +215,8 @@ void WinUIClientApp::foundResource(std::shared_ptr resource) std::cout << "Querying for device information... " << std::endl; ret = OCPlatform::getDeviceInfo(resource->host(), deviceDiscoveryURI, - resource->connectivityType(), &receivedDeviceInfo); + resource->connectivityType(), + &receivedDeviceInfo); if (ret == OC_STACK_OK) -- 2.7.4