const int SUCCESS_RESPONSE = 0;
std::shared_ptr<OCResource> curResource;
+std::mutex resourceLock;
int observe_count()
{
// Callback to found resources
void foundResource(std::shared_ptr<OCResource> resource)
{
+ std::lock_guard<std::mutex> lock(resourceLock);
if(curResource)
{
std::cout << "Found another resource, ignoring"<<std::endl;
}
catch(std::exception& e)
{
+ std::cerr << "Exception in foundResource: "<< e.what() <<std::endl;
//log(e.what());
}
}
int main(int argc, char* argv[]) {
+ std::ostringstream requestURI;
+
+
// Create PlatformConfig object
PlatformConfig cfg {
OC::ServiceType::InProc,
try
{
// Find all resources
- OCPlatform::findResource("", "coap://224.0.1.187/oc/core", &foundResource);
+ requestURI << OC_MULTICAST_DISCOVERY_URI;
+
+ OCPlatform::findResource("", requestURI.str(), OC_ALL, &foundResource);
std::cout<< "Finding Resource... " <<std::endl;
// A condition variable will free the mutex it is given, then do a non-
}catch(OCException& e)
{
- //log(e.what());
+ oclog() << "Exception in main: "<< e.what();
}
return 0;
}
+