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);
73 OCResource::Ptr constructResourceObject(const std::string& host,
74 const std::string& uri,
75 OCConnectivityType connectivityType,
77 const std::vector<std::string>& resourceTypes,
78 const std::vector<std::string>& interfaces)
80 return OCPlatform_impl::Instance().constructResourceObject(host,
81 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,
101 return OCPlatform_impl::Instance().findResource(host, resourceName,
102 connectivityType, resourceHandler, QoS);
105 OCStackResult findResource(const std::string& host,
106 const std::string& resourceName,
107 OCConnectivityType connectivityType,
108 FindCallback resourceHandler,
109 FindErrorCallback errorHandler)
111 return OCPlatform_impl::Instance().findResource(host, resourceName,
112 connectivityType, resourceHandler, errorHandler);
115 OCStackResult findResource(const std::string& host,
116 const std::string& resourceName,
117 OCConnectivityType connectivityType,
118 FindCallback resourceHandler,
119 FindErrorCallback errorHandler,
120 QualityOfService QoS)
122 return OCPlatform_impl::Instance().findResource(host, resourceName,
123 connectivityType, resourceHandler, errorHandler, QoS);
126 OCStackResult getDeviceInfo(const std::string& host,
127 const std::string& deviceURI,
128 OCConnectivityType connectivityType,
129 FindDeviceCallback deviceInfoHandler)
131 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
132 connectivityType, deviceInfoHandler);
135 OCStackResult getDeviceInfo(const std::string& host,
136 const std::string& deviceURI,
137 OCConnectivityType connectivityType,
138 FindDeviceCallback deviceInfoHandler,
139 QualityOfService QoS)
141 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
142 deviceInfoHandler, QoS);
145 OCStackResult getPlatformInfo(const std::string& host,
146 const std::string& platformURI,
147 OCConnectivityType connectivityType,
148 FindPlatformCallback platformInfoHandler)
150 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
151 connectivityType, platformInfoHandler);
154 OCStackResult getPlatformInfo(const std::string& host,
155 const std::string& platformURI,
156 OCConnectivityType connectivityType,
157 FindPlatformCallback platformInfoHandler,
158 QualityOfService QoS)
160 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
161 platformInfoHandler, QoS);
164 OCStackResult registerResource(OCResourceHandle& resourceHandle,
165 std::string& resourceURI,
166 const std::string& resourceTypeName,
167 const std::string& resourceInterface,
168 EntityHandler entityHandler,
169 uint8_t resourceProperty)
171 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
172 resourceTypeName, resourceInterface,
173 entityHandler, resourceProperty);
176 OCStackResult registerResource(OCResourceHandle& resourceHandle,
177 const std::shared_ptr< OCResource > resource)
179 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
182 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
184 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
187 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
189 return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
192 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
194 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
197 OCStackResult unbindResource(OCResourceHandle collectionHandle,
198 OCResourceHandle resourceHandle)
200 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
203 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
204 const std::vector<OCResourceHandle>& resourceHandles)
206 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
209 OCStackResult bindResource(const OCResourceHandle collectionHandle,
210 const OCResourceHandle resourceHandle)
212 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
215 OCStackResult bindResources(const OCResourceHandle collectionHandle,
216 const std::vector<OCResourceHandle>& resourceHandles
219 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
222 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
223 const std::string& resourceTypeName)
225 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
228 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
229 const std::string& resourceInterfaceName)
231 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
232 resourceInterfaceName);
235 OCStackResult startPresence(const unsigned int announceDurationSeconds)
237 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
240 OCStackResult stopPresence()
242 return OCPlatform_impl::Instance().stopPresence();
245 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
246 const std::string& host,
247 OCConnectivityType connectivityType,
248 SubscribeCallback presenceHandler)
250 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
251 connectivityType, presenceHandler);
254 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
255 const std::string& host,
256 const std::string& resourceType,
257 OCConnectivityType connectivityType,
258 SubscribeCallback presenceHandler)
260 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
261 resourceType, connectivityType, presenceHandler);
264 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
266 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
270 OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
271 const std::string& host,
272 const std::vector<std::string>& di,
273 OCConnectivityType connectivityType,
274 ObserveCallback callback)
276 return OCPlatform_impl::Instance().subscribeDevicePresence(presenceHandle,
284 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
286 return OCPlatform_impl::Instance().sendResponse(pResponse);
289 OCStackResult findDirectPairingDevices(unsigned short waittime,
290 GetDirectPairedCallback directPairingHandler)
292 return OCPlatform_impl::Instance().findDirectPairingDevices(waittime,
293 directPairingHandler);
296 OCStackResult getDirectPairedDevices(GetDirectPairedCallback directPairingHandler)
298 return OCPlatform_impl::Instance().getDirectPairedDevices(directPairingHandler);
301 OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
302 const std::string& pinNumber,
303 DirectPairingCallback resultCallback)
305 return OCPlatform_impl::Instance().doDirectPairing(peer, pmSel,
306 pinNumber, resultCallback);
309 OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
310 OCConnectivityType connectivityType)
312 return OCPlatform_impl::Instance().constructAccountManagerObject(host,
317 OCStackResult publishResourceToRD(const std::string& host,
318 OCConnectivityType connectivityType,
319 PublishResourceCallback callback)
321 ResourceHandles resourceHandles;
322 return OCPlatform_impl::Instance().publishResourceToRD(host, connectivityType,
327 OCStackResult publishResourceToRD(const std::string& host,
328 OCConnectivityType connectivityType,
329 PublishResourceCallback callback,
330 QualityOfService QoS)
332 ResourceHandles resourceHandles;
333 return OCPlatform_impl::Instance().publishResourceToRD(host, connectivityType,
338 OCStackResult publishResourceToRD(const std::string& host,
339 OCConnectivityType connectivityType,
340 ResourceHandles& resourceHandles,
341 PublishResourceCallback callback)
343 return OCPlatform_impl::Instance().publishResourceToRD(host, connectivityType,
348 OCStackResult publishResourceToRD(const std::string& host,
349 OCConnectivityType connectivityType,
350 ResourceHandles& resourceHandles,
351 PublishResourceCallback callback, QualityOfService QoS)
353 return OCPlatform_impl::Instance().publishResourceToRD(host, connectivityType,
358 OCStackResult deleteResourceFromRD(const std::string& host,
359 OCConnectivityType connectivityType,
360 DeleteResourceCallback callback)
362 ResourceHandles resourceHandles;
363 return OCPlatform_impl::Instance().deleteResourceFromRD(host, connectivityType,
364 resourceHandles, callback);
367 OCStackResult deleteResourceFromRD(const std::string& host,
368 OCConnectivityType connectivityType,
369 DeleteResourceCallback callback,
370 QualityOfService QoS)
372 ResourceHandles resourceHandles;
373 return OCPlatform_impl::Instance().deleteResourceFromRD(host, connectivityType,
374 resourceHandles, callback, QoS);
377 OCStackResult deleteResourceFromRD(const std::string& host,
378 OCConnectivityType connectivityType,
379 ResourceHandles& resourceHandles,
380 DeleteResourceCallback callback)
382 return OCPlatform_impl::Instance().deleteResourceFromRD(host, connectivityType,
383 resourceHandles, callback);
386 OCStackResult deleteResourceFromRD(const std::string& host,
387 OCConnectivityType connectivityType,
388 ResourceHandles& resourceHandles,
389 DeleteResourceCallback callback, QualityOfService QoS)
391 return OCPlatform_impl::Instance().deleteResourceFromRD(host, connectivityType,
392 resourceHandles, callback,
396 } // namespace OCPlatform