From 4a0e8ff523c2266633580f6ec0f1ddc2a9c0d58b Mon Sep 17 00:00:00 2001 From: "jihwan.seo" Date: Wed, 26 Oct 2016 09:02:19 +0900 Subject: [PATCH] [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 --- resource/examples/presenceclient.cpp | 95 +++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 23 deletions(-) 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") { -- 2.7.4