IoTivity C++ SDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OC::OCPlatform Namespace Reference

This namespace contains the main entrance/functionality of the product. More...

Typedefs

typedef OCDoHandle OCPresenceHandle
 

Functions

void Configure (const PlatformConfig &config)
 API for overwriting the default configuration of the OCPlatform object. More...
 
OCStackResult stop ()
 API for stop Base layer including resource and connectivity abstraction. More...
 
OCStackResult start ()
 API for start Base layer including resource and connectivity abstraction. More...
 
OCStackResult notifyAllObservers (OCResourceHandle resourceHandle)
 API for notifying base that resource's attributes have changed. More...
 
OCStackResult notifyAllObservers (OCResourceHandle resourceHandle, QualityOfService QoS)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OCStackResult notifyListOfObservers (OCResourceHandle resourceHandle, ObservationIds &observationIds, const std::shared_ptr< OCResourceResponse > responsePtr)
 API for notifying only specific clients that resource's attributes have changed. More...
 
OCStackResult notifyListOfObservers (OCResourceHandle resourceHandle, ObservationIds &observationIds, const std::shared_ptr< OCResourceResponse > responsePtr, QualityOfService QoS)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OCStackResult findResource (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindCallback resourceHandler)
 API for Service and Resource Discovery. More...
 
OCStackResult findResource (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindCallback resourceHandler, QualityOfService QoS)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OCStackResult findResource (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindCallback resourceHandler, FindErrorCallback errorHandler)
 
OCStackResult findResource (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindCallback resourceHandler, FindErrorCallback errorHandler, QualityOfService QoS)
 
OCStackResult findResourceList (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindResListCallback resourceHandler, QualityOfService QoS=QualityOfService::LowQos)
 
OCStackResult findResourceList (const std::string &host, const std::string &resourceURI, OCConnectivityType connectivityType, FindResListCallback resourceHandler, FindErrorCallback errorHandler, QualityOfService QoS=QualityOfService::LowQos)
 
OCStackResult setPropertyValue (OCPayloadType type, const std::string &tag, const std::string &value)
 
OCStackResult setPropertyValue (OCPayloadType type, const std::string &tag, const std::vector< std::string > &value)
 
OCStackResult getPropertyValue (OCPayloadType type, const std::string &tag, std::string &value)
 
OCStackResult getPropertyValue (OCPayloadType type, const std::string &tag, std::vector< std::string > &value)
 
OCStackResult getDeviceInfo (const std::string &host, const std::string &deviceURI, OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler)
 API for Device Discovery. More...
 
OCStackResult getDeviceInfo (const std::string &host, const std::string &deviceURI, OCConnectivityType connectivityType, FindDeviceCallback deviceInfoHandler, QualityOfService QoS)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OCStackResult getPlatformInfo (const std::string &host, const std::string &platformURI, OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler)
 API for Platform Discovery. More...
 
OCStackResult getPlatformInfo (const std::string &host, const std::string &platformURI, OCConnectivityType connectivityType, FindPlatformCallback platformInfoHandler, QualityOfService QoS)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
OCStackResult getSupportedTransportsInfo (OCTpsSchemeFlags &supportedTps)
 This function returns flags of supported endpoint TPS on stack. More...
 
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. More...
 
OCStackResult registerResource (OCResourceHandle &resourceHandle, std::string &resourceURI, const std::string &resourceTypeName, const std::string &resourceInterface, EntityHandler entityHandler, uint8_t resourceProperty, OCTpsSchemeFlags resourceTpsTypes)
 This API registers a resource with the server. More...
 
OCStackResult registerResource (OCResourceHandle &resourceHandle, const std::shared_ptr< OCResource > resource)
 This API registers a resource with the server. More...
 
OCStackResult registerDeviceInfo (const OCDeviceInfo deviceInfo)
 Register Device Info. More...
 
OCStackResult registerPlatformInfo (const OCPlatformInfo platformInfo)
 Register Platform Info. More...
 
OCStackResult setDefaultDeviceEntityHandler (EntityHandler entityHandler)
 Set default device entity handler. More...
 
OCStackResult unregisterResource (const OCResourceHandle &resourceHandle)
 This API unregisters a resource with the server. More...
 
OCStackResult bindResource (const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle)
 Add a resource to a collection resource. More...
 
OCStackResult bindResources (const OCResourceHandle collectionHandle, const std::vector< OCResourceHandle > &addedResourceHandleList)
 Add multiple resources to a collection resource. More...
 
OCStackResult unbindResource (const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle)
 Unbind a resource from a collection resource. More...
 
OCStackResult unbindResources (const OCResourceHandle collectionHandle, const std::vector< OCResourceHandle > &resourceHandleList)
 Unbind resources from a collection resource. More...
 
OCStackResult bindTypeToResource (const OCResourceHandle &resourceHandle, const std::string &resourceTypeName)
 Binds a type to a particular resource. More...
 
OCStackResult bindInterfaceToResource (const OCResourceHandle &resourceHandle, const std::string &resourceInterfaceName)
 Binds an interface to a particular resource. More...
 
OCStackResult startPresence (const unsigned int ttl)
 Start Presence announcements. More...
 
OCStackResult stopPresence ()
 Stop Presence announcements. More...
 
OCStackResult subscribePresence (OCPresenceHandle &presenceHandle, const std::string &host, OCConnectivityType connectivityType, SubscribeCallback presenceHandler)
 subscribes to a server's presence change events. More...
 
OCStackResult subscribePresence (OCPresenceHandle &presenceHandle, const std::string &host, const std::string &resourceType, OCConnectivityType connectivityType, SubscribeCallback presenceHandler)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.subscribes to a server's presence change events. More...
 
OCStackResult unsubscribePresence (OCPresenceHandle presenceHandle)
 unsubscribes from a previously subscribed server's presence events. More...
 
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 the object in advance. More...
 
OCStackResult sendResponse (const std::shared_ptr< OCResourceResponse > pResponse)
 Allows application entity handler to send response to an incoming request. More...
 
OCStackResult getDeviceId (OCUUIdentity *deviceId)
 gets the deviceId of the client More...
 
OCStackResult setDeviceId (const OCUUIdentity *deviceId)
 sets the deviceId of the client More...
 

Detailed Description

This namespace contains the main entrance/functionality of the product.

It may be used with OC::OCPlatform::functionName. To set a custom configuration, the implementer must make a call to OCPlatform::Configure before the first usage of a function in this namespace.

Typedef Documentation

Function Documentation

OCStackResult OC::OCPlatform::bindInterfaceToResource ( const OCResourceHandle resourceHandle,
const std::string &  resourceInterfaceName 
)

Binds an interface to a particular resource.

Parameters
resourceHandlehandle to the resource
resourceInterfaceNamenew interface to bind to the resource
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::bindResource ( const OCResourceHandle  collectionHandle,
const OCResourceHandle  resourceHandle 
)

Add a resource to a collection resource.

Parameters
collectionHandlehandle to the collection resource
resourceHandlehandle to resource to be added to the collection resource
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
bindResource must be used only after the both collection resource and resource to add under a collections are created and respective handles obtained
Example:
  1. registerResource(homeResourceHandle, "a/home", "home", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  2. registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  3. bindResource(homeResourceHandle, kitchenResourceHandle);
At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".
OCStackResult OC::OCPlatform::bindResources ( const OCResourceHandle  collectionHandle,
const std::vector< OCResourceHandle > &  addedResourceHandleList 
)

Add multiple resources to a collection resource.

Parameters
collectionHandlehandle to the collection resource
addedResourceHandleListreference to list of resource handles to be added to the collection resource
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
bindResources must be used only after the both collection resource and list of resources to add under a collection are created and respective handles obtained.
Example:
  1. registerResource(homeResourceHandle, "a/home", "home", Link_Interface, homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  2. registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  3. registerResource(roomResourceHandle, "a/room", "room", Link_Interface, roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  4. std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle); rList.push_back(roomResourceHandle);
  5. bindResource(homeResourceHandle, rList);
At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and "a/room"
OCStackResult OC::OCPlatform::bindTypeToResource ( const OCResourceHandle resourceHandle,
const std::string &  resourceTypeName 
)

Binds a type to a particular resource.

Parameters
resourceHandlehandle to the resource
resourceTypeNamenew typename to bind to the resource
Returns
Returns OC_STACK_OK if success.
void OC::OCPlatform::Configure ( const PlatformConfig &  config)

API for overwriting the default configuration of the OCPlatform object.

Note
Any calls made to this AFTER the first call to OCPlatform::Instance will have no affect
OCResource::Ptr OC::OCPlatform::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 the object in advance.

Note that the consumer of this method needs to provide all of the details required to correctly contact and observe the object. If the consumer lacks any of this information, they should discover the resource object normally. Additionally, you can only create this object if OCPlatform was initialized to be a Client or Client/Server. Otherwise, this will return an empty shared ptr.

Parameters
hosta string containing a resolvable "coap(s)", "coap(s)+protocol" uri scheme of the server holding the resource. Currently this should be in the format coap(s)://address:port or coap(s)+protocol://address:port, though in the future, we expect this to change to //address:port
urithe rest of the resource's URI that will permit messages to be properly routed. Example: /a/light
connectivityTypeOCConnectivityType type of connectivity indicating the transport method and IP address scope. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP. if you want to use a specific Flag like IPv4, you should apply OR operation for the flag in here. Example: static_cast<OCConnectivityType>(CT_ADAPTER_TCP | OC_IP_USE_V4)
isObservablea boolean containing whether the resource supports observation
resourceTypesa collection of resource types implemented by the resource
interfacesa collection of interfaces that the resource supports/implements
Returns
OCResource::Ptr a shared pointer to the new resource object
OCStackResult OC::OCPlatform::findResource ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindCallback  resourceHandler 
)

API for Service and Resource Discovery.

Note
This API applies to client side only.
Parameters
hostHost IP Address of a service to direct resource discovery query. If null or empty, performs multicast resource discovery query
resourceURIname of the resource. If null or empty, performs search for all resource names
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
resourceHandlerHandles callbacks, success states and failure states.
   Four modes of discovery defined as follows:
   (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
      discovery.
   (NULL/Empty, Not Empty) - Performs query for a filtered/scoped/particular
                              resource(s) from ALL services.
   (Not Empty, NULL/Empty) - Performs ALL resource discovery on a particular service.
   (Not Empty, Not Empty) - Performs query for a filtered/scoped/particular
                              resource(s)
                             from a particular service.
Returns
Returns OC_STACK_OK if success.
Note
First parameter 'host' currently represents an IP address. This will change in future and will refer to endpoint interface so that we can refer to other transports such as BTH etc.
OCStackResult is defined in ocstack.h.
See Also
findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback, QualityOfService)
Note
To get the tcpPort information, user must call getAllHosts() from the OCResource object in FindCallback. To use a TCP endpoint that has been received by getAllHosts(), user must use the setHost() function.
OCStackResult OC::OCPlatform::findResource ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindCallback  resourceHandler,
QualityOfService  QoS 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
hostHost IP Address of a service to direct resource discovery query. If null or empty, performs multicast resource discovery query
resourceURIname of the resource. If null or empty, performs search for all resource names
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
resourceHandlerHandles callbacks, success states and failure states.
   Four modes of discovery defined as follows:
   (NULL/Empty, NULL/Empty) - Performs ALL service discovery AND ALL resource
      discovery.
   (NULL/Empty, Not Empty) - Performs query for a filtered/scoped/particular
                              resource(s) from ALL services.
   (Not Empty, NULL/Empty) - Performs ALL resource discovery on a particular service.
   (Not Empty, Not Empty) - Performs query for a filtered/scoped/particular
                              resource(s)
                             from a particular service.
QoSQualityOfService the quality of communication
See Also
findResource(const std::string&, const std::string&, OCConnectivityType, FindCallback)
Note
To get the tcpPort information, user must call getAllHosts() from the OCResource object in FindCallback. To use a TCP endpoint that has been received by getAllHosts(), user must use the setHost() function.
OCStackResult OC::OCPlatform::findResource ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindCallback  resourceHandler,
FindErrorCallback  errorHandler 
)
OCStackResult OC::OCPlatform::findResource ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindCallback  resourceHandler,
FindErrorCallback  errorHandler,
QualityOfService  QoS 
)
OCStackResult OC::OCPlatform::findResourceList ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindResListCallback  resourceHandler,
QualityOfService  QoS = QualityOfService::LowQos 
)
OCStackResult OC::OCPlatform::findResourceList ( const std::string &  host,
const std::string &  resourceURI,
OCConnectivityType  connectivityType,
FindResListCallback  resourceHandler,
FindErrorCallback  errorHandler,
QualityOfService  QoS = QualityOfService::LowQos 
)
OCStackResult OC::OCPlatform::getDeviceId ( OCUUIdentity deviceId)

gets the deviceId of the client

Parameters
deviceIdpointer.
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::getDeviceInfo ( const std::string &  host,
const std::string &  deviceURI,
OCConnectivityType  connectivityType,
FindDeviceCallback  deviceInfoHandler 
)

API for Device Discovery.

Parameters
hostHost IP Address. If null or empty, Multicast is performed.
deviceURIUri containing address to the virtual device in C Stack ("/oic/d")
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
deviceInfoHandlerdevice discovery callback
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
See Also
getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback, QualityOfService)
OCStackResult OC::OCPlatform::getDeviceInfo ( const std::string &  host,
const std::string &  deviceURI,
OCConnectivityType  connectivityType,
FindDeviceCallback  deviceInfoHandler,
QualityOfService  QoS 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
hostHost IP Address. If null or empty, Multicast is performed.
deviceURIUri containing address to the virtual device in C Stack ("/oic/d")
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
deviceInfoHandlerdevice discovery callback
QoSthe quality of communication
See Also
getDeviceInfo(const std::string&, const std::string&, OCConnectivityType, FindDeviceCallback)
OCStackResult OC::OCPlatform::getPlatformInfo ( const std::string &  host,
const std::string &  platformURI,
OCConnectivityType  connectivityType,
FindPlatformCallback  platformInfoHandler 
)

API for Platform Discovery.

Parameters
hostHost IP Address. If null or empty, Multicast is performed.
platformURIUri containing address to the virtual platform in C Stack ("/oic/p")
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
platformInfoHandlerplatform discovery callback
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
See Also
getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback, QualityOfService)
OCStackResult OC::OCPlatform::getPlatformInfo ( const std::string &  host,
const std::string &  platformURI,
OCConnectivityType  connectivityType,
FindPlatformCallback  platformInfoHandler,
QualityOfService  QoS 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
hostHost IP Address. If null or empty, Multicast is performed.
platformURIUri containing address to the virtual platform in C Stack ("/oic/p")
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
platformInfoHandlerplatform discovery callback
QoSthe quality of communication
See Also
getPlatformInfo(const std::string&, const std::string&, OCConnectivityType, FindPlatformCallback)
OCStackResult OC::OCPlatform::getPropertyValue ( OCPayloadType  type,
const std::string &  tag,
std::string &  value 
)
OCStackResult OC::OCPlatform::getPropertyValue ( OCPayloadType  type,
const std::string &  tag,
std::vector< std::string > &  value 
)
OCStackResult OC::OCPlatform::getSupportedTransportsInfo ( OCTpsSchemeFlags supportedTps)

This function returns flags of supported endpoint TPS on stack.

Parameters
[out]supportedTpsBit combinations of supported OCTpsSchemeFlags.
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::notifyAllObservers ( OCResourceHandle  resourceHandle)

API for notifying base that resource's attributes have changed.

Parameters
resourceHandleresource handle of the resource
Returns
Returns OC_STACK_OK if success.
Note
This API is for server side only.
OCResourceHandle is defined in ocstack.h
OCStackResult is defined in ocstack.h.
See Also
notifyAllObservers(OCResourceHandle, QualityOfService)
OCStackResult OC::OCPlatform::notifyAllObservers ( OCResourceHandle  resourceHandle,
QualityOfService  QoS 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
resourceHandleresource handle of the resource
QoSthe quality of communication
See Also
notifyAllObservers(OCResourceHandle)
OCStackResult OC::OCPlatform::notifyListOfObservers ( OCResourceHandle  resourceHandle,
ObservationIds &  observationIds,
const std::shared_ptr< OCResourceResponse >  responsePtr 
)

API for notifying only specific clients that resource's attributes have changed.

Parameters
resourceHandleresource handle of the resource
observationIdsstd vector of observationIds. These set of ids are ones which which will be notified upon resource change.
responsePtrOCResourceResponse pointer used by app to fill the response for this resource change.
Returns
Returns OC_STACK_OK if success.
Note
This API is for server side only.
OCResourceHandle is defined in ocstack.h.
OCStackResult is defined in ocstack.h.
See Also
notifyListOfObservers(OCResourceHandle, ObservationIds&, const std::shared_ptr<OCResourceResponse>, QualityOfService)
OCStackResult OC::OCPlatform::notifyListOfObservers ( OCResourceHandle  resourceHandle,
ObservationIds &  observationIds,
const std::shared_ptr< OCResourceResponse >  responsePtr,
QualityOfService  QoS 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
resourceHandleresource handle of the resource
observationIdsstd vector of observationIds. These set of ids are ones which which will be notified upon resource change.
responsePtrOCResourceResponse pointer used by app to fill the response for this resource change.
QoSthe quality of communication
See Also
notifyListOfObservers(OCResourceHandle, ObservationIds&, const std::shared_ptr<OCResourceResponse>)
OCStackResult OC::OCPlatform::registerDeviceInfo ( const OCDeviceInfo  deviceInfo)

Register Device Info.

Deprecated:
: Use setPropertyValue instead.
Parameters
deviceInfostructure containing all the device specific information
Returns
Returns OC_STACK_OK if no errors and OC_STACK_ERROR in case of stack process error
OCStackResult OC::OCPlatform::registerPlatformInfo ( const OCPlatformInfo  platformInfo)

Register Platform Info.

Parameters
platformInfostructure containing all the platform specific information
Returns
Returns OC_STACK_OK if no errors and OC_STACK_ERROR in case of stack process error
OCStackResult OC::OCPlatform::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.

Note
This API applies to server side only.
Parameters
resourceHandleUpon successful registration, resourceHandle will be filled
resourceURIThe URI of the resource. Example: "a/light". See NOTE below
resourceTypeNameThe resource type. Example: "core.light"
resourceInterfaceThe resource interface (whether it is collection etc).
entityHandlerentity handler callback.
resourcePropertyindicates the property of the resource. Defined in octypes.h. setting resourceProperty as OC_DISCOVERABLE will allow Discovery of this resource setting resourceProperty as OC_OBSERVABLE will allow observation setting resourceProperty as OC_DISCOVERABLE | OC_OBSERVABLE will allow both discovery and observation
Returns
Returns OC_STACK_OK if success.
Note
"a/light" is a relative reference to URI. Above relative reference to URI will be prepended (by core) with a host IP Therefore, fully qualified URI format would be "CoAP(s)+protocol-URI-Scheme://HostIP-Address/relativeURI" Example, a relative reference to URI: 'a/light' will result in a fully qualified URI: "coap://192.168.1.1:5246/a/light", "coaps://192.168.1.1:5246/a/light"
OCStackResult is defined in octypes.h.
entity handler callback : When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT, OC_EH_SLOW and etc in entity handler callback, ocstack will be not send response automatically to client except for error return value like OC_EH_ERROR If you want to send response to client with specific result, OCDoResponse API should be called with the result value.
OCStackResult OC::OCPlatform::registerResource ( OCResourceHandle resourceHandle,
std::string &  resourceURI,
const std::string &  resourceTypeName,
const std::string &  resourceInterface,
EntityHandler  entityHandler,
uint8_t  resourceProperty,
OCTpsSchemeFlags  resourceTpsTypes 
)

This API registers a resource with the server.

Note
This API applies to server side only.
Parameters
resourceHandleUpon successful registration, resourceHandle will be filled
resourceURIThe URI of the resource. Example: "a/light". See NOTE below
resourceTypeNameThe resource type. Example: "core.light"
resourceInterfaceThe resource interface (whether it is collection etc).
entityHandlerEntity handler callback.
resourcePropertyindicates the property of the resource. Defined in octypes.h.
resourceTpsTypesTransport Protocol Suites(TPS) types of resource for open resource to specific transport adapter (e.g., TCP, UDP) with messaging protocol(e.g., COAP, COAPS). Example: "OC_COAP | OC_COAP_TCP" setting resourceProperty as OC_DISCOVERABLE will allow Discovery of this resource setting resourceProperty as OC_OBSERVABLE will allow observation setting resourceProperty as OC_DISCOVERABLE | OC_OBSERVABLE will allow both discovery and observation
Returns
Returns OC_STACK_OK if success.
Note
"a/light" is a relative reference to URI. Above relative reference to URI will be prepended (by core) with a host IP Therefore, fully qualified URI format would be "CoAP(s)+protocol-URI-Scheme://HostIP-Address/relativeURI" Example, a relative reference to URI: 'a/light' will result in a fully qualified URI: "coap://192.168.1.1:5246/a/light", "coaps://192.168.1.1:5246/a/light"
OCStackResult is defined in octypes.h.
entity handler callback : When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT, OC_EH_SLOW and etc in entity handler callback, ocstack will be not send response automatically to client except for error return value like OC_EH_ERROR If you want to send response to client with specific result, OCDoResponse API should be called with the result value.
OCStackResult OC::OCPlatform::registerResource ( OCResourceHandle resourceHandle,
const std::shared_ptr< OCResource >  resource 
)

This API registers a resource with the server.

Note
This API applies to server & client side.
Parameters
resourceHandleUpon successful registration, resourceHandle will be filled
resourceThe instance of OCResource that all data filled.
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
OCStackResult OC::OCPlatform::sendResponse ( const std::shared_ptr< OCResourceResponse >  pResponse)

Allows application entity handler to send response to an incoming request.

Parameters
pResponseOCResourceResponse pointer that will permit to set values related to resource response.
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::setDefaultDeviceEntityHandler ( EntityHandler  entityHandler)

Set default device entity handler.

Parameters
entityHandlerentity handler to handle requests for any undefined resources or default actions. if NULL is passed it removes the device default entity handler.
Returns
Returns OC_STACK_OK if no errors and OC_STACK_ERROR in case of stack process error
Note
entity handler callback : When you set specific return value like OC_EH_CHANGED, OC_EH_CONTENT, OC_EH_SLOW and etc in entity handler callback, ocstack will be not send response automatically to client except for error return value like OC_EH_ERROR If you want to send response to client with specific result, sendResponse API should be called with the result value.
OCStackResult OC::OCPlatform::setDeviceId ( const OCUUIdentity deviceId)

sets the deviceId of the client

Parameters
deviceIdpointer.
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::setPropertyValue ( OCPayloadType  type,
const std::string &  tag,
const std::string &  value 
)
OCStackResult OC::OCPlatform::setPropertyValue ( OCPayloadType  type,
const std::string &  tag,
const std::vector< std::string > &  value 
)
OCStackResult OC::OCPlatform::start ( )

API for start Base layer including resource and connectivity abstraction.

OCInit will be invoked. The API is reference counted. The calls to start and stop need to be balanced.

Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::startPresence ( const unsigned int  ttl)

Start Presence announcements.

Parameters
ttltime to live
If ttl is '0', then the default stack value will be used (60 Seconds). If ttl is greater than OC_MAX_PRESENCE_TTL_SECONDS, then the ttl will be set to OC_MAX_PRESENCE_TTL_SECONDS.
Returns
Returns OC_STACK_OK if success.

Server can call this function when it comes online for the first time, or when it comes back online from offline mode, or when it re enters network.

OCStackResult OC::OCPlatform::stop ( )

API for stop Base layer including resource and connectivity abstraction.

The API is reference counted. The calls to start and stop need to be balanced.

Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::stopPresence ( )

Stop Presence announcements.

Returns
Returns OC_STACK_OK if success.

Server can call this function when it is terminating, going offline, or when going away from network.

OCStackResult OC::OCPlatform::subscribePresence ( OCPresenceHandle &  presenceHandle,
const std::string &  host,
OCConnectivityType  connectivityType,
SubscribeCallback  presenceHandler 
)

subscribes to a server's presence change events.

By making this subscription, every time a server adds/removes/alters a resource, starts or is intentionally stopped (potentially more to be added later).

Parameters
presenceHandlea handle object that can be used to identify this subscription request. It can be used to unsubscribe from these events in the future. It will be set upon successful return of this method.
hostThe IP address/addressable name of the server to subscribe to. This should be in the format coap://address:port If empty, the multicast subscribe presence is performed.
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
presenceHandlercallback function that will receive notifications/subscription events
Returns
Returns OC_STACK_OK if success.
OCStackResult OC::OCPlatform::subscribePresence ( OCPresenceHandle &  presenceHandle,
const std::string &  host,
const std::string &  resourceType,
OCConnectivityType  connectivityType,
SubscribeCallback  presenceHandler 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.subscribes to a server's presence change events.

By making this subscription, every time a server adds/removes/alters a resource, starts or is intentionally stopped (potentially more to be added later).

Parameters
presenceHandlea handle object that can be used to identify this subscription request. It can be used to unsubscribe from these events in the future. It will be set upon successful return of this method.
hostThe IP address/addressable name of the server to subscribe to. This should be in the format coap://address:port If empty, the multicast subscribe presence is performed.
resourceTypea resource type specified as a filter for subscription callbacks.
connectivityTypeOCConnectivityType type of connectivity indicating the interface. Example: CT_DEFAULT, CT_ADAPTER_IP, CT_ADAPTER_TCP.
presenceHandlercallback function that will receive notifications/subscription events
See Also
subscribePresence(OCPresenceHandle&, const std::string&, OCConnectivityType, SubscribeCallback)
OCStackResult OC::OCPlatform::unbindResource ( const OCResourceHandle  collectionHandle,
const OCResourceHandle  resourceHandle 
)

Unbind a resource from a collection resource.

Parameters
collectionHandlehandle to the collection resource
resourceHandleresource handle to be unbound from the collection resource
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
unbindResource must be used only after the both collection resource and resource to unbind from a collection are created and respective handles obtained
Example:
  1. registerResource(homeResourceHandle, "a/home", "home", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  2. registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  3. bindResource(homeResourceHandle, kitchenResourceHandle);
  4. unbindResource(homeResourceHandle, kitchenResourceHandle);
At the end of Step 4, resource "a/home" will no longer reference "a/kitchen".
OCStackResult OC::OCPlatform::unbindResources ( const OCResourceHandle  collectionHandle,
const std::vector< OCResourceHandle > &  resourceHandleList 
)

Unbind resources from a collection resource.

Parameters
collectionHandlehandle to the collection resource
resourceHandleListList of resource handles to be unbound from the collection resource
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
unbindResources must be used only after the both collection resource and list of resources resource to unbind from a collection are created and respective handles obtained.
Example:
  1. registerResource(homeResourceHandle, "a/home", "home", Link_Interface, homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  2. registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  3. registerResource(roomResourceHandle, "a/room", "room", Link_Interface, roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);
  4. std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle); rList.push_back(roomResourceHandle);
  5. bindResource(homeResourceHandle, rList);
  6. unbindResources(homeResourceHandle, rList);
At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and "a/room"
OCStackResult OC::OCPlatform::unregisterResource ( const OCResourceHandle resourceHandle)

This API unregisters a resource with the server.

Note
This API applies to server side only.
Parameters
resourceHandleThis is the resource handle which we need to unregister from the server
Returns
Returns OC_STACK_OK if success.
Note
OCStackResult is defined in ocstack.h.
OCStackResult OC::OCPlatform::unsubscribePresence ( OCPresenceHandle  presenceHandle)

unsubscribes from a previously subscribed server's presence events.

Note that you may for a short time still receive events from the server since it may take time for the unsubscribe to take effect.

Parameters
presenceHandlethe handle object provided by the subscribePresence call that identifies this subscription.
Returns
Returns OC_STACK_OK if success.