IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OCPlatform.h
Go to the documentation of this file.
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 
28 #ifndef OC_PLATFORM_H_
29 #define OC_PLATFORM_H_
30 #include <OCApi.h>
31 #include <OCPlatform_impl.h>
32 namespace OC
33 {
40  namespace OCPlatform
41  {
47  void Configure(const PlatformConfig& config);
48 
49  // typedef for handle to cancel presence info with
51 
59 
68 
81 
90 
107  OCResourceHandle resourceHandle,
108  ObservationIds& observationIds,
109  const std::shared_ptr<OCResourceResponse> responsePtr);
122  OCResourceHandle resourceHandle,
123  ObservationIds& observationIds,
124  const std::shared_ptr<OCResourceResponse> responsePtr,
125  QualityOfService QoS);
126 
159  OCStackResult findResource(const std::string& host, const std::string& resourceURI,
160  OCConnectivityType connectivityType, FindCallback resourceHandler);
187  OCStackResult findResource(const std::string& host, const std::string& resourceURI,
188  OCConnectivityType connectivityType, FindCallback resourceHandler,
189  QualityOfService QoS);
190 
191  OCStackResult findResource(const std::string& host, const std::string& resourceURI,
192  OCConnectivityType connectivityType, FindCallback resourceHandler,
193  FindErrorCallback errorHandler);
194 
195  OCStackResult findResource(const std::string& host, const std::string& resourceURI,
196  OCConnectivityType connectivityType, FindCallback resourceHandler,
197  FindErrorCallback errorHandler, QualityOfService QoS);
198 
199  OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
200  OCConnectivityType connectivityType, FindResListCallback resourceHandler,
202 
203  OCStackResult findResourceList(const std::string& host, const std::string& resourceURI,
204  OCConnectivityType connectivityType, FindResListCallback resourceHandler,
206 
207  OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag,
208  const std::string& value);
209  OCStackResult setPropertyValue(OCPayloadType type, const std::string& tag,
210  const std::vector<std::string>& value);
211  OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag,
212  std::string& value);
213  OCStackResult getPropertyValue(OCPayloadType type, const std::string& tag,
214  std::vector<std::string>& value);
230  OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
231  OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler);
244  OCStackResult getDeviceInfo(const std::string& host, const std::string& deviceURI,
245  OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler,
246  QualityOfService QoS);
247 
264  OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
265  OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler);
278  OCStackResult getPlatformInfo(const std::string& host, const std::string& platformURI,
279  OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler,
280  QualityOfService QoS);
281 
290 
323  std::string& resourceURI,
324  const std::string& resourceTypeName,
325  const std::string& resourceInterface,
326  EntityHandler entityHandler,
327  uint8_t resourceProperty);
328 
365  std::string& resourceURI,
366  const std::string& resourceTypeName,
367  const std::string& resourceInterface,
368  EntityHandler entityHandler,
369  uint8_t resourceProperty,
370  OCTpsSchemeFlags resourceTpsTypes);
371 
383  const std::shared_ptr< OCResource > resource);
384 
394 
402 
419 
430  OCStackResult unregisterResource(const OCResourceHandle& resourceHandle);
431 
452  OCStackResult bindResource(const OCResourceHandle collectionHandle,
453  const OCResourceHandle resourceHandle);
454 
482  OCStackResult bindResources(const OCResourceHandle collectionHandle,
483  const std::vector<OCResourceHandle>& addedResourceHandleList);
484 
506  OCStackResult unbindResource(const OCResourceHandle collectionHandle,
507  const OCResourceHandle resourceHandle);
508 
537  OCStackResult unbindResources(const OCResourceHandle collectionHandle,
538  const std::vector<OCResourceHandle>& resourceHandleList);
539 
547  OCStackResult bindTypeToResource(const OCResourceHandle& resourceHandle,
548  const std::string& resourceTypeName);
549 
558  const std::string& resourceInterfaceName);
559 
560 
577  OCStackResult startPresence(const unsigned int ttl);
578 
589 
608  OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
609  OCConnectivityType connectivityType, SubscribeCallback presenceHandler);
631  OCStackResult subscribePresence(OCPresenceHandle& presenceHandle, const std::string& host,
632  const std::string& resourceType, OCConnectivityType connectivityType,
633  SubscribeCallback presenceHandler);
634 
646 
647 #ifdef WITH_CLOUD
648 
666  OCStackResult subscribeDevicePresence(OCPresenceHandle& presenceHandle,
667  const std::string& host,
668  const std::vector<std::string>& di,
669  OCConnectivityType connectivityType,
670  ObserveCallback callback);
671 #endif
672 
707  OCResource::Ptr constructResourceObject(const std::string& host,
708  const std::string& uri,
709  OCConnectivityType connectivityType, bool isObservable,
710  const std::vector<std::string>& resourceTypes,
711  const std::vector<std::string>& interfaces);
712 
721  OCStackResult sendResponse(const std::shared_ptr<OCResourceResponse> pResponse);
722 
723 #ifdef WITH_CLOUD
724 
742  OCAccountManager::Ptr constructAccountManagerObject(const std::string& host,
743  OCConnectivityType connectivityType);
744 #endif // WITH_CLOUD
745 
753 
760  OCStackResult setDeviceId(const OCUUIdentity *deviceId);
761  }
762 }
763 
764 #endif // OC_PLATFORM_H_
OCStackResult getDeviceInfo(const std::string &host, const std::string &deviceURI, OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler)
API for Device Discovery.
OCStackResult findResource(const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindCallback resourceHandler)
API for Service and Resource Discovery.
OCStackResult unsubscribePresence(OCPresenceHandle presenceHandle)
unsubscribes from a previously subscribed server's presence events.
QualityOfService
Quality of Service attempts to abstract the guarantees provided by the underlying transport protocol...
Definition: OCApi.h:117
OCStackResult bindResource(const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle)
Add a resource to a collection resource.
OCStackResult sendResponse(const std::shared_ptr< OCResourceResponse > pResponse)
Allows application entity handler to send response to an incoming request.
This structure is expected as input for device properties.
Definition: octypes.h:1340
std::function< OCEntityHandlerResult(const std::shared_ptr< OCResourceRequest >)> EntityHandler
Definition: OCApi.h:369
OCStackResult unregisterResource(const OCResourceHandle &resourceHandle)
This API unregisters a resource with the server.
std::function< void(std::vector< std::shared_ptr< OCResource >>)> FindResListCallback
Definition: OCApi.h:362
OCStackResult getPlatformInfo(const std::string &host, const std::string &platformURI, OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler)
API for Platform Discovery.
This structure describes the platform properties.
Definition: octypes.h:1297
std::function< void(const std::string &, const int)> FindErrorCallback
Definition: OCApi.h:360
OCPayloadType
Enum to describe the type of object held by the OCPayload object.
Definition: octypes.h:1425
OCStackResult findResourceList(const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindResListCallback resourceHandler, QualityOfService QoS=QualityOfService::LowQos)
std::shared_ptr< OCResource > Ptr
Definition: OCResource.h:112
OCStackResult bindInterfaceToResource(const OCResourceHandle &resourceHandle, const std::string &resourceInterfaceName)
Binds an interface to a particular resource.
OCStackResult notifyAllObservers(OCResourceHandle resourceHandle)
API for notifying base that resource's attributes have changed.
void * OCResourceHandle
Handle to an OCResource object owned by the OCStack.
Definition: octypes.h:1152
OCStackResult notifyListOfObservers(OCResourceHandle resourceHandle, ObservationIds &observationIds, const std::shared_ptr< OCResourceResponse > responsePtr)
API for notifying only specific clients that resource's attributes have changed.
OCStackResult unbindResource(const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle)
Unbind a resource from a collection resource.
std::function< void(OCStackResult, const unsigned int, const std::string &)> SubscribeCallback
Definition: OCApi.h:372
OCStackResult getPropertyValue(OCPayloadType type, const std::string &tag, std::string &value)
OCStackResult stopPresence()
Stop Presence announcements.
OCStackResult start()
API for start Base layer including resource and connectivity abstraction.
Packet delivery is best effort.
OCStackResult getSupportedTransportsInfo(OCTpsSchemeFlags &supportedTps)
This function returns flags of supported endpoint TPS on stack.
std::function< void(const OCRepresentation &)> FindPlatformCallback
Definition: OCApi.h:366
void Configure(const PlatformConfig &config)
API for overwriting the default configuration of the OCPlatform object.
OCStackResult getDeviceId(OCUUIdentity *deviceId)
gets the deviceId of the client
OCStackResult
Declares Stack Results & Errors.
Definition: octypes.h:1054
void * OCDoHandle
Handle to an OCDoResource invocation.
Definition: octypes.h:1147
OCStackResult registerPlatformInfo(const OCPlatformInfo platformInfo)
Register Platform Info.
OCStackResult unbindResources(const OCResourceHandle collectionHandle, const std::vector< OCResourceHandle > &resourceHandleList)
Unbind resources from a collection resource.
OCConnectivityType
This enum type includes elements of both OCTransportAdapter and OCTransportFlags. ...
Definition: octypes.h:829
OCDoHandle OCPresenceHandle
Definition: OCPlatform.h:50
OCStackResult subscribePresence(OCPresenceHandle &presenceHandle, const std::string &host, OCConnectivityType connectivityType, SubscribeCallback presenceHandler)
subscribes to a server's presence change events.
Data structure to provide the configuration.
Definition: OCApi.h:135
std::function< void(std::shared_ptr< OCResource >)> FindCallback
Definition: OCApi.h:358
OCStackResult setDefaultDeviceEntityHandler(EntityHandler entityHandler)
Set default device entity handler.
Universally unique identifier.
Definition: octypes.h:786
std::function< void(const HeaderOptions &, const OCRepresentation &, const int, const int)> ObserveCallback
Definition: OCApi.h:386
std::function< void(const OCRepresentation &)> FindDeviceCallback
Definition: OCApi.h:364
OCResource::Ptr constructResourceObject(const std::string &host, const std::string &uri, OCConnectivityType connectivityType, bool isObservable, const std::vector< std::string > &resourceTypes, const std::vector< std::string > &interfaces)
Creates a resource proxy object so that get/put/observe functionality can be used without discovering...
OCStackResult setDeviceId(const OCUUIdentity *deviceId)
sets the deviceId of the client
OCStackResult registerResource(OCResourceHandle &resourceHandle, std::string &resourceURI, const std::string &resourceTypeName, const std::string &resourceInterface, EntityHandler entityHandler, uint8_t resourceProperty)
This API registers a resource with the server.
OCStackResult stop()
API for stop Base layer including resource and connectivity abstraction.
OCStackResult bindResources(const OCResourceHandle collectionHandle, const std::vector< OCResourceHandle > &addedResourceHandleList)
Add multiple resources to a collection resource.
OCStackResult startPresence(const unsigned int ttl)
Start Presence announcements.
OCStackResult registerDeviceInfo(const OCDeviceInfo deviceInfo)
Register Device Info.
OCStackResult bindTypeToResource(const OCResourceHandle &resourceHandle, const std::string &resourceTypeName)
Binds a type to a particular resource.
std::vector< OCObservationId > ObservationIds
Definition: OCApi.h:322
OCStackResult setPropertyValue(OCPayloadType type, const std::string &tag, const std::string &value)
OCTpsSchemeFlags
This enum type for indicate Transport Protocol Suites.
Definition: octypes.h:1355