namespace NetworkManager {
const std::string IoTDevice_impl::dev_info_uri{"/oic/d"};
+const std::string dev_type_resource{"oic.d."};
+const std::string dev_type_uri{"/oic/res?rt=oic.wk.d"};
+
+using namespace std;
IoTDevice_impl::IoTDevice_impl(std::shared_ptr<OCResource> device_resource)
: dev(device_resource), name("unknown"), model("unknown"), type("unknown"), uuid("unknown"), spec_ver("unknown")
{
host = device_resource->host();
+
+ std::unique_lock<std::mutex> lock(mtx);
+
+ OCPlatform::findResource(device_resource->host(), dev_type_uri, device_resource->connectivityType(),
+ [this](std::shared_ptr<OCResource> res) {
+ auto rt = res->getResourceTypes();
+ for (auto res_type: rt)
+ {
+ if (res_type.compare(0, dev_type_resource.length(), dev_type_resource) == 0)
+ {
+ type = res_type.substr(dev_type_resource.length());
+ }
+ }
+
+ this->cond_var.notify_one();
+ });
+
+ cond_var.wait_for(lock, std::chrono::seconds(CALLBACK_WAIT_TIMEOUT_S));
+
OCPlatform::getDeviceInfo(device_resource->host(),
dev_info_uri,
device_resource->connectivityType(),
this->name = std::move(value);
}
- if(rep.getValue("lcv", value))
+ if(rep.getValue("icv", value))
{
this->spec_ver = std::move(value);
}
this->model = std::move(value);
}
- this->cond_var.notify_all();
+ this->cond_var.notify_one();
});
- std::unique_lock<std::mutex> lock(mtx);
cond_var.wait_for(lock, std::chrono::seconds(CALLBACK_WAIT_TIMEOUT_S));
}