1 //******************************************************************
3 // Copyright 2015 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #include "OCPlatform.h"
23 bool g_foundResource = true;
25 void foundResource(std::shared_ptr< OC::OCResource > resource)
29 std::cout << "Found resource response." << std::endl;
32 if (resource->uri() == "/a/light")
34 std::cout << "Found Resource at @ URI: " << resource->uri() << "\tHost Address: " <<
35 resource->host() << std::endl;
40 std::cout << "Resource is invalid " << resource->uri() << std::endl;
42 g_foundResource = false;
45 catch (std::exception &ex)
47 std::cout << "Exception: " << ex.what() << " in foundResource" << std::endl;
54 OC::PlatformConfig cfg;
55 OC::OCPlatform::Configure(cfg);
56 bool sendRequest = true;
58 std::cout << "Created Platform..." << std::endl;
60 while (g_foundResource)
67 std::cout << "Finding Resource light" << std::endl;
68 OC::OCPlatform::findResource("", "/oic/res?rt=core.light", CT_DEFAULT, &foundResource);
71 catch (OC::OCException &ex)
74 std::cout << "Exception finding resources : " << ex.reason() << std::endl;