c6062b2167503e28f785101624b4de115bcd2635
[platform/upstream/iotivity.git] / resource / include / OCPlatform.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /**
22  * @file
23  *
24  * This file contains the declaration of classes and its members related to
25  * OCPlatform.
26  */
27
28 #ifndef OC_PLATFORM_H_
29 #define OC_PLATFORM_H_
30 #include <OCApi.h>
31 #include <OCPlatform_impl.h>
32 namespace OC
33 {
34     /**
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.
39     */
40     namespace OCPlatform
41     {
42         /**
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
45         * will have no affect
46         */
47         void Configure(const PlatformConfig& config);
48
49         // typedef for handle to cancel presence info with
50         typedef OCDoHandle OCPresenceHandle;
51
52         /**
53          * API for notifying base that resource's attributes have changed.
54          *
55          * @param resourceHandle resource handle of the resource
56          *
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)
62          */
63         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle);
64
65         /**
66          * @overload
67          *
68          * @param resourceHandle resource handle of the resource
69          * @param QoS the quality of communication
70          * @see notifyAllObservers(OCResourceHandle)
71          */
72         OCStackResult notifyAllObservers(OCResourceHandle resourceHandle, QualityOfService QoS);
73
74         /**
75          * API for notifying only specific clients that resource's attributes have changed.
76          *
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
81          * resource change.
82          *
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)
88          */
89         OCStackResult notifyListOfObservers(
90                     OCResourceHandle resourceHandle,
91                     ObservationIds& observationIds,
92                     const std::shared_ptr<OCResourceResponse> responsePtr);
93         /**
94          * @overload
95          *
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
100          * resource change.
101          * @param QoS the quality of communication
102          * @see notifyListOfObservers(OCResourceHandle, ObservationIds&, const std::shared_ptr<OCResourceResponse>)
103          */
104         OCStackResult notifyListOfObservers(
105                     OCResourceHandle resourceHandle,
106                     ObservationIds& observationIds,
107                     const std::shared_ptr<OCResourceResponse> responsePtr,
108                     QualityOfService QoS);
109
110         /**
111          * API for Service and Resource Discovery.
112          * @note This API applies to client side only.
113          *
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
117          *       resource names
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.
121          *
122          *        Four modes of discovery defined as follows:
123          *        (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
124          *           discovery.
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
129          *                                   resource(s)
130          *                                  from a particular service.
131          *
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
135          * as BTH etc.
136          * @note OCStackResult is defined in ocstack.h.
137          * @see findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback, QualityOfService)
138          */
139         OCStackResult findResource(const std::string& host, const std::string& resourceURI,
140                     OCConnectivityType connectivityType, FindCallback resourceHandler);
141         /**
142          * @overload
143          *
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
147          *       resource names
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.
151          *
152          *        Four modes of discovery defined as follows:
153          *        (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
154          *           discovery.
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
159          *                                   resource(s)
160          *                                  from a particular service.
161          * @param QoS QualityOfService the quality of communication
162          * @see findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback)
163          */
164         OCStackResult findResource(const std::string& host, const std::string& resourceURI,
165                     OCConnectivityType connectivityType, FindCallback resourceHandler,
166                     QualityOfService QoS);
167
168         OCStackResult findResource(const std::string& host, const std::string& resourceURI,
169                     OCConnectivityType connectivityType, FindCallback resourceHandler,
170                     FindErrorCallback errorHandler);
171
172         OCStackResult findResource(const std::string& host, const std::string& resourceURI,
173                     OCConnectivityType connectivityType, FindCallback resourceHandler,
174                     FindErrorCallback errorHandler, QualityOfService QoS);
175
176         /**
177          * API for Device Discovery
178          *
179          *
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
182                                 ("/oic/d")
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
186          *
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)
190          */
191         OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
192                     OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler);
193         /**
194          * @overload
195          *
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
198                                 ("/oic/d")
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)
204          */
205         OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
206                     OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler,
207                     QualityOfService QoS);
208
209         /**
210          * API for Platform Discovery
211          *
212          *
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
215                                 ("/oic/p")
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
219          *
220          * @return Returns ::OC_STACK_OK if success.
221          *
222          * @note OCStackResult is defined in ocstack.h.
223          * @see getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback, QualityOfService)
224          */
225         OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
226                     OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler);
227         /**
228          * @overload
229          *
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
232                                 ("/oic/p")
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)
238          */
239         OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
240                     OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler,
241                     QualityOfService QoS);
242
243         /**
244         * This API registers a resource with the server
245         * @note This API applies to server side only.
246         *
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
256         * observation
257         *
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
265         * qualified URI OR
266         * first parameter can take fully qualified URI and core will take that as is for further
267         * operations
268         * @note OCStackResult is defined in ocstack.h.
269         */
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);
276
277         /**
278          * This API registers a resource with the server
279          * @note This API applies to server & client side.
280          *
281          * @param resourceHandle Upon successful registration, resourceHandle will be filled
282          * @param resource The instance of OCResource that all data filled.
283          *
284          * @return Returns ::OC_STACK_OK if success.
285          * @note OCStackResult is defined in ocstack.h.
286          */
287         OCStackResult registerResource(OCResourceHandle& resourceHandle,
288                         const std::shared_ptr< OCResource > resource);
289
290         /**
291         * Register Device Info
292         *
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
295         */
296         OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo);
297
298         /**
299         * Register Platform Info
300         *
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
303         */
304         OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo);
305
306         /**
307         * Set default device entity handler
308         *
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
313         */
314         OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler);
315
316         /**
317         * This API unregisters a resource with the server
318         * @note This API applies to server side only.
319         *
320         * @param resourceHandle This is the resource handle which we need to unregister from the
321         * server
322         *
323         * @return Returns ::OC_STACK_OK if success.
324         * @note OCStackResult is defined in ocstack.h.
325         */
326         OCStackResult unregisterResource(const OCResourceHandle& resourceHandle);
327
328         /**
329         * Add a resource to a collection resource.
330         *
331         * @param collectionHandle handle to the collection resource
332         * @param resourceHandle handle to resource to be added to the collection resource
333         *
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
338         *
339         * @par Example:
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);
345         * @par
346         * At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".
347         */
348         OCStackResult bindResource(const OCResourceHandle collectionHandle,
349                 const OCResourceHandle resourceHandle);
350
351         /**
352         * Add multiple resources to a collection resource.
353         *
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
357         *
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
362         * obtained.
363         *
364         * @par Example:
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);
374         * @par
375         * At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and
376         *   "a/room"
377         */
378         OCStackResult bindResources(const OCResourceHandle collectionHandle,
379                 const std::vector<OCResourceHandle>& addedResourceHandleList);
380
381         /**
382         * Unbind a resource from a collection resource.
383         *
384         * @param collectionHandle handle to the collection resource
385         * @param resourceHandle resource handle to be unbound from the collection resource
386         *
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
391         *
392         * @par Example:
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);
399         * @par
400         * At the end of Step 4, resource "a/home" will no longer reference "a/kitchen".
401         */
402         OCStackResult unbindResource(const OCResourceHandle collectionHandle,
403                     const OCResourceHandle resourceHandle);
404
405         /**
406         * Unbind resources from a collection resource.
407         *
408         * @param collectionHandle handle to the collection resource
409         * @param resourceHandleList List of resource handles to be unbound from the collection
410         *   resource
411         *
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
416         *   obtained.
417         *
418         * @par Example:
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);
429         * @par
430         * At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and
431         *   "a/room"
432         */
433         OCStackResult unbindResources(const OCResourceHandle collectionHandle,
434                         const std::vector<OCResourceHandle>& resourceHandleList);
435
436         /**
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
440         *
441         * @return Returns ::OC_STACK_OK if success.
442         */
443         OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
444                         const std::string& resourceTypeName);
445
446         /**
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
450         *
451         * @return Returns ::OC_STACK_OK if success.
452         */
453         OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
454                         const std::string& resourceInterfaceName);
455
456
457         /**
458         * Start Presence announcements.
459         *
460         * @param ttl time to live
461         * @par
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.
465         * @par
466         * @return Returns ::OC_STACK_OK if success.
467         *
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.
471         *
472         */
473         OCStackResult startPresence(const unsigned int ttl);
474
475         /**
476         * Stop Presence announcements.
477         *
478         * @return Returns ::OC_STACK_OK if success.
479         *
480         * Server can call this function when it is terminating,
481         * going offline, or when going away from network.
482         *
483         */
484         OCStackResult stopPresence();
485
486         /**
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).
490          *
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
499          *               events
500          *
501          * @return Returns ::OC_STACK_OK if success.
502          * @copydoc subscribePresence(OCPresenceHandle&, const std::string&, resourceType, OCConnectivityType, SubscribeCallback)
503          */
504         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
505                         OCConnectivityType connectivityType, SubscribeCallback presenceHandler);
506         /**
507          * @overload
508          *
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
518          *               events
519          * @see subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
520          */
521         OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
522                         const std::string& resourceType, OCConnectivityType connectivityType,
523                         SubscribeCallback presenceHandler);
524
525         /**
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.
529          *
530          * @param presenceHandle the handle object provided by the subscribePresence call that
531          *               identifies this subscription.
532          *
533          * @return Returns ::OC_STACK_OK if success.
534          */
535         OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle);
536
537 #ifdef WITH_CLOUD
538         /**
539          * Subscribes to a server's device presence change events.
540          *
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
553          *
554          * @return Returns ::OC_STACK_OK if success.
555          */
556         OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
557                                               const std::string& host,
558                                               const std::vector<std::string>& di,
559                                               OCConnectivityType connectivityType,
560                                               ObserveCallback callback);
561 #endif
562
563         /**
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
571          * shared ptr.
572          *
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
577          *
578          * @param uri the rest of the resource's URI that will permit messages to be
579          *           properly routed.  Example: /a/light
580          *
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
586          *                                                                    | OC_IP_USE_V4)
587          *
588          * @param isObservable a boolean containing whether the resource supports observation
589          *
590          * @param resourceTypes a collection of resource types implemented by the resource
591          *
592          * @param interfaces a collection of interfaces that the resource supports/implements
593          * @return OCResource::Ptr a shared pointer to the new resource object
594          */
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);
600
601         /**
602          * Allows application entity handler to send response to an incoming request.
603          *
604          * @param pResponse OCResourceResponse pointer that will permit to set values related
605          * to resource response.
606          *
607          * @return Returns ::OC_STACK_OK if success.
608          */
609         OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
610
611         /**
612          * Find all the Direct Pairing capable devices.
613          *
614          * @param waittime timeoutbefore the callback is called
615          * @param callback function to callback with discovered devices after timeout
616          *
617          * @return Returns ::OC_STACK_OK if success
618          */
619         OCStackResult findDirectPairingDevices(unsigned short waittime,
620                                      GetDirectPairedCallback callback);
621
622         /**
623          * Get all the Direct paired devices.
624          *
625          * @param callback function to callback with the list of paired devices
626          *
627          * @return Returns ::OC_STACK_OK if success
628          */
629         OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
630
631         /**
632          * Perform the Direct Pairing with the selected peer device
633          *
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
638          *
639          * @return Returns ::OC_STACK_OK if success
640          */
641         OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
642                                      const std::string& pinNumber,
643                                      DirectPairingCallback resultCallback);
644 #ifdef WITH_CLOUD
645         /**
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.
649          *
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.
652          *
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
659          *                                                                    | OC_IP_USE_V4)
660          *
661          * @return OCAccountManager::Ptr a shared pointer to the new account manager object
662          */
663         OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
664                                                             OCConnectivityType connectivityType);
665 #endif // WITH_CLOUD
666 #ifdef RD_CLIENT
667         /**
668          * API for Virtual Resource("/oic/d" and "/oic/p") Publish to Resource Directory.
669          * @note This API applies to resource server side only.
670          *
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.
674          *
675          * @return Returns ::OC_STACK_OK if success.
676          */
677         OCStackResult publishResourceToRD(const std::string& host,
678                                           OCConnectivityType connectivityType,
679                                           PublishResourceCallback callback);
680
681         /**
682          * API for Resource Publish to Resource Directory.
683          * @note This API applies to resource server side only.
684          *
685          * @param host Host IP Address of a service to direct resource publish query.
686          * @param connectivityType ::OCConnectivityType type of connectivity.
687          * @param resourceHandle resource handle of the resource.
688          * @param callback Handles callbacks, success states and failure states.
689          *
690          * @return Returns ::OC_STACK_OK if success.
691          */
692         OCStackResult publishResourceToRD(const std::string& host,
693                                           OCConnectivityType connectivityType,
694                                           ResourceHandles& resourceHandles,
695                                           PublishResourceCallback callback);
696
697         /**
698          * @overload
699          *
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 function to callback with published resources.
704          * @param QoS the quality of communication
705          * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
706          * uint8_t, PublishResourceCallback)
707          */
708         OCStackResult publishResourceToRD(const std::string& host,
709                                           OCConnectivityType connectivityType,
710                                           ResourceHandles& resourceHandles,
711                                           PublishResourceCallback callback, QualityOfService QoS);
712
713         /**
714          * API for published resource delete from Resource Directory.
715          * @note This API applies to resource server side only.
716          *
717          * @param host Host IP Address of a service to direct resource delete query.
718          * @param connectivityType ::OCConnectivityType type of connectivity.
719          * @param callback Handles callbacks, success states and failure states.
720          *
721          * @return Returns ::OC_STACK_OK if success.
722          */
723         OCStackResult deleteResourceFromRD(const std::string& host,
724                                            OCConnectivityType connectivityType,
725                                            DeleteResourceCallback callback);
726
727         /**
728          * @overload
729          *
730          * @param host Host IP Address of a service to direct resource delete query.
731          * @param connectivityType ::OCConnectivityType type of connectivity.
732          * @param resourceHandle resource handle of the resource.
733          * @param callback function to callback with published resources.
734          * @param QoS the quality of communication
735          * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
736          * uint8_t, PublishResourceCallback)
737          */
738         OCStackResult deleteResourceFromRD(const std::string& host,
739                                            OCConnectivityType connectivityType,
740                                            ResourceHandles& resourceHandles,
741                                            DeleteResourceCallback callback);
742
743         /**
744          * @overload
745          *
746          * @param host Host IP Address of a service to direct resource delete query.
747          * @param connectivityType ::OCConnectivityType type of connectivity.
748          * @param resourceHandle resource handle of the resource.
749          * @param callback function to callback with published resources.
750          * @param QoS the quality of communication
751          * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
752          * uint8_t, PublishResourceCallback)
753          */
754         OCStackResult deleteResourceFromRD(const std::string& host,
755                                            OCConnectivityType connectivityType,
756                                            ResourceHandles& resourceHandles,
757                                            DeleteResourceCallback callback, QualityOfService QoS);
758 #endif
759     }
760 }
761
762 #endif // OC_PLATFORM_H_
763
764
765