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.
269 * @note entity handler callback :
270 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
271 * OC_EH_SLOW and etc in entity handler callback,
272 * ocstack will be not send response automatically to client
273 * except for error return value like OC_EH_ERROR
274 * If you want to send response to client with specific result,
275 * OCDoResponse API should be called with the result value.
277 OCStackResult registerResource(OCResourceHandle& resourceHandle,
278 std::string& resourceURI,
279 const std::string& resourceTypeName,
280 const std::string& resourceInterface,
281 EntityHandler entityHandler,
282 uint8_t resourceProperty);
285 * This API registers a resource with the server
286 * @note This API applies to server & client side.
288 * @param resourceHandle Upon successful registration, resourceHandle will be filled
289 * @param resource The instance of OCResource that all data filled.
291 * @return Returns ::OC_STACK_OK if success.
292 * @note OCStackResult is defined in ocstack.h.
294 OCStackResult registerResource(OCResourceHandle& resourceHandle,
295 const std::shared_ptr< OCResource > resource);
298 * Register Device Info
300 * @param deviceInfo structure containing all the device specific information
301 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
303 OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo);
306 * Register Platform Info
308 * @param platformInfo structure containing all the platform specific information
309 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
311 OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo);
314 * Set default device entity handler
316 * @param entityHandler entity handler to handle requests for
317 * any undefined resources or default actions.
318 * if NULL is passed it removes the device default entity handler.
319 * @return Returns ::OC_STACK_OK if no errors and ::OC_STACK_ERROR in case of stack process error
320 * @note entity handler callback :
321 * When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT,
322 * OC_EH_SLOW and etc in entity handler callback,
323 * ocstack will be not send response automatically to client
324 * except for error return value like OC_EH_ERROR
325 * If you want to send response to client with specific result,
326 * sendResponse API should be called with the result value.
328 OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler);
331 * This API unregisters a resource with the server
332 * @note This API applies to server side only.
334 * @param resourceHandle This is the resource handle which we need to unregister from the
337 * @return Returns ::OC_STACK_OK if success.
338 * @note OCStackResult is defined in ocstack.h.
340 OCStackResult unregisterResource(const OCResourceHandle& resourceHandle);
343 * Add a resource to a collection resource.
345 * @param collectionHandle handle to the collection resource
346 * @param resourceHandle handle to resource to be added to the collection resource
348 * @return Returns ::OC_STACK_OK if success.
349 * @note OCStackResult is defined in ocstack.h.
350 * @note bindResource must be used only after the both collection resource and
351 * resource to add under a collections are created and respective handles obtained
354 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
355 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
356 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
357 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
358 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
360 * At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".
362 OCStackResult bindResource(const OCResourceHandle collectionHandle,
363 const OCResourceHandle resourceHandle);
366 * Add multiple resources to a collection resource.
368 * @param collectionHandle handle to the collection resource
369 * @param addedResourceHandleList reference to list of resource handles to be added to the
370 * collection resource
372 * @return Returns ::OC_STACK_OK if success.
373 * @note OCStackResult is defined in ocstack.h.
374 * @note bindResources must be used only after the both collection resource and
375 * list of resources to add under a collection are created and respective handles
379 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
380 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
381 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
382 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
383 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
384 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
385 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
386 * rList.push_back(roomResourceHandle);
387 * -# bindResource(homeResourceHandle, rList);
389 * At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and
392 OCStackResult bindResources(const OCResourceHandle collectionHandle,
393 const std::vector<OCResourceHandle>& addedResourceHandleList);
396 * Unbind a resource from a collection resource.
398 * @param collectionHandle handle to the collection resource
399 * @param resourceHandle resource handle to be unbound from the collection resource
401 * @return Returns ::OC_STACK_OK if success.
402 * @note OCStackResult is defined in ocstack.h.
403 * @note unbindResource must be used only after the both collection resource and
404 * resource to unbind from a collection are created and respective handles obtained
407 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
408 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
409 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
410 * entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
411 * -# bindResource(homeResourceHandle, kitchenResourceHandle);
412 * -# unbindResource(homeResourceHandle, kitchenResourceHandle);
414 * At the end of Step 4, resource "a/home" will no longer reference "a/kitchen".
416 OCStackResult unbindResource(const OCResourceHandle collectionHandle,
417 const OCResourceHandle resourceHandle);
420 * Unbind resources from a collection resource.
422 * @param collectionHandle handle to the collection resource
423 * @param resourceHandleList List of resource handles to be unbound from the collection
426 * @return Returns ::OC_STACK_OK if success.
427 * @note OCStackResult is defined in ocstack.h.
428 * @note unbindResources must be used only after the both collection resource and
429 * list of resources resource to unbind from a collection are created and respective handles
433 * -# registerResource(homeResourceHandle, "a/home", "home", Link_Interface,
434 * homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
435 * -# registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface,
436 * kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
437 * -# registerResource(roomResourceHandle, "a/room", "room", Link_Interface,
438 * roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
439 * -# std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle);
440 * rList.push_back(roomResourceHandle);
441 * -# bindResource(homeResourceHandle, rList);
442 * -# unbindResources(homeResourceHandle, rList);
444 * At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and
447 OCStackResult unbindResources(const OCResourceHandle collectionHandle,
448 const std::vector<OCResourceHandle>& resourceHandleList);
451 * Binds a type to a particular resource
452 * @param resourceHandle handle to the resource
453 * @param resourceTypeName new typename to bind to the resource
455 * @return Returns ::OC_STACK_OK if success.
457 OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
458 const std::string& resourceTypeName);
461 * Binds an interface to a particular resource
462 * @param resourceHandle handle to the resource
463 * @param resourceInterfaceName new interface to bind to the resource
465 * @return Returns ::OC_STACK_OK if success.
467 OCStackResult bindInterfaceToResource(const OCResourceHandle& resourceHandle,
468 const std::string& resourceInterfaceName);
472 * Start Presence announcements.
474 * @param ttl time to live
476 * If ttl is '0', then the default stack value will be used (60 Seconds).
477 * If ttl is greater than OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be set to
478 * OC_MAX_PRESENCE_TTL_SECONDS.
480 * @return Returns ::OC_STACK_OK if success.
482 * Server can call this function when it comes online for the
483 * first time, or when it comes back online from offline mode,
484 * or when it re enters network.
487 OCStackResult startPresence(const unsigned int ttl);
490 * Stop Presence announcements.
492 * @return Returns ::OC_STACK_OK if success.
494 * Server can call this function when it is terminating,
495 * going offline, or when going away from network.
498 OCStackResult stopPresence();
501 * subscribes to a server's presence change events. By making this subscription,
502 * every time a server adds/removes/alters a resource, starts or is intentionally
503 * stopped (potentially more to be added later).
505 * @param presenceHandle a handle object that can be used to identify this subscription
506 * request. It can be used to unsubscribe from these events in the future.
507 * It will be set upon successful return of this method.
508 * @param host The IP address/addressable name of the server to subscribe to.
509 * This should be in the format coap://address:port
510 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
511 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
512 * @param presenceHandler callback function that will receive notifications/subscription
515 * @return Returns ::OC_STACK_OK if success.
516 * @copydoc subscribePresence(OCPresenceHandle&, const std::string&, resourceType, OCConnectivityType, SubscribeCallback)
518 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
519 OCConnectivityType connectivityType, SubscribeCallback presenceHandler);
523 * @param presenceHandle a handle object that can be used to identify this subscription
524 * request. It can be used to unsubscribe from these events in the future.
525 * It will be set upon successful return of this method.
526 * @param host The IP address/addressable name of the server to subscribe to.
527 * This should be in the format coap://address:port
528 * @param resourceType a resource type specified as a filter for subscription callbacks.
529 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
530 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
531 * @param presenceHandler callback function that will receive notifications/subscription
533 * @see subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
535 OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
536 const std::string& resourceType, OCConnectivityType connectivityType,
537 SubscribeCallback presenceHandler);
540 * unsubscribes from a previously subscribed server's presence events. Note that
541 * you may for a short time still receive events from the server since it may take time
542 * for the unsubscribe to take effect.
544 * @param presenceHandle the handle object provided by the subscribePresence call that
545 * identifies this subscription.
547 * @return Returns ::OC_STACK_OK if success.
549 OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle);
553 * Subscribes to a server's device presence change events.
555 * @param presenceHandle a handle object that can be used to identify this subscription
556 * request. It can be used to unsubscribe from these events in the future.
557 * It will be set upon successful return of this method.
558 * @param host The IP address/addressable name of the server to subscribe to.
559 * This should be in the format coap://address:port
560 * @param di Vector which can have the devices id.
561 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
562 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
563 * @param observeHandler handles callback
564 * The callback function will be invoked with a map of attribute name and values.
565 * The callback function will also have the result from this observe operation
566 * This will have error codes
568 * @return Returns ::OC_STACK_OK if success.
570 OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
571 const std::string& host,
572 const std::vector<std::string>& di,
573 OCConnectivityType connectivityType,
574 ObserveCallback callback);
578 * Creates a resource proxy object so that get/put/observe functionality
579 * can be used without discovering the object in advance. Note that the
580 * consumer of this method needs to provide all of the details required to
581 * correctly contact and observe the object. If the consumer lacks any of
582 * this information, they should discover the resource object normally.
583 * Additionally, you can only create this object if OCPlatform was initialized
584 * to be a Client or Client/Server. Otherwise, this will return an empty
587 * @param host a string containing a resolvable host address of the server
588 * holding the resource. Currently this should be in the format
589 * coap://address:port, though in the future, we expect this to
590 * change to //address:port
592 * @param uri the rest of the resource's URI that will permit messages to be
593 * properly routed. Example: /a/light
595 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
596 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
597 * if you want to use a specific Flag like IPv4,
598 * you should apply OR operation for the flag in here.
599 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
602 * @param isObservable a boolean containing whether the resource supports observation
604 * @param resourceTypes a collection of resource types implemented by the resource
606 * @param interfaces a collection of interfaces that the resource supports/implements
607 * @return OCResource::Ptr a shared pointer to the new resource object
609 OCResource::Ptr constructResourceObject(const std::string& host,
610 const std::string& uri,
611 OCConnectivityType connectivityType, bool isObservable,
612 const std::vector<std::string>& resourceTypes,
613 const std::vector<std::string>& interfaces);
616 * Allows application entity handler to send response to an incoming request.
618 * @param pResponse OCResourceResponse pointer that will permit to set values related
619 * to resource response.
621 * @return Returns ::OC_STACK_OK if success.
623 OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
626 * Find all the Direct Pairing capable devices.
628 * @param waittime timeoutbefore the callback is called
629 * @param callback function to callback with discovered devices after timeout
631 * @return Returns ::OC_STACK_OK if success
633 OCStackResult findDirectPairingDevices(unsigned short waittime,
634 GetDirectPairedCallback callback);
637 * Get all the Direct paired devices.
639 * @param callback function to callback with the list of paired devices
641 * @return Returns ::OC_STACK_OK if success
643 OCStackResult getDirectPairedDevices(GetDirectPairedCallback callback);
646 * Perform the Direct Pairing with the selected peer device
648 * @param peer device to direct pair with
649 * @param pmSel Selected pairing method
650 * @param pinNumber pin to validate peer & perform the direct pairing
651 * @param resultCallback callback function that will get the result of the operation
653 * @return Returns ::OC_STACK_OK if success
655 OCStackResult doDirectPairing(std::shared_ptr<OCDirectPairing> peer, OCPrm_t pmSel,
656 const std::string& pinNumber,
657 DirectPairingCallback resultCallback);
660 * Create an account manager object that can be used for doing request to account server.
661 * You can only create this object if OCPlatform was initialized to be a Client or
662 * Client/Server. Otherwise, this will return an empty shared ptr.
664 * @note For now, OCPlatform SHOULD be initialized to be a Client/Server(Both) for the
665 * methods of this object to work since device id is not generated on Client mode.
667 * @param host Host IP Address of a account server.
668 * @param connectivityType ::OCConnectivityType type of connectivity indicating the
669 * interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
670 * if you want to use a specific Flag like IPv4,
671 * you should apply OR operation for the flag in here.
672 * Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP
675 * @return OCAccountManager::Ptr a shared pointer to the new account manager object
677 OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
678 OCConnectivityType connectivityType);
682 * API for Virtual Resource("/oic/d" and "/oic/p") Publish to Resource Directory.
683 * @note This API applies to resource server side only.
685 * @param host Host IP Address of a service to direct resource publish query.
686 * @param connectivityType ::OCConnectivityType type of connectivity.
687 * @param callback Handles callbacks, success states and failure states.
689 * @return Returns ::OC_STACK_OK if success.
691 OCStackResult publishResourceToRD(const std::string& host,
692 OCConnectivityType connectivityType,
693 PublishResourceCallback callback);
698 * @param host Host IP Address of a service to direct resource publish query.
699 * @param connectivityType ::OCConnectivityType type of connectivity.
700 * @param callback Handles callbacks, success states and failure states.
701 * @param QoS the quality of communication.
703 * @return Returns ::OC_STACK_OK if success.
705 OCStackResult publishResourceToRD(const std::string& host,
706 OCConnectivityType connectivityType,
707 PublishResourceCallback callback,
708 QualityOfService QoS);
711 * API for Resource Publish to Resource Directory.
712 * @note This API applies to resource server side only.
714 * @param host Host IP Address of a service to direct resource publish query.
715 * @param connectivityType ::OCConnectivityType type of connectivity.
716 * @param resourceHandle resource handle of the resource.
717 * @param callback Handles callbacks, success states and failure states.
719 * @return Returns ::OC_STACK_OK if success.
721 OCStackResult publishResourceToRD(const std::string& host,
722 OCConnectivityType connectivityType,
723 ResourceHandles& resourceHandles,
724 PublishResourceCallback callback);
729 * @param host Host IP Address of a service to direct resource publish query.
730 * @param connectivityType ::OCConnectivityType type of connectivity.
731 * @param resourceHandle resource handle of the resource.
732 * @param callback function to callback with published resources.
733 * @param QoS the quality of communication.
734 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
735 * uint8_t, PublishResourceCallback)
737 OCStackResult publishResourceToRD(const std::string& host,
738 OCConnectivityType connectivityType,
739 ResourceHandles& resourceHandles,
740 PublishResourceCallback callback, QualityOfService QoS);
743 * API for published resource delete from Resource Directory.
744 * @note This API applies to resource server side only.
746 * @param host Host IP Address of a service to direct resource delete query.
747 * @param connectivityType ::OCConnectivityType type of connectivity.
748 * @param callback Handles callbacks, success states and failure states.
750 * @return Returns ::OC_STACK_OK if success.
752 OCStackResult deleteResourceFromRD(const std::string& host,
753 OCConnectivityType connectivityType,
754 DeleteResourceCallback callback);
759 * @param host Host IP Address of a service to direct resource delete query.
760 * @param connectivityType ::OCConnectivityType type of connectivity.
761 * @param callback Handles callbacks, success states and failure states.
762 * @param QoS the quality of communication.
764 * @return Returns ::OC_STACK_OK if success.
766 OCStackResult deleteResourceFromRD(const std::string& host,
767 OCConnectivityType connectivityType,
768 DeleteResourceCallback callback,
769 QualityOfService QoS);
774 * @param host Host IP Address of a service to direct resource delete query.
775 * @param connectivityType ::OCConnectivityType type of connectivity.
776 * @param resourceHandle resource handle of the resource.
777 * @param callback function to callback with published resources.
778 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
779 * uint8_t, PublishResourceCallback)
781 OCStackResult deleteResourceFromRD(const std::string& host,
782 OCConnectivityType connectivityType,
783 ResourceHandles& resourceHandles,
784 DeleteResourceCallback callback);
789 * @param host Host IP Address of a service to direct resource delete query.
790 * @param connectivityType ::OCConnectivityType type of connectivity.
791 * @param resourceHandle resource handle of the resource.
792 * @param callback function to callback with published resources.
793 * @param QoS the quality of communication.
794 * @see publishResourceToRD(const std::string&, OCConnectivityType, OCResourceHandle,
795 * uint8_t, PublishResourceCallback)
797 OCStackResult deleteResourceFromRD(const std::string& host,
798 OCConnectivityType connectivityType,
799 ResourceHandles& resourceHandles,
800 DeleteResourceCallback callback, QualityOfService QoS);
804 * gets the deviceId of the client
806 * @param deviceId pointer.
807 * @return Returns ::OC_STACK_OK if success.
809 OCStackResult getDeviceId(OCUUIdentity *deviceId);
812 * sets the deviceId of the client
814 * @param deviceId pointer.
815 * @return Returns ::OC_STACK_OK if success.
817 OCStackResult setDeviceId(const OCUUIdentity *deviceId);
821 #endif // OC_PLATFORM_H_