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);
177 * API for Device Discovery
180 * @param host Host IP Address. If null or empty, Multicast is performed.
181 * @param deviceURI Uri containing address to the virtual device in C Stack
183 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
184 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
185 * @param deviceInfoHandler device discovery callback
187 * @return Returns ::OC_STACK_OK if success.
188 * @note OCStackResult is defined in ocstack.h.
189 * @see getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback, QualityOfService)
191 OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
192 OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler);
196 * @param host Host IP Address. If null or empty, Multicast is performed.
197 * @param deviceURI Uri containing address to the virtual device in C Stack
199 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
200 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
201 * @param deviceInfoHandler device discovery callback
202 * @param QoS the quality of communication
203 * @see getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback)
205 OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
206 OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler,
207 QualityOfService QoS);
210 * API for Platform Discovery
213 * @param host Host IP Address. If null or empty, Multicast is performed.
214 * @param platformURI Uri containing address to the virtual platform in C Stack
216 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
217 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
218 * @param platformInfoHandler platform discovery callback
220 * @return Returns ::OC_STACK_OK if success.
222 * @note OCStackResult is defined in ocstack.h.
223 * @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback, QualityOfService)
225 OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
226 OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler);
230 * @param host Host IP Address. If null or empty, Multicast is performed.
231 * @param platformURI Uri containing address to the virtual platform in C Stack
233 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
234 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
235 * @param platformInfoHandler platform discovery callback
236 * @param QoS the quality of communication
237 * @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback)
239 OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
240 OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler,
241 QualityOfService QoS);
244 * This API registers a resource with the server
245 * @note This API applies to server side only.
247 * @param resourceHandle Upon successful registration, resourceHandle will be filled
248 * @param resourceURI The URI of the resource. Example: "a/light". See NOTE below
249 * @param resourceTypeName The resource type. Example: "light"
250 * @param resourceInterface The resource interface (whether it is collection etc).
251 * @param entityHandler entity handler callback.
252 * @param resourceProperty indicates the property of the resource. Defined in ocstack.h.
253 * setting resourceProperty as OC_DISCOVERABLE will allow Discovery of this resource
254 * setting resourceProperty as OC_OBSERVABLE will allow observation
255 * settings resourceProperty as OC_DISCOVERABLE | OC_OBSERVABLE will allow both discovery and
258 * @return Returns ::OC_STACK_OK if success.
259 * @note "a/light" is a relative URI.
260 * Above relative URI will be prepended (by core) with a host IP + namespace "oic"
261 * Therefore, fully qualified URI format would be //HostIP-Address/namespace/relativeURI"
262 * Example, a relative URI: 'a/light' will result in a fully qualified URI:
263 * //192.168.1.1/oic/a/light"
264 * First parameter can take a relative URI and core will take care of preparing the fully
266 * first parameter can take fully qualified URI and core will take that as is for further
268 * @note OCStackResult is defined in ocstack.h.
270 OCStackResult registerResource(OCResourceHandle& resourceHandle,
271 std::string& resourceURI,
272 const std::string& resourceTypeName,
273 const std::string& resourceInterface,
274 EntityHandler entityHandler,
275 uint8_t resourceProperty);
278 * This API registers a resource with the server
279 * @note This API applies to server & client side.
281 * @param resourceHandle Upon successful registration, resourceHandle will be filled
282 * @param resource The instance of OCResource that all data filled.
284 * @return Returns ::OC_STACK_OK if success.
285 * @note OCStackResult is defined in ocstack.h.
287 OCStackResult registerResource(OCResourceHandle& resourceHandle,
288 const std::shared_ptr< OCResource > resource);
291 * Register Device Info
293 * @param deviceInfo structure containing all the device specific information
294 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
296 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo);
299 * Register Platform Info
301 * @param platformInfo structure containing all the platform specific information
302 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
304 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo);
307 * Set default device entity handler
309 * @param entityHandler entity handler to handle requests for
310 * any undefined resources or default actions.
311 * if NULL is passed it removes the device default entity handler.
312 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
314 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler);
317 * This API unregisters a resource with the server
318 * @note This API applies to server side only.
320 * @param resourceHandle This is the resource handle which we need to unregister from the
323 * @return Returns ::OC_STACK_OK if success.
324 * @note OCStackResult is defined in ocstack.h.
326 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle);
329 * Add a resource to a collection resource.
331 * @param collectionHandle handle to the collection resource
332 * @param resourceHandle handle to resource to be added to the collection resource
334 * @return Returns ::OC_STACK_OK if success.
335 * @note OCStackResult is defined in ocstack.h.
336 * @note bindResource must be used only after the both collection resource and
337 * resource to add under a collections are created and respective handles obtained
340 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
341 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
342 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
343 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
344 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
346 * At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".
348 OCStackResult bindResource(const OCResourceHandle collectionHandle,
349 const OCResourceHandle resourceHandle);
352 * Add multiple resources to a collection resource.
354 * @param collectionHandle handle to the collection resource
355 * @param addedResourceHandleList reference to list of resource handles to be added to the
356 * collection resource
358 * @return Returns ::OC_STACK_OK if success.
359 * @note OCStackResult is defined in ocstack.h.
360 * @note bindResources must be used only after the both collection resource and
361 * list of resources to add under a collection are created and respective handles
365 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
366 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
367 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
368 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
369 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
370 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
371 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
372 * rList.push_back(roomResourceHandle);
373 * -# bindResource(homeResourceHandle, rList);
375 * At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and
378 OCStackResult bindResources(const OCResourceHandle collectionHandle,
379 const std::vector<OCResourceHandle>& addedResourceHandleList);
382 * Unbind a resource from a collection resource.
384 * @param collectionHandle handle to the collection resource
385 * @param resourceHandle resource handle to be unbound from the collection resource
387 * @return Returns ::OC_STACK_OK if success.
388 * @note OCStackResult is defined in ocstack.h.
389 * @note unbindResource must be used only after the both collection resource and
390 * resource to unbind from a collection are created and respective handles obtained
393 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
394 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
395 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
396 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
397 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
398 * -# unbindResource(homeResourceHandle, kitchenResourceHandle);
400 * At the end of Step 4, resource "a/home" will no longer reference "a/kitchen".
402 OCStackResult unbindResource(const OCResourceHandle collectionHandle,
403 const OCResourceHandle resourceHandle);
406 * Unbind resources from a collection resource.
408 * @param collectionHandle handle to the collection resource
409 * @param resourceHandleList List of resource handles to be unbound from the collection
412 * @return Returns ::OC_STACK_OK if success.
413 * @note OCStackResult is defined in ocstack.h.
414 * @note unbindResources must be used only after the both collection resource and
415 * list of resources resource to unbind from a collection are created and respective handles
419 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
420 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
421 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
422 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
423 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
424 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
425 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
426 * rList.push_back(roomResourceHandle);
427 * -# bindResource(homeResourceHandle, rList);
428 * -# unbindResources(homeResourceHandle, rList);
430 * At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and
433 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
434 const std::vector<OCResourceHandle>& resourceHandleList);
437 * Binds a type to a particular resource
438 * @param resourceHandle handle to the resource
439 * @param resourceTypeName new typename to bind to the resource
441 * @return Returns ::OC_STACK_OK if success.
443 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
444 const std::string& resourceTypeName);
447 * Binds an interface to a particular resource
448 * @param resourceHandle handle to the resource
449 * @param resourceInterfaceName new interface to bind to the resource
451 * @return Returns ::OC_STACK_OK if success.
453 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
454 const std::string& resourceInterfaceName);
458 * Start Presence announcements.
460 * @param ttl time to live
462 * If ttl is '0', then the default stack value will be used (60 Seconds).
463 * If ttl is greater than OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be set to
464 * OC_MAX_PRESENCE_TTL_SECONDS.
466 * @return Returns ::OC_STACK_OK if success.
468 * Server can call this function when it comes online for the
469 * first time, or when it comes back online from offline mode,
470 * or when it re enters network.
473 OCStackResult startPresence(const unsigned int ttl);
476 * Stop Presence announcements.
478 * @return Returns ::OC_STACK_OK if success.
480 * Server can call this function when it is terminating,
481 * going offline, or when going away from network.
484 OCStackResult stopPresence();
487 * subscribes to a server's presence change events. By making this subscription,
488 * every time a server adds/removes/alters a resource, starts or is intentionally
489 * stopped (potentially more to be added later).
491 * @param presenceHandle a handle object that can be used to identify this subscription
492 * request. It can be used to unsubscribe from these events in the future.
493 * It will be set upon successful return of this method.
494 * @param host The IP address/addressable name of the server to subscribe to.
495 * This should be in the format coap://address:port
496 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
497 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
498 * @param presenceHandler callback function that will receive notifications/subscription
501 * @return Returns ::OC_STACK_OK if success.
502 * @copydoc subscribePresence(OCPresenceHandle&, const std::string&, resourceType, OCConnectivityType, SubscribeCallback)
504 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
505 OCConnectivityType connectivityType, SubscribeCallback presenceHandler);
509 * @param presenceHandle a handle object that can be used to identify this subscription
510 * request. It can be used to unsubscribe from these events in the future.
511 * It will be set upon successful return of this method.
512 * @param host The IP address/addressable name of the server to subscribe to.
513 * This should be in the format coap://address:port
514 * @param resourceType a resource type specified as a filter for subscription callbacks.
515 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
516 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
517 * @param presenceHandler callback function that will receive notifications/subscription
519 * @see subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
521 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
522 const std::string& resourceType, OCConnectivityType connectivityType,
523 SubscribeCallback presenceHandler);
526 * unsubscribes from a previously subscribed server's presence events. Note that
527 * you may for a short time still receive events from the server since it may take time
528 * for the unsubscribe to take effect.
530 * @param presenceHandle the handle object provided by the subscribePresence call that
531 * identifies this subscription.
533 * @return Returns ::OC_STACK_OK if success.
535 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle);
539 * Subscribes to a server's device presence change events.
541 * @param presenceHandle a handle object that can be used to identify this subscription
542 * request. It can be used to unsubscribe from these events in the future.
543 * It will be set upon successful return of this method.
544 * @param host The IP address/addressable name of the server to subscribe to.
545 * This should be in the format coap://address:port
546 * @param di Vector which can have the devices id.
547 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
548 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
549 * @param observeHandler handles callback
550 * The callback function will be invoked with a map of attribute name and values.
551 * The callback function will also have the result from this observe operation
552 * This will have error codes
554 * @return Returns ::OC_STACK_OK if success.
556 OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
557 const std::string& host,
558 const std::vector<std::string>& di,
559 OCConnectivityType connectivityType,
560 ObserveCallback callback);
564 * Creates a resource proxy object so that get/put/observe functionality
565 * can be used without discovering the object in advance. Note that the
566 * consumer of this method needs to provide all of the details required to
567 * correctly contact and observe the object. If the consumer lacks any of
568 * this information, they should discover the resource object normally.
569 * Additionally, you can only create this object if OCPlatform was initialized
570 * to be a Client or Client/Server. Otherwise, this will return an empty
573 * @param host a string containing a resolvable host address of the server
574 * holding the resource. Currently this should be in the format
575 * coap://address:port, though in the future, we expect this to
576 * change to //address:port
578 * @param uri the rest of the resource's URI that will permit messages to be
579 * properly routed. Example: /a/light
581 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
582 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
583 * if you want to use a specific Flag like IPv4,
584 * you should apply OR operation for the flag in here.
585 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
588 * @param isObservable a boolean containing whether the resource supports observation
590 * @param resourceTypes a collection of resource types implemented by the resource
592 * @param interfaces a collection of interfaces that the resource supports/implements
593 * @return OCResource::Ptr a shared pointer to the new resource object
595 OCResource::Ptr constructResourceObject(const std::string& host,
596 const std::string& uri,
597 OCConnectivityType connectivityType, bool isObservable,
598 const std::vector<std::string>& resourceTypes,
599 const std::vector<std::string>& interfaces);
602 * Allows application entity handler to send response to an incoming request.
604 * @param pResponse OCResourceResponse pointer that will permit to set values related
605 * to resource response.
607 * @return Returns ::OC_STACK_OK if success.
609 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
612 * Find all the Direct Pairing capable devices.
614 * @param waittime timeoutbefore the callback is called
615 * @param callback function to callback with discovered devices after timeout
617 * @return Returns ::OC_STACK_OK if success
619 OCStackResult findDirectPairingDevices(unsigned short waittime,
620 GetDirectPairedCallback callback);
623 * Get all the Direct paired devices.
625 * @param callback function to callback with the list of paired devices
627 * @return Returns ::OC_STACK_OK if success
629 OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
632 * Perform the Direct Pairing with the selected peer device
634 * @param peer device to direct pair with
635 * @param pmSel Selected pairing method
636 * @param pinNumber pin to validate peer & perform the direct pairing
637 * @param resultCallback callback function that will get the result of the operation
639 * @return Returns ::OC_STACK_OK if success
641 OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
642 const std::string& pinNumber,
643 DirectPairingCallback resultCallback);
646 * Create an account manager object that can be used for doing request to account server.
647 * You can only create this object if OCPlatform was initialized to be a Client or
648 * Client/Server. Otherwise, this will return an empty shared ptr.
650 * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
651 * methods of this object to work since device id is not generated on Client mode.
653 * @param host Host IP Address of a account server.
654 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
655 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
656 * if you want to use a specific Flag like IPv4,
657 * you should apply OR operation for the flag in here.
658 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
661 * @return OCAccountManager::Ptr a shared pointer to the new account manager object
663 OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
664 OCConnectivityType connectivityType);
668 * API for Virtual Resource("/oic/d" and "/oic/p") Publish to Resource Directory.
669 * @note This API applies to resource server side only.
671 * @param host Host IP Address of a service to direct resource publish query.
672 * @param connectivityType ::OCConnectivityType type of connectivity.
673 * @param callback Handles callbacks, success states and failure states.
675 * @return Returns ::OC_STACK_OK if success.
677 OCStackResult publishResourceToRD(const std::string& host,
678 OCConnectivityType connectivityType,
679 PublishResourceCallback callback);
684 * @param host Host IP Address of a service to direct resource publish query.
685 * @param connectivityType ::OCConnectivityType type of connectivity.
686 * @param callback Handles callbacks, success states and failure states.
687 * @param QoS the quality of communication.
689 * @return Returns ::OC_STACK_OK if success.
691 OCStackResult publishResourceToRD(const std::string& host,
692 OCConnectivityType connectivityType,
693 PublishResourceCallback callback,
694 QualityOfService QoS);
697 * API for Resource Publish to Resource Directory.
698 * @note This API applies to resource server side only.
700 * @param host Host IP Address of a service to direct resource publish query.
701 * @param connectivityType ::OCConnectivityType type of connectivity.
702 * @param resourceHandle resource handle of the resource.
703 * @param callback Handles callbacks, success states and failure states.
705 * @return Returns ::OC_STACK_OK if success.
707 OCStackResult publishResourceToRD(const std::string& host,
708 OCConnectivityType connectivityType,
709 ResourceHandles& resourceHandles,
710 PublishResourceCallback callback);
715 * @param host Host IP Address of a service to direct resource publish query.
716 * @param connectivityType ::OCConnectivityType type of connectivity.
717 * @param resourceHandle resource handle of the resource.
718 * @param callback function to callback with published resources.
719 * @param QoS the quality of communication.
720 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
721 * uint8_t, PublishResourceCallback)
723 OCStackResult publishResourceToRD(const std::string& host,
724 OCConnectivityType connectivityType,
725 ResourceHandles& resourceHandles,
726 PublishResourceCallback callback, QualityOfService QoS);
729 * API for published resource delete from Resource Directory.
730 * @note This API applies to resource server side only.
732 * @param host Host IP Address of a service to direct resource delete query.
733 * @param connectivityType ::OCConnectivityType type of connectivity.
734 * @param callback Handles callbacks, success states and failure states.
736 * @return Returns ::OC_STACK_OK if success.
738 OCStackResult deleteResourceFromRD(const std::string& host,
739 OCConnectivityType connectivityType,
740 DeleteResourceCallback callback);
745 * @param host Host IP Address of a service to direct resource delete query.
746 * @param connectivityType ::OCConnectivityType type of connectivity.
747 * @param callback Handles callbacks, success states and failure states.
748 * @param QoS the quality of communication.
750 * @return Returns ::OC_STACK_OK if success.
752 OCStackResult deleteResourceFromRD(const std::string& host,
753 OCConnectivityType connectivityType,
754 DeleteResourceCallback callback,
755 QualityOfService QoS);
760 * @param host Host IP Address of a service to direct resource delete query.
761 * @param connectivityType ::OCConnectivityType type of connectivity.
762 * @param resourceHandle resource handle of the resource.
763 * @param callback function to callback with published resources.
764 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
765 * uint8_t, PublishResourceCallback)
767 OCStackResult deleteResourceFromRD(const std::string& host,
768 OCConnectivityType connectivityType,
769 ResourceHandles& resourceHandles,
770 DeleteResourceCallback callback);
775 * @param host Host IP Address of a service to direct resource delete query.
776 * @param connectivityType ::OCConnectivityType type of connectivity.
777 * @param resourceHandle resource handle of the resource.
778 * @param callback function to callback with published resources.
779 * @param QoS the quality of communication.
780 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
781 * uint8_t, PublishResourceCallback)
783 OCStackResult deleteResourceFromRD(const std::string& host,
784 OCConnectivityType connectivityType,
785 ResourceHandles& resourceHandles,
786 DeleteResourceCallback callback, QualityOfService QoS);
791 #endif // OC_PLATFORM_H_