X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fexamples%2FsimpleclientHQ.cpp;h=e4d2f0bc665821fd6fe83bc771e9045fe2e86fd8;hb=8c01dff2c5bc5496f7dc1632c498943ec6ecb015;hp=af0bea4af7eaf2be613130cc3d919fec25b39619;hpb=935fdb9b67b6c10d007e652e9e2e028fd6ccfe09;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/examples/simpleclientHQ.cpp b/resource/examples/simpleclientHQ.cpp index af0bea4..e4d2f0b 100644 --- a/resource/examples/simpleclientHQ.cpp +++ b/resource/examples/simpleclientHQ.cpp @@ -370,35 +370,57 @@ void foundResource(std::shared_ptr resource) void PrintUsage() { std::cout << std::endl; - std::cout << "Usage : simpleclientHQ " << std::endl; + std::cout << "Usage : simpleclientHQ " << std::endl; std::cout << " ObserveType : 1 - Observe" << std::endl; std::cout << " ObserveType : 2 - ObserveAll" << std::endl; + std::cout << " ConnectivityType: Default IP" << std::endl; + std::cout << " ConnectivityType : 0 - IP"<< std::endl; } int main(int argc, char* argv[]) { std::ostringstream requestURI; + OCConnectivityType connectivityType = CT_ADAPTER_IP; try { if (argc == 1) { OBSERVE_TYPE_TO_USE = ObserveType::Observe; } - else if (argc == 2) + else if (argc ==2 || argc==3) { int value = std::stoi(argv[1]); if (value == 1) - { OBSERVE_TYPE_TO_USE = ObserveType::Observe; - } else if (value == 2) - { OBSERVE_TYPE_TO_USE = ObserveType::ObserveAll; - } else - { OBSERVE_TYPE_TO_USE = ObserveType::Observe; + + if(argc == 3) + { + std::size_t inputValLen; + int optionSelected = std::stoi(argv[2], &inputValLen); + + if(inputValLen == strlen(argv[2])) + { + if(optionSelected == 0) + { + std::cout << "Using IP."<< std::endl; + connectivityType = CT_ADAPTER_IP; + } + else + { + std::cout << "Invalid connectivity type selected. Using default IP" + << std::endl; + } + } + else + { + std::cout << "Invalid connectivity type selected. Using default IP" + << std::endl; + } } } else @@ -407,11 +429,14 @@ int main(int argc, char* argv[]) { return -1; } } - catch(std::exception&) + catch(std::exception& e) { - std::cout << "Invalid input argument. Using Observe as observe type" << std::endl; + std::cout << "Invalid input argument." << std::endl; + PrintUsage(); + return -1; } + // Create PlatformConfig object PlatformConfig cfg { OC::ServiceType::InProc, @@ -426,17 +451,17 @@ int main(int argc, char* argv[]) { try { // Find all resources - requestURI << OC_MULTICAST_DISCOVERY_URI << "?rt=core.light"; + requestURI << OC_RSRVD_WELL_KNOWN_URI << "?rt=core.light"; OCPlatform::findResource("", requestURI.str(), - OC_ALL, &foundResource, OC::QualityOfService::LowQos); + connectivityType, &foundResource, OC::QualityOfService::LowQos); std::cout<< "Finding Resource... " <