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, uri, connectivityType,
82 resourceTypes, interfaces);
85 OCStackResult findResource(const std::string& host,
86 const std::string& resourceName,
87 OCConnectivityType connectivityType,
88 FindCallback resourceHandler)
90 return OCPlatform_impl::Instance().findResource(host, resourceName,
91 connectivityType, resourceHandler);
94 OCStackResult findResource(const std::string& host,
95 const std::string& resourceName,
96 OCConnectivityType connectivityType,
97 FindCallback resourceHandler, QualityOfService QoS)
99 return OCPlatform_impl::Instance().findResource(host, resourceName, connectivityType,
100 resourceHandler, QoS);
103 OCStackResult getDeviceInfo(const std::string& host,
104 const std::string& deviceURI,
105 OCConnectivityType connectivityType,
106 FindDeviceCallback deviceInfoHandler)
108 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI,
109 connectivityType, deviceInfoHandler);
112 OCStackResult getDeviceInfo(const std::string& host,
113 const std::string& deviceURI,
114 OCConnectivityType connectivityType,
115 FindDeviceCallback deviceInfoHandler,
116 QualityOfService QoS)
118 return OCPlatform_impl::Instance().getDeviceInfo(host, deviceURI, connectivityType,
119 deviceInfoHandler, QoS);
122 OCStackResult registerResource(OCResourceHandle& resourceHandle,
123 std::string& resourceURI,
124 const std::string& resourceTypeName,
125 const std::string& resourceInterface,
126 EntityHandler entityHandler,
127 uint8_t resourceProperty)
129 return OCPlatform_impl::Instance().registerResource(resourceHandle, resourceURI,
130 resourceTypeName, resourceInterface,
131 entityHandler, resourceProperty);
134 OCStackResult registerResource(OCResourceHandle& resourceHandle,
135 const std::shared_ptr< OCResource > resource)
137 return OCPlatform_impl::Instance().registerResource(resourceHandle, resource);
140 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
142 return OCPlatform_impl::Instance().registerDeviceInfo(deviceInfo);
145 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle)
147 return OCPlatform_impl::Instance().unregisterResource(resourceHandle);
150 OCStackResult unbindResource(OCResourceHandle collectionHandle,
151 OCResourceHandle resourceHandle)
153 return OCPlatform_impl::Instance().unbindResource(collectionHandle, resourceHandle);
156 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
157 const std::vector<OCResourceHandle>& resourceHandles
160 return OCPlatform_impl::Instance().unbindResources(collectionHandle, resourceHandles);
163 OCStackResult bindResource(const OCResourceHandle collectionHandle,
164 const OCResourceHandle resourceHandle)
166 return OCPlatform_impl::Instance().bindResource(collectionHandle, resourceHandle);
169 OCStackResult bindResources(const OCResourceHandle collectionHandle,
170 const std::vector<OCResourceHandle>& resourceHandles
173 return OCPlatform_impl::Instance().bindResources(collectionHandle, resourceHandles);
176 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
177 const std::string& resourceTypeName)
179 return OCPlatform_impl::Instance().bindTypeToResource(resourceHandle,resourceTypeName);
182 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
183 const std::string& resourceInterfaceName)
185 return OCPlatform_impl::Instance().bindInterfaceToResource(resourceHandle,
186 resourceInterfaceName);
189 OCStackResult startPresence(const unsigned int announceDurationSeconds)
191 return OCPlatform_impl::Instance().startPresence(announceDurationSeconds);
194 OCStackResult stopPresence()
196 return OCPlatform_impl::Instance().stopPresence();
199 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
200 const std::string& host,
201 OCConnectivityType connectivityType,
202 SubscribeCallback presenceHandler)
204 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
205 connectivityType, presenceHandler);
208 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle,
209 const std::string& host,
210 const std::string& resourceType,
211 OCConnectivityType connectivityType,
212 SubscribeCallback presenceHandler)
214 return OCPlatform_impl::Instance().subscribePresence(presenceHandle, host,
215 resourceType, connectivityType, presenceHandler);
218 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
220 return OCPlatform_impl::Instance().unsubscribePresence(presenceHandle);
223 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse)
225 return OCPlatform_impl::Instance().sendResponse(pResponse);
227 } // namespace OCPlatform