From: jihwan.seo Date: Wed, 26 Oct 2016 00:02:19 +0000 (+0900) Subject: [IOT-1477] fix presenceclient sample for linux. X-Git-Tag: 1.2.1~189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c41502405b5171c7687fb1a4c916766c6db18ff;p=platform%2Fupstream%2Fiotivity.git [IOT-1477] fix presenceclient sample for linux. There was some miss codes from https://gerrit.iotivity.org/gerrit/#/c/13261 Change-Id: I04814c14084acbca13c40c983e2fe9addc29cc4d Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/13669 Tested-by: jenkins-iotivity Reviewed-by: Ashok Babu Channa (cherry picked from commit 4a0e8ff523c2266633580f6ec0f1ddc2a9c0d58b) Reviewed-on: https://gerrit.iotivity.org/gerrit/13735 Reviewed-by: George Nash Reviewed-by: Larry Sachs Reviewed-by: Ziran Sun --- diff --git a/resource/examples/presenceclient.cpp b/resource/examples/presenceclient.cpp index 2b3624f..55698d7 100644 --- a/resource/examples/presenceclient.cpp +++ b/resource/examples/presenceclient.cpp @@ -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 resource) { @@ -133,34 +181,35 @@ void foundResource(std::shared_ptr 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") {