+// Callback to found resources
+void foundResource(std::shared_ptr<OC::OCResource> resource)
+{
+ std::string resourceURI;
+ std::string hostAddress;
+ try
+ {
+ // Do some operations with resource object.
+ if(resource &&
+ !curResource &&
+ resource->getResourceTypes().at(0) == OC_RSRVD_ES_RES_TYPE_PROV)
+ {
+ std::cout<<"DISCOVERED Resource:"<<std::endl;
+ // Get the resource URI
+ resourceURI = resource->uri();
+ std::cout << "\tURI of the resource: " << resourceURI << std::endl;
+
+ // Get the resource host address
+ hostAddress = resource->host();
+ std::cout << "\tHost address of the resource: " << hostAddress << std::endl;
+
+ // Get the resource types
+ std::cout << "\tList of resource types: " << std::endl;
+ for(auto &resourceTypes : resource->getResourceTypes())
+ {
+ std::cout << "\t\t" << resourceTypes << std::endl;
+ }
+
+ // Get the resource interfaces
+ std::cout << "\tList of resource interfaces: " << std::endl;
+ for(auto &resourceInterfaces : resource->getResourceInterfaces())
+ {
+ std::cout << "\t\t" << resourceInterfaces << std::endl;
+ }
+
+ if(curResource == nullptr)
+ {
+ remoteEnrollee = EasySetup::getInstance()->createRemoteEnrollee(resource);
+ if(!remoteEnrollee)
+ {
+ std::cout << "RemoteEnrollee object is failed for some reasons!" << std::endl;
+ }
+ else
+ {
+ curResource = resource;
+ std::cout << "RemoteEnrollee object is successfully created!" << std::endl;
+ g_cond.notify_all();
+ }
+ }
+ }
+ }
+ catch(std::exception& e)
+ {
+ std::cerr << "Exception in foundResource: "<< e.what() << std::endl;
+ }