1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH 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 //******************************************************************
25 // Description: Implementation of the OCPlatform.
29 //*********************************************************************
30 #include <OCPlatform.h>
35 void Configure(const PlatformConfig& config)
37 OCPlatform_impl::Configure(config);
40 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
42 return OCPlatform_impl::Instance().setDefaultDeviceEntityHandler(entityHandler);
45 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle,
48 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle, QoS);
51 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
53 return OCPlatform_impl::Instance().notifyAllObservers(resourceHandle);
56 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
57 ObservationIds& observationIds,
58 const std::shared_ptr<OCResourceResponse> pResponse)
60 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
61 observationIds, pResponse);
64 OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle,
65 ObservationIds& observationIds,
66 const std::shared_ptr<OCResourceResponse> pResponse,
69 return OCPlatform_impl::Instance().notifyListOfObservers(resourceHandle,
70 observationIds, pResponse, QoS);
74 OCResource::Ptr constructResourceObject(const std::string& host,
75 const std::string& uri,
76 OCConnectivityType connectivityType,
78 const std::vector<std::string>& resourceTypes,
79 const std::vector<std::string>& interfaces)
81 return OCPlatform_impl::Instance().constructResourceObject(host, uri, connectivityType,
83 resourceTypes, interfaces);
86 OCStackResult findResource(const std::string& host,
87 const std::string& resourceName,
88 OCConnectivityType connectivityType,
89 FindCallback resourceHandler)
91 return OCPlatform_impl::Instance().findResource(host, resourceName,
92 connectivityType, resourceHandler);
95 OCStackResult findResource(const std::string& host,
96 const std::string& resourceName,
97 OCConnectivityType connectivityType,
98 FindCallback resourceHandler, QualityOfService QoS)
100 return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
101 resourceHandler, QoS);
104 OCStackResult getDeviceInfo(const std::string& host,
105 const std::string& deviceURI,
106 OCConnectivityType connectivityType,
107 FindDeviceCallback deviceInfoHandler)
109 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
110 connectivityType, deviceInfoHandler);
113 OCStackResult getDeviceInfo(const std::string& host,
114 const std::string& deviceURI,
115 OCConnectivityType connectivityType,
116 FindDeviceCallback deviceInfoHandler,
117 QualityOfService QoS)
119 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
120 deviceInfoHandler, QoS);
124 OCStackResult findResource(const std::string& host,
125 const std::string& resourceName,
126 FindCallback resourceHandler)
128 //TODO-CA Revisit this API
130 return OCPlatform_impl::Instance().findResource(host, resourceName,
131 OC_WIFI, resourceHandler);
133 return OCPlatform_impl::Instance().findResource(host, resourceName, resourceHandler);
137 OCStackResult findResource(const std::string& host,
138 const std::string& resourceName,
139 FindCallback resourceHandler, QualityOfService QoS)
141 //TODO-CA Revisit this API
143 return OCPlatform_impl::Instance().findResource(host, resourceName,
144 OC_WIFI, resourceHandler, QoS);
146 return OCPlatform_impl::Instance().findResource(host, resourceName,
147 resourceHandler, QoS);
151 OCResource::Ptr constructResourceObject(const std::string& host,
152 const std::string& uri,
154 const std::vector<std::string>& resourceTypes,
155 const std::vector<std::string>& interfaces)
157 //TODO-CA Revisit this API
159 return OCPlatform_impl::Instance().constructResourceObject(host, uri, OC_WIFI,
160 isObservable, resourceTypes, interfaces);
162 return OCPlatform_impl::Instance().constructResourceObject(host, uri, isObservable,
163 resourceTypes, interfaces);
167 OCStackResult getDeviceInfo(const std::string& host,
168 const std::string& deviceURI,
169 FindDeviceCallback deviceInfoHandler)
172 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, OC_WIFI,
175 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler);
179 OCStackResult getDeviceInfo(const std::string& host,
180 const std::string& deviceURI,
181 FindDeviceCallback deviceInfoHandler,
182 QualityOfService QoS)
185 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, OC_WIFI,
186 deviceInfoHandler, QoS);
188 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, deviceInfoHandler, QoS);
193 OCStackResult registerResource(OCResourceHandle& resourceHandle,
194 std::string& resourceURI,
195 const std::string& resourceTypeName,
196 const std::string& resourceInterface,
197 EntityHandler entityHandler,
198 uint8_t resourceProperty)
200 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
201 resourceTypeName, resourceInterface,
202 entityHandler, resourceProperty);
205 OCStackResult registerResource(OCResourceHandle& resourceHandle,
206 const std::shared_ptr< OCResource > resource)
208 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
211 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
213 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
216 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
218 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
221 OCStackResult unbindResource(OCResourceHandle collectionHandle,
222 OCResourceHandle resourceHandle)
224 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
227 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
228 const std::vector<OCResourceHandle>& resourceHandles
231 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
234 OCStackResult bindResource(const OCResourceHandle collectionHandle,
235 const OCResourceHandle resourceHandle)
237 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
240 OCStackResult bindResources(const OCResourceHandle collectionHandle,
241 const std::vector<OCResourceHandle>& resourceHandles
244 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
247 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
248 const std::string& resourceTypeName)
250 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
253 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
254 const std::string& resourceInterfaceName)
256 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
257 resourceInterfaceName);
260 OCStackResult startPresence(const unsigned int announceDurationSeconds)
262 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
265 OCStackResult stopPresence()
267 return OCPlatform_impl::Instance().stopPresence();
271 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
272 const std::string& host,
273 OCConnectivityType connectivityType,
274 SubscribeCallback presenceHandler)
276 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
277 connectivityType, presenceHandler);
280 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
281 const std::string& host,
282 const std::string& resourceType,
283 OCConnectivityType connectivityType,
284 SubscribeCallback presenceHandler)
286 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
287 resourceType, connectivityType, presenceHandler);
290 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
291 const std::string& host,
292 SubscribeCallback presenceHandler)
294 //TODO-CA Revisit this API
296 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
297 OC_WIFI, presenceHandler);
299 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
304 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
305 const std::string& host,
306 const std::string& resourceType,
307 SubscribeCallback presenceHandler)
309 //TODO-CA Revisit this API
311 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
312 resourceType, OC_WIFI,
315 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
316 resourceType, presenceHandler);
320 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
322 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
325 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
327 return OCPlatform_impl::Instance().sendResponse(pResponse);
329 } // namespace OCPlatform