switch(config.mode)
{
case ModeType::Server:
- m_server = m_WrapperInstance->CreateServerWrapper(*this, m_csdkLock, config);
+ m_server = m_WrapperInstance->CreateServerWrapper(m_csdkLock, config);
break;
case ModeType::Client:
- m_client = m_WrapperInstance->CreateClientWrapper(*this, m_csdkLock, config);
+ m_client = m_WrapperInstance->CreateClientWrapper(m_csdkLock, config);
break;
case ModeType::Both:
- m_server = m_WrapperInstance->CreateServerWrapper(*this, m_csdkLock, config);
- m_client = m_WrapperInstance->CreateClientWrapper(*this, m_csdkLock, config);
+ m_server = m_WrapperInstance->CreateServerWrapper(m_csdkLock, config);
+ m_client = m_WrapperInstance->CreateClientWrapper(m_csdkLock, config);
break;
}
}
}
OCStackResult OCPlatform_impl::notifyListOfObservers(OCResourceHandle resourceHandle,
- ObservationIds& observationIds,
- const std::shared_ptr<OCResourceResponse> pResponse)
+ ObservationIds& observationIds,
+ const std::shared_ptr<OCResourceResponse> pResponse)
{
return notifyListOfObservers(resourceHandle, observationIds, pResponse, m_cfg.QoS);
}
OCStackResult OCPlatform_impl::notifyListOfObservers(OCResourceHandle resourceHandle,
- ObservationIds& observationIds,
- const std::shared_ptr<OCResourceResponse> pResponse,
- QualityOfService QoS)
+ ObservationIds& observationIds,
+ const std::shared_ptr<OCResourceResponse> pResponse,
+ QualityOfService QoS)
{
if(!pResponse)
{
return result_guard(OC_STACK_ERROR);
}
- std::string payload(pResponse->getPayload());
+ std::string payload(pResponse->getResourceRepresentation().getJSONRepresentation());
return result_guard(
OCNotifyListOfObservers(resourceHandle,
host, resourceName, resourceHandler, QoS);
}
+ OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ FindDeviceCallback deviceInfoHandler)
+ {
+ return result_guard(getDeviceInfo(host, deviceURI, deviceInfoHandler, m_cfg.QoS));
+ }
+
+ OCStackResult OCPlatform_impl::getDeviceInfo(const std::string& host,
+ const std::string& deviceURI,
+ FindDeviceCallback deviceInfoHandler,
+ QualityOfService QoS)
+ {
+ return checked_guard(m_client, &IClientWrapper::ListenForDevice,
+ host, deviceURI, deviceInfoHandler, QoS);
+ }
OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
std::string& resourceURI,
resourceInterface, entityHandler, resourceProperty);
}
+ OCStackResult OCPlatform_impl::registerDeviceInfo(const OCDeviceInfo deviceInfo)
+ {
+ return checked_guard(m_server, &IServerWrapper::registerDeviceInfo, deviceInfo);
+ }
- OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
- const std::shared_ptr<OCResource> resource)
- {
- uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
-
- return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
- ref(resourceHandle), resource->host(), resource->uri(), "core.remote",
- "oc.mi.def", (EntityHandler) NULL, resourceProperty);
+ OCStackResult OCPlatform_impl::registerResource(OCResourceHandle& resourceHandle,
+ const std::shared_ptr< OCResource > resource)
+ {
+ uint8_t resourceProperty = OC_DISCOVERABLE | OC_OBSERVABLE;
+ std::vector<std::string> resourceTypes = resource->getResourceTypes();
+ return checked_guard(m_server, &IServerWrapper::registerResourceWithHost,
+ ref(resourceHandle), resource->host(), resource->uri(), resourceTypes[0]/*"core.remote"*/, "oc.mi.def",
+ (EntityHandler) nullptr, resourceProperty);
+ }
- }
OCStackResult OCPlatform_impl::unregisterResource(const OCResourceHandle& resourceHandle) const
{
return checked_guard(m_server, &IServerWrapper::unregisterResource,
const std::string& host,
SubscribeCallback presenceHandler)
{
+ return subscribePresence(presenceHandle, host, "", presenceHandler);
+ }
+
+ OCStackResult OCPlatform_impl::subscribePresence(OCPresenceHandle& presenceHandle,
+ const std::string& host,
+ const std::string& resourceType,
+ SubscribeCallback presenceHandler)
+ {
return checked_guard(m_client, &IClientWrapper::SubscribePresence,
- &presenceHandle, host, presenceHandler);
+ &presenceHandle, host, resourceType, presenceHandler);
}
OCStackResult OCPlatform_impl::unsubscribePresence(OCPresenceHandle presenceHandle)
ref(presenceHandle));
}
+ OCStackResult OCPlatform_impl::sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
+ {
+ return checked_guard(m_server, &IServerWrapper::sendResponse,
+ pResponse);
+ }
} //namespace OC