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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This file contains the declaration of classes and its members related to
28 #ifndef OC_PLATFORM_H_
29 #define OC_PLATFORM_H_
31 #include <OCPlatform_impl.h>
35 * This namespace contains the main entrance/functionality of the product.
36 * It may be used with OC::OCPlatform::functionName. To set a custom configuration,
37 * the implementer must make a call to OCPlatform::Configure before the first usage
38 * of a function in this namespace.
43 * API for overwriting the default configuration of the OCPlatform object.
44 * @note Any calls made to this AFTER the first call to OCPlatform::Instance
47 void Configure(const PlatformConfig& config);
49 // typedef for handle to cancel presence info with
50 typedef OCDoHandle OCPresenceHandle;
53 * API for notifying base that resource's attributes have changed.
55 * @param resourceHandle resource handle of the resource
57 * @return Returns ::OC_STACK_OK if success.
58 * @note This API is for server side only.
59 * @note OCResourceHandle is defined in ocstack.h
60 * @note OCStackResult is defined in ocstack.h.
61 * @see notifyAllObservers(OCResourceHandle, QualityOfService)
63 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle);
68 * @param resourceHandle resource handle of the resource
69 * @param QoS the quality of communication
70 * @see notifyAllObservers(OCResourceHandle)
72 OCStackResult notifyAllObservers(OCResourceHandle resourceHandle, QualityOfService QoS);
75 * API for notifying only specific clients that resource's attributes have changed.
77 * @param resourceHandle resource handle of the resource
78 * @param observationIds std vector of observationIds. These set of ids are ones which
79 * which will be notified upon resource change.
80 * @param responsePtr OCResourceResponse pointer used by app to fill the response for this
83 * @return Returns ::OC_STACK_OK if success.
84 * @note This API is for server side only.
85 * @note OCResourceHandle is defined in ocstack.h.
86 * @note OCStackResult is defined in ocstack.h.
87 * @see notifyListOfObservers(OCResourceHandle, ObservationIds&, const std::shared_ptr<OCResourceResponse>, QualityOfService)
89 OCStackResult notifyListOfObservers(
90 OCResourceHandle resourceHandle,
91 ObservationIds& observationIds,
92 const std::shared_ptr<OCResourceResponse> responsePtr);
96 * @param resourceHandle resource handle of the resource
97 * @param observationIds std vector of observationIds. These set of ids are ones which
98 * which will be notified upon resource change.
99 * @param responsePtr OCResourceResponse pointer used by app to fill the response for this
101 * @param QoS the quality of communication
102 * @see notifyListOfObservers(OCResourceHandle, ObservationIds&, const std::shared_ptr<OCResourceResponse>)
104 OCStackResult notifyListOfObservers(
105 OCResourceHandle resourceHandle,
106 ObservationIds& observationIds,
107 const std::shared_ptr<OCResourceResponse> responsePtr,
108 QualityOfService QoS);
111 * API for Service and Resource Discovery.
112 * @note This API applies to client side only.
114 * @param host Host IP Address of a service to direct resource discovery query. If null or
115 * empty, performs multicast resource discovery query
116 * @param resourceURI name of the resource. If null or empty, performs search for all
118 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
119 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
120 * @param resourceHandler Handles callbacks, success states and failure states.
122 * Four modes of discovery defined as follows:
123 * (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
125 * (NULL/Empty, Not Empty) - Performs query for a filtered/scoped/particular
126 * resource(s) from ALL services.
127 * (Not Empty, NULL/Empty) - Performs ALL resource discovery on a particular service.
128 * (Not Empty, Not Empty) - Performs query for a filtered/scoped/particular
130 * from a particular service.
132 * @return Returns ::OC_STACK_OK if success.
133 * @note First parameter 'host' currently represents an IP address. This will change in
134 * future and will refer to endpoint interface so that we can refer to other transports such
136 * @note OCStackResult is defined in ocstack.h.
137 * @see findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback, QualityOfService)
139 OCStackResult findResource(const std::string& host, const std::string& resourceURI,
140 OCConnectivityType connectivityType, FindCallback resourceHandler);
144 * @param host Host IP Address of a service to direct resource discovery query. If null or
145 * empty, performs multicast resource discovery query
146 * @param resourceURI name of the resource. If null or empty, performs search for all
148 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
149 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
150 * @param resourceHandler Handles callbacks, success states and failure states.
152 * Four modes of discovery defined as follows:
153 * (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
155 * (NULL/Empty, Not Empty) - Performs query for a filtered/scoped/particular
156 * resource(s) from ALL services.
157 * (Not Empty, NULL/Empty) - Performs ALL resource discovery on a particular service.
158 * (Not Empty, Not Empty) - Performs query for a filtered/scoped/particular
160 * from a particular service.
161 * @param QoS QualityOfService the quality of communication
162 * @see findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback)
164 OCStackResult findResource(const std::string& host, const std::string& resourceURI,
165 OCConnectivityType connectivityType, FindCallback resourceHandler,
166 QualityOfService QoS);
168 OCStackResult findResource(const std::string& host, const std::string& resourceURI,
169 OCConnectivityType connectivityType, FindCallback resourceHandler,
170 FindErrorCallback errorHandler);
172 OCStackResult findResource(const std::string& host, const std::string& resourceURI,
173 OCConnectivityType connectivityType, FindCallback resourceHandler,
174 FindErrorCallback errorHandler, QualityOfService QoS);
176 OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
177 OCConnectivityType connectivityType, FindResListCallback resourceHandler,
178 QualityOfService QoS = QualityOfService::LowQos);
180 OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::string& value);
181 OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag, const std::vector<std::string>& value);
182 OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::string& value);
183 OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag, std::vector<std::string>& value);
185 * API for Device Discovery
188 * @param host Host IP Address. If null or empty, Multicast is performed.
189 * @param deviceURI Uri containing address to the virtual device in C Stack
191 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
192 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
193 * @param deviceInfoHandler device discovery callback
195 * @return Returns ::OC_STACK_OK if success.
196 * @note OCStackResult is defined in ocstack.h.
197 * @see getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback, QualityOfService)
199 OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
200 OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler);
204 * @param host Host IP Address. If null or empty, Multicast is performed.
205 * @param deviceURI Uri containing address to the virtual device in C Stack
207 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
208 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
209 * @param deviceInfoHandler device discovery callback
210 * @param QoS the quality of communication
211 * @see getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback)
213 OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
214 OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler,
215 QualityOfService QoS);
218 * API for Platform Discovery
221 * @param host Host IP Address. If null or empty, Multicast is performed.
222 * @param platformURI Uri containing address to the virtual platform in C Stack
224 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
225 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
226 * @param platformInfoHandler platform discovery callback
228 * @return Returns ::OC_STACK_OK if success.
230 * @note OCStackResult is defined in ocstack.h.
231 * @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback, QualityOfService)
233 OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
234 OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler);
238 * @param host Host IP Address. If null or empty, Multicast is performed.
239 * @param platformURI Uri containing address to the virtual platform in C Stack
241 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
242 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
243 * @param platformInfoHandler platform discovery callback
244 * @param QoS the quality of communication
245 * @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback)
247 OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
248 OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler,
249 QualityOfService QoS);
252 * This API registers a resource with the server
253 * @note This API applies to server side only.
255 * @param resourceHandle Upon successful registration, resourceHandle will be filled
256 * @param resourceURI The URI of the resource. Example: "a/light". See NOTE below
257 * @param resourceTypeName The resource type. Example: "light"
258 * @param resourceInterface The resource interface (whether it is collection etc).
259 * @param entityHandler entity handler callback.
260 * @param resourceProperty indicates the property of the resource. Defined in ocstack.h.
261 * setting resourceProperty as OC_DISCOVERABLE will allow Discovery of this resource
262 * setting resourceProperty as OC_OBSERVABLE will allow observation
263 * settings resourceProperty as OC_DISCOVERABLE | OC_OBSERVABLE will allow both discovery and
266 * @return Returns ::OC_STACK_OK if success.
267 * @note "a/light" is a relative URI.
268 * Above relative URI will be prepended (by core) with a host IP + namespace "oic"
269 * Therefore, fully qualified URI format would be //HostIP-Address/namespace/relativeURI"
270 * Example, a relative URI: 'a/light' will result in a fully qualified URI:
271 * //192.168.1.1/oic/a/light"
272 * First parameter can take a relative URI and core will take care of preparing the fully
274 * first parameter can take fully qualified URI and core will take that as is for further
276 * @note OCStackResult is defined in ocstack.h.
277 * @note entity handler callback :
278 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
279 * OC_EH_SLOW and etc in entity handler callback,
280 * ocstack will be not send response automatically to client
281 * except for error return value like OC_EH_ERROR
282 * If you want to send response to client with specific result,
283 * OCDoResponse API should be called with the result value.
285 OCStackResult registerResource(OCResourceHandle& resourceHandle,
286 std::string& resourceURI,
287 const std::string& resourceTypeName,
288 const std::string& resourceInterface,
289 EntityHandler entityHandler,
290 uint8_t resourceProperty);
293 * This API registers a resource with the server
294 * @note This API applies to server & client side.
296 * @param resourceHandle Upon successful registration, resourceHandle will be filled
297 * @param resource The instance of OCResource that all data filled.
299 * @return Returns ::OC_STACK_OK if success.
300 * @note OCStackResult is defined in ocstack.h.
302 OCStackResult registerResource(OCResourceHandle& resourceHandle,
303 const std::shared_ptr< OCResource > resource);
306 * Register Device Info
308 * @param deviceInfo structure containing all the device specific information
309 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
311 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo);
314 * Register Platform Info
316 * @param platformInfo structure containing all the platform specific information
317 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
319 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo);
322 * Set default device entity handler
324 * @param entityHandler entity handler to handle requests for
325 * any undefined resources or default actions.
326 * if NULL is passed it removes the device default entity handler.
327 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
328 * @note entity handler callback :
329 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
330 * OC_EH_SLOW and etc in entity handler callback,
331 * ocstack will be not send response automatically to client
332 * except for error return value like OC_EH_ERROR
333 * If you want to send response to client with specific result,
334 * sendResponse API should be called with the result value.
336 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler);
339 * This API unregisters a resource with the server
340 * @note This API applies to server side only.
342 * @param resourceHandle This is the resource handle which we need to unregister from the
345 * @return Returns ::OC_STACK_OK if success.
346 * @note OCStackResult is defined in ocstack.h.
348 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle);
351 * Add a resource to a collection resource.
353 * @param collectionHandle handle to the collection resource
354 * @param resourceHandle handle to resource to be added to the collection resource
356 * @return Returns ::OC_STACK_OK if success.
357 * @note OCStackResult is defined in ocstack.h.
358 * @note bindResource must be used only after the both collection resource and
359 * resource to add under a collections are created and respective handles obtained
362 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
363 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
364 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
365 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
366 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
368 * At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".
370 OCStackResult bindResource(const OCResourceHandle collectionHandle,
371 const OCResourceHandle resourceHandle);
374 * Add multiple resources to a collection resource.
376 * @param collectionHandle handle to the collection resource
377 * @param addedResourceHandleList reference to list of resource handles to be added to the
378 * collection resource
380 * @return Returns ::OC_STACK_OK if success.
381 * @note OCStackResult is defined in ocstack.h.
382 * @note bindResources must be used only after the both collection resource and
383 * list of resources to add under a collection are created and respective handles
387 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
388 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
389 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
390 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
391 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
392 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
393 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
394 * rList.push_back(roomResourceHandle);
395 * -# bindResource(homeResourceHandle, rList);
397 * At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and
400 OCStackResult bindResources(const OCResourceHandle collectionHandle,
401 const std::vector<OCResourceHandle>& addedResourceHandleList);
404 * Unbind a resource from a collection resource.
406 * @param collectionHandle handle to the collection resource
407 * @param resourceHandle resource handle to be unbound from the collection resource
409 * @return Returns ::OC_STACK_OK if success.
410 * @note OCStackResult is defined in ocstack.h.
411 * @note unbindResource must be used only after the both collection resource and
412 * resource to unbind from a collection are created and respective handles obtained
415 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
416 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
417 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
418 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
419 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
420 * -# unbindResource(homeResourceHandle, kitchenResourceHandle);
422 * At the end of Step 4, resource "a/home" will no longer reference "a/kitchen".
424 OCStackResult unbindResource(const OCResourceHandle collectionHandle,
425 const OCResourceHandle resourceHandle);
428 * Unbind resources from a collection resource.
430 * @param collectionHandle handle to the collection resource
431 * @param resourceHandleList List of resource handles to be unbound from the collection
434 * @return Returns ::OC_STACK_OK if success.
435 * @note OCStackResult is defined in ocstack.h.
436 * @note unbindResources must be used only after the both collection resource and
437 * list of resources resource to unbind from a collection are created and respective handles
441 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
442 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
443 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
444 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
445 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
446 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
447 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
448 * rList.push_back(roomResourceHandle);
449 * -# bindResource(homeResourceHandle, rList);
450 * -# unbindResources(homeResourceHandle, rList);
452 * At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and
455 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
456 const std::vector<OCResourceHandle>& resourceHandleList);
459 * Binds a type to a particular resource
460 * @param resourceHandle handle to the resource
461 * @param resourceTypeName new typename to bind to the resource
463 * @return Returns ::OC_STACK_OK if success.
465 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
466 const std::string& resourceTypeName);
469 * Binds an interface to a particular resource
470 * @param resourceHandle handle to the resource
471 * @param resourceInterfaceName new interface to bind to the resource
473 * @return Returns ::OC_STACK_OK if success.
475 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
476 const std::string& resourceInterfaceName);
480 * Start Presence announcements.
482 * @param ttl time to live
484 * If ttl is '0', then the default stack value will be used (60 Seconds).
485 * If ttl is greater than OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be set to
486 * OC_MAX_PRESENCE_TTL_SECONDS.
488 * @return Returns ::OC_STACK_OK if success.
490 * Server can call this function when it comes online for the
491 * first time, or when it comes back online from offline mode,
492 * or when it re enters network.
495 OCStackResult startPresence(const unsigned int ttl);
498 * Stop Presence announcements.
500 * @return Returns ::OC_STACK_OK if success.
502 * Server can call this function when it is terminating,
503 * going offline, or when going away from network.
506 OCStackResult stopPresence();
509 * subscribes to a server's presence change events. By making this subscription,
510 * every time a server adds/removes/alters a resource, starts or is intentionally
511 * stopped (potentially more to be added later).
513 * @param presenceHandle a handle object that can be used to identify this subscription
514 * request. It can be used to unsubscribe from these events in the future.
515 * It will be set upon successful return of this method.
516 * @param host The IP address/addressable name of the server to subscribe to.
517 * This should be in the format coap://address:port
518 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
519 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
520 * @param presenceHandler callback function that will receive notifications/subscription
523 * @return Returns ::OC_STACK_OK if success.
524 * @copydoc subscribePresence(OCPresenceHandle&, const std::string&, resourceType, OCConnectivityType, SubscribeCallback)
526 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
527 OCConnectivityType connectivityType, SubscribeCallback presenceHandler);
531 * @param presenceHandle a handle object that can be used to identify this subscription
532 * request. It can be used to unsubscribe from these events in the future.
533 * It will be set upon successful return of this method.
534 * @param host The IP address/addressable name of the server to subscribe to.
535 * This should be in the format coap://address:port
536 * @param resourceType a resource type specified as a filter for subscription callbacks.
537 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
538 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
539 * @param presenceHandler callback function that will receive notifications/subscription
541 * @see subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
543 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
544 const std::string& resourceType, OCConnectivityType connectivityType,
545 SubscribeCallback presenceHandler);
548 * unsubscribes from a previously subscribed server's presence events. Note that
549 * you may for a short time still receive events from the server since it may take time
550 * for the unsubscribe to take effect.
552 * @param presenceHandle the handle object provided by the subscribePresence call that
553 * identifies this subscription.
555 * @return Returns ::OC_STACK_OK if success.
557 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle);
561 * Subscribes to a server's device presence change events.
563 * @param presenceHandle a handle object that can be used to identify this subscription
564 * request. It can be used to unsubscribe from these events in the future.
565 * It will be set upon successful return of this method.
566 * @param host The IP address/addressable name of the server to subscribe to.
567 * This should be in the format coap://address:port
568 * @param di Vector which can have the devices id.
569 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
570 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
571 * @param observeHandler handles callback
572 * The callback function will be invoked with a map of attribute name and values.
573 * The callback function will also have the result from this observe operation
574 * This will have error codes
576 * @return Returns ::OC_STACK_OK if success.
578 OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
579 const std::string& host,
580 const std::vector<std::string>& di,
581 OCConnectivityType connectivityType,
582 ObserveCallback callback);
586 * Creates a resource proxy object so that get/put/observe functionality
587 * can be used without discovering the object in advance. Note that the
588 * consumer of this method needs to provide all of the details required to
589 * correctly contact and observe the object. If the consumer lacks any of
590 * this information, they should discover the resource object normally.
591 * Additionally, you can only create this object if OCPlatform was initialized
592 * to be a Client or Client/Server. Otherwise, this will return an empty
595 * @param host a string containing a resolvable host address of the server
596 * holding the resource. Currently this should be in the format
597 * coap://address:port, though in the future, we expect this to
598 * change to //address:port
600 * @param uri the rest of the resource's URI that will permit messages to be
601 * properly routed. Example: /a/light
603 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
604 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
605 * if you want to use a specific Flag like IPv4,
606 * you should apply OR operation for the flag in here.
607 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
610 * @param isObservable a boolean containing whether the resource supports observation
612 * @param resourceTypes a collection of resource types implemented by the resource
614 * @param interfaces a collection of interfaces that the resource supports/implements
615 * @return OCResource::Ptr a shared pointer to the new resource object
617 OCResource::Ptr constructResourceObject(const std::string& host,
618 const std::string& uri,
619 OCConnectivityType connectivityType, bool isObservable,
620 const std::vector<std::string>& resourceTypes,
621 const std::vector<std::string>& interfaces);
624 * Allows application entity handler to send response to an incoming request.
626 * @param pResponse OCResourceResponse pointer that will permit to set values related
627 * to resource response.
629 * @return Returns ::OC_STACK_OK if success.
631 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
634 * Find all the Direct Pairing capable devices.
636 * @param waittime timeoutbefore the callback is called
637 * @param callback function to callback with discovered devices after timeout
639 * @return Returns ::OC_STACK_OK if success
641 OCStackResult findDirectPairingDevices(unsigned short waittime,
642 GetDirectPairedCallback callback);
645 * Get all the Direct paired devices.
647 * @param callback function to callback with the list of paired devices
649 * @return Returns ::OC_STACK_OK if success
651 OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
654 * Perform the Direct Pairing with the selected peer device
656 * @param peer device to direct pair with
657 * @param pmSel Selected pairing method
658 * @param pinNumber pin to validate peer & perform the direct pairing
659 * @param resultCallback callback function that will get the result of the operation
661 * @return Returns ::OC_STACK_OK if success
663 OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
664 const std::string& pinNumber,
665 DirectPairingCallback resultCallback);
668 * Create an account manager object that can be used for doing request to account server.
669 * You can only create this object if OCPlatform was initialized to be a Client or
670 * Client/Server. Otherwise, this will return an empty shared ptr.
672 * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
673 * methods of this object to work since device id is not generated on Client mode.
675 * @param host Host IP Address of a account server.
676 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
677 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
678 * if you want to use a specific Flag like IPv4,
679 * you should apply OR operation for the flag in here.
680 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
683 * @return OCAccountManager::Ptr a shared pointer to the new account manager object
685 OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
686 OCConnectivityType connectivityType);
690 * gets the deviceId of the client
692 * @param deviceId pointer.
693 * @return Returns ::OC_STACK_OK if success.
695 OCStackResult getDeviceId(OCUUIdentity *deviceId);
698 * sets the deviceId of the client
700 * @param deviceId pointer.
701 * @return Returns ::OC_STACK_OK if success.
703 OCStackResult setDeviceId(const OCUUIdentity *deviceId);
707 #endif // OC_PLATFORM_H_