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 findResourceList(const std::string& host, const std::string& resourceURI,
127 OCConnectivityType connectivityType, FindResListCallback resourceHandler,
128 QualityOfService QoS)
130 return OCPlatform_impl::Instance().findResourceList(host, resourceURI,
131 connectivityType, resourceHandler, QoS);
134 OCStackResult getDeviceInfo(const std::string& host,
135 const std::string& deviceURI,
136 OCConnectivityType connectivityType,
137 FindDeviceCallback deviceInfoHandler)
139 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
140 connectivityType, deviceInfoHandler);
143 OCStackResult getDeviceInfo(const std::string& host,
144 const std::string& deviceURI,
145 OCConnectivityType connectivityType,
146 FindDeviceCallback deviceInfoHandler,
147 QualityOfService QoS)
149 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
150 deviceInfoHandler, QoS);
153 OCStackResult getPlatformInfo(const std::string& host,
154 const std::string& platformURI,
155 OCConnectivityType connectivityType,
156 FindPlatformCallback platformInfoHandler)
158 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI,
159 connectivityType, platformInfoHandler);
162 OCStackResult getPlatformInfo(const std::string& host,
163 const std::string& platformURI,
164 OCConnectivityType connectivityType,
165 FindPlatformCallback platformInfoHandler,
166 QualityOfService QoS)
168 return OCPlatform_impl::Instance().getPlatformInfo(host, platformURI, connectivityType,
169 platformInfoHandler, QoS);
172 OCStackResult registerResource(OCResourceHandle& resourceHandle,
173 std::string& resourceURI,
174 const std::string& resourceTypeName,
175 const std::string& resourceInterface,
176 EntityHandler entityHandler,
177 uint8_t resourceProperty)
179 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
180 resourceTypeName, resourceInterface,
181 entityHandler, resourceProperty);
184 OCStackResult registerResource(OCResourceHandle& resourceHandle,
185 const std::shared_ptr< OCResource > resource)
187 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
190 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
192 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
195 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
197 return OCPlatform_impl::Instance().registerPlatformInfo(platformInfo);
200 OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::string& value)
202 return OCPlatform_impl::Instance().setPropertyValue(type, tag, value);
205 OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::vector<std::string>& value)
207 return OCPlatform_impl::Instance().setPropertyValue(type, tag, value);
210 OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::string& value)
212 return OCPlatform_impl::Instance().getPropertyValue(type, tag, value);
215 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
217 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
220 OCStackResult unbindResource(OCResourceHandle collectionHandle,
221 OCResourceHandle resourceHandle)
223 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
226 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
227 const std::vector<OCResourceHandle>& resourceHandles)
229 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
232 OCStackResult bindResource(const OCResourceHandle collectionHandle,
233 const OCResourceHandle resourceHandle)
235 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
238 OCStackResult bindResources(const OCResourceHandle collectionHandle,
239 const std::vector<OCResourceHandle>& resourceHandles
242 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
245 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
246 const std::string& resourceTypeName)
248 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
251 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
252 const std::string& resourceInterfaceName)
254 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
255 resourceInterfaceName);
258 OCStackResult startPresence(const unsigned int announceDurationSeconds)
260 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
263 OCStackResult stopPresence()
265 return OCPlatform_impl::Instance().stopPresence();
268 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
269 const std::string& host,
270 OCConnectivityType connectivityType,
271 SubscribeCallback presenceHandler)
273 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
274 connectivityType, presenceHandler);
277 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
278 const std::string& host,
279 const std::string& resourceType,
280 OCConnectivityType connectivityType,
281 SubscribeCallback presenceHandler)
283 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
284 resourceType, connectivityType, presenceHandler);
287 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
289 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
293 OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
294 const std::string& host,
295 const std::vector<std::string>& di,
296 OCConnectivityType connectivityType,
297 ObserveCallback callback)
299 return OCPlatform_impl::Instance().subscribeDevicePresence(presenceHandle,
307 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
309 return OCPlatform_impl::Instance().sendResponse(pResponse);
312 OCStackResult findDirectPairingDevices(unsigned short waittime,
313 GetDirectPairedCallback directPairingHandler)
315 return OCPlatform_impl::Instance().findDirectPairingDevices(waittime,
316 directPairingHandler);
319 OCStackResult getDirectPairedDevices(GetDirectPairedCallback directPairingHandler)
321 return OCPlatform_impl::Instance().getDirectPairedDevices(directPairingHandler);
324 OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
325 const std::string& pinNumber,
326 DirectPairingCallback resultCallback)
328 return OCPlatform_impl::Instance().doDirectPairing(peer, pmSel,
329 pinNumber, resultCallback);
332 OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
333 OCConnectivityType connectivityType)
335 return OCPlatform_impl::Instance().constructAccountManagerObject(host,
340 OCStackResult getDeviceId(OCUUIdentity *deviceId)
342 return OCPlatform_impl::Instance().getDeviceId(deviceId);
345 OCStackResult setDeviceId(const OCUUIdentity *deviceId)
347 return OCPlatform_impl::Instance().setDeviceId(deviceId);
349 } // namespace OCPlatform