C stack external header files were missing support for doxygen documentation.
Modified comments, spelling, definitions, alignment and terminology.
Change-Id: Ic777555324c45fe5e9fcd421eac20fc418fe10cc
Signed-off-by: Moumita Ray <moumita.ray@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1431
Reviewed-by: Joseph Morrow <joseph.l.morrow@intel.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
Tested-by: Jon A. Cruz <jonc@osg.samsung.com>
-//******************************************************************
-//
-// Copyright 2014 Intel Corporation All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ //*******************************************************************
+ //
+ // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+ //
+ //
+ //
+ // Licensed under the Apache License, Version 2.0 (the "License");
+ // you may not use this file except in compliance with the License.
+ // You may obtain a copy of the License at
+ //
+ // http://www.apache.org/licenses/LICENSE-2.0
+ //
+ // Unless required by applicable law or agreed to in writing, software
+ // distributed under the License is distributed on an "AS IS" BASIS,
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // See the License for the specific language governing permissions and
+ // limitations under the License.
+ //
+ //
+ //******************************************************************
+/**
+ * @file
+ *
+ * This file contains all the constants which can be configured/modified as
+ * per platform or security specific product usage scenarios.
+ */
+
#ifndef OC_SECURITY_CONFIG_H
#define OC_SECURITY_CONFIG_H
-/* ****************************************************************
- *
- * Copyright 2014 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************/
+//* ****************************************************************
+//
+// Copyright 2014 Samsung Electronics All Rights Reserved.
+//
+//
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//******************************************************************/
/**
* @file
-//******************************************************************
+//*******************************************************************
//
// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
+// ******************************************************************/
+
+
+/**
+ * @file
+ *
+ * This file contains the definition and types for client's callback mode and functions.
+ *
+ */
+
#ifndef OC_CLIENT_CB
#define OC_CLIENT_CB
#include "ocresource.h"
#include "cacommon.h"
+/**
+ * Data structure For presence Discovery.
+ * This is the TTL associated with presence.
+ */
typedef struct OCPresence
{
- // This is the TTL associated with presence
+ /** Time to Live. */
uint32_t TTL;
+
+ /** Time out. */
uint32_t * timeOut;
+
+ /** TTL Level. */
uint32_t TTLlevel;
} OCPresence;
+/**
+ * Data structure to hold Multicast node identity for resource discovery.
+ */
typedef struct OCMulticastNode
{
+ /** URI of new resource.*/
char * uri;
+
+ /** URI of new resource that entity handler might create.*/
uint32_t nonce;
+
+ /** Linked list; for multicast nodes.*/
struct OCMulticastNode * next;
} OCMulticastNode;
+/**
+ * Forward declaration of resource type.
+ */
typedef struct resourcetype_t OCResourceType;
+
+/**
+ * Data structure for holding client's callback context, methods and Time to Live,
+ * connectivity Types, presence and resource type, request uri etc.
+ */
+
typedef struct ClientCB {
- // callback method defined in application address space
+ /** callback method defined in application address space. */
OCClientResponseHandler callBack;
- // callback context data
+
+ /** callback context data. */
void * context;
- // callback method to delete context data
+
+ /** callback method to delete context data. */
OCClientContextDeleter deleteCallback;
- // when a response is recvd with this token, above callback will be invoked
+
+ /** when a response is recvd with this token, above callback will be invoked. */
CAToken_t token;
- // a response is recvd with this token length
+
+ /** a response is recvd with this token length.*/
uint8_t tokenLength;
- // Invocation handle tied to original call to OCDoResource()
+
+ /** Invocation handle tied to original call to OCDoResource().*/
OCDoHandle handle;
- // This is used to determine if all responses should be consumed or not.
- // (For now, only pertains to OC_REST_OBSERVE_ALL Vs. OC_REST_OBSERVE functionality)
+
+ /** This is used to determine if all responses should be consumed or not.
+ * (For now, only pertains to OC_REST_OBSERVE_ALL vs. OC_REST_OBSERVE functionality).*/
OCMethod method;
- // This is the sequence identifier the server applies to the invocation tied to 'handle'.
+
+ /** This is the sequence identifier the server applies to the invocation tied to 'handle'.*/
uint32_t sequenceNumber;
- // The canonical form of the request uri associated with the call back
+
+ /** The canonical form of the request uri associated with the call back.*/
char * requestUri;
- // Remote address complete
+
+ /** Remote address complete.*/
OCDevAddr * devAddr;
- // Struct to hold TTL info for presence
+
+ /** Struct to hold TTL info for presence.*/
+
#ifdef WITH_PRESENCE
OCPresence * presence;
OCResourceType * filterResourceType;
#endif
- // The connectivity type on which the request was sent on.
+
+ /** The connectivity type on which the request was sent on.*/
OCConnectivityType conType;
- // The TTL for this callback. Holds the time till when this callback can
- // still be used. TTL is set to 0 when the callback is for presence and observe.
- // Presence has ttl mechanism in the "presence" member of this struct and observes
- // can be explicitly cancelled.
+
+ /** The TTL for this callback. Holds the time till when this callback can
+ * still be used. TTL is set to 0 when the callback is for presence and observe.
+ * Presence has ttl mechanism in the "presence" member of this struct and observes
+ * can be explicitly cancelled.*/
uint32_t TTL;
- // next node in this list
+
+ /** next node in this list.*/
struct ClientCB *next;
} ClientCB;
+/**
+ * Linked list of ClientCB node.
+ */
extern struct ClientCB *cbList;
/** @ingroup ocstack
*
* This method is used to add a client callback method in cbList.
*
- * @param[out] clientCB
- * The resulting node from making this call. Null if out of memory.
- * @param[in] cbData
- * address to client callback function.
- * @param[in] token
- * identifier for OTA CoAP comms.
- * @param[in] handle
- * Masked in the public API as an 'invocation handle' - Used for callback management.
- * @param[in] method
- * OCMethod via which this client callback is expected to operate
- * @param[in] requestUri
- * the resource uri of the request.
- * @param[in] resourceType
- * the resourceType associated with a presence request.
- * @param[in] conType
- * the connectivity type on which the associated request for this clientCB was sent on.
- * @param[in] ttl
- * time to live in coap_ticks for the callback.
- * @brief If the handle you're looking for does not exist, the stack will reply with a RST message.
- *
- * @return OC_STACK_OK for Success, otherwise some error value
+ * @param[out] clientCB The resulting node from making this call. Null if out of memory.
+ * @param[in] cbData Address to client callback function.
+ * @param[in] token Identifier for OTA CoAP comms.
+ * @param[in] tokenLength Length for OTA CoAP comms.
+ * @param[in] handle masked in the public API as an 'invocation handle'
+ * Used for callback management.
+ * @param[in] method A method via which this client callback is expected to operate
+ * @param[in] devAddr The Device address.
+ * @param[in] requestUri The resource uri of the request.
+ * @param[in] resourceTypeName The resource type associated with a presence request.
+ * @param[in] ttl time to live in coap_ticks for the callback.
+ *
+ * @note If the handle you're looking for does not exist, the stack will reply with a RST message.
+ *
+ * @return OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult
AddClientCB (ClientCB** clientCB, OCCallbackData* cbData,
*
* This method is used to remove a callback node from cbList.
*
- * @param[in] cbNode
- * address to client callback node.
+ * @param[in] cbNode Address to client callback node.
*/
void DeleteClientCB(ClientCB *cbNode);
*
* This method is used to search and retrieve a cb node in cbList.
*
- * @param[in] token
- * token to search for.
- * @param[in] handle
- * handle to search for.
- * @param[in] requestUri
- * Uri to search for.
+ * @param[in] token Token to search for.
+ * @param[in] tokenLength The Length of the token.
+ * @param[in] handle Handle to search for.
+ * @param[in] requestUri Uri to search for.
*
* @brief You can search by token OR by handle, but not both.
*
ClientCB* GetClientCB(const CAToken_t token, uint8_t tokenLength,
OCDoHandle handle, const char * requestUri);
+#ifdef WITH_PRESENCE
/**
* Inserts a new resource type filter into this cb node.
*
- * @param[in] cbNode
- * the node to add the new resourceType filter to
- * @param[in] resourceTypeName
- * the value to create the new resourceType filter from
+ * @param[in] cbNode the node to add the new resourceType filter to.
+ * @param[in] resourceTypeName the value to create the new resourceType filter from.
*
* @return
* OC_STACK_OK on success
* OC_STACK_ERROR with invalid parameters
* OC_STACK_NO_MEMORY when out of memory
*/
-#ifdef WITH_PRESENCE
+
OCStackResult InsertResourceTypeFilter(ClientCB * cbNode, char * resourceTypeName);
#endif // WITH_PRESENCE
* This method is used to verify the presence of a cb node in cbList
* and then delete it.
*
- * @param[in] cbNode
- * address to client callback node.
+ * @param[in] cbNode Address to client callback node.
*/
void FindAndDeleteClientCB(ClientCB * cbNode);
*
* This method is used to search a multicast presence node from list.
*
- * @param[in] uri
- * the uri of the request.
+ * @param[in] uri the uri of the request.
*
* @return OCMulticastNode
* The resulting node from making this call. Null if doesn't exist.
*/
-//------------------------------------------------------------------------
+
OCMulticastNode* GetMCPresenceNode(const char * uri);
/** @ingroup ocstack
*
* This method is used to add a multicast presence node to the list.
- *
- * @param[out] outnode
- * The resulting node from making this call. Null if out of memory.
- * @param[in] uri
- * the uri of the server.
- * @param[in] nonce
- * current nonce for the server
+ * @param[out] outnode the resulting node from making this call. Null if out of memory.
+ * @param[in] uri the uri of the server.
+ * @param[in] nonce current nonce for the server
*
* @return OC_STACK_OK for Success, otherwise some error value
*/
-//------------------------------------------------------------------------
+
OCStackResult AddMCPresenceNode(OCMulticastNode** outnode, char* uri, uint32_t nonce);
#endif //OC_CLIENT_CB
-//******************************************************************
+//********************************************************************
//
// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
//
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+/**
+ * @file
+ *
+ * This file contains the data structure and APIs for registered resource as an observer.
+ *
+ */
+
+
#ifndef OC_OBSERVE_H
#define OC_OBSERVE_H
-// Sequence number is a 24 bit field, per
-// https://tools.ietf.org/html/draft-ietf-core-observe-16
+/** Sequence number is a 24 bit field, per https://tools.ietf.org/html/draft-ietf-core-observe-16.*/
#define MAX_SEQUENCE_NUMBER (0xFFFFFF)
+/** Maximum number of observers to reach */
+
#define MAX_OBSERVER_FAILED_COMM (2)
+
+/** Maximum number of observers to reach for resources with low QOS */
#define MAX_OBSERVER_NON_COUNT (3)
/**
- * This information is stored for each registered observer.
+ * Data structure to hold informations for each registered observer.
*/
typedef struct ResourceObserver
{
- // Observation Identifier for request
+ /** Observation Identifier for request.*/
OCObservationId observeId;
- // URI of observed resource
+
+ /** URI of observed resource.*/
char *resUri;
- // Query
+
+ /** Query.*/
char *query;
- //token for the observe request
+
+ /** token for the observe request.*/
CAToken_t token;
- //token length for the observe request
+
+ /** token length for the observe request.*/
uint8_t tokenLength;
- // Resource handle
+
+ /** Resource handle.*/
OCResource *resource;
- /** Remote Endpoint **/
+
+ /** Remote Endpoint. */
OCDevAddr devAddr;
- // Quality of service of the request
+
+ /** Quality of service of the request.*/
OCQualityOfService qos;
- // number of times the server failed to reach the observer
+
+ /** number of times the server failed to reach the observer.*/
uint8_t failedCommCount;
- // number of times the server sent NON notifications
+
+ /** number of times the server sent NON notifications.*/
uint8_t lowQosCount;
- // force the qos value to CON
+
+ /** force the qos value to CON.*/
uint8_t forceHighQos;
- // next node in this list
+
+ /** next node in this list.*/
struct ResourceObserver *next;
} ResourceObserver;
/**
* Create an observe response and send to all observers in the observe list.
*
- * @param method RESTful method.
- * @param resPtr Observed resource.
- * @param maxAge Time To Live (in seconds) of observation.
- * @param resourceType Resource type. Allows resource type name to be added to response.
- * @param qos Quality of service of resource.
+ * @param method RESTful method.
+ * @param resPtr Observed resource.
+ * @param maxAge Time To Live (in seconds) of observation.
+ * @param resourceType Resource type. Allows resource type name to be added to response.
+ * @param qos Quality of service of resource.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
* @param resPtr Observed resource.
* @param maxAge Time To Live (in seconds) of observation.
* @param qos Quality of service of resource.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult SendAllObserverNotification (OCMethod method, OCResource *resPtr, uint32_t maxAge,
/**
* Notify specific observers with updated value of representation.
*
- * @param resource Observed resource
- * @param obsIdList List of observation ids that need to be notified.
- * @param numberOfIds Number of observation ids included in obsIdList.
- * @param payload - OCRepresentationPayload object representing the message
- * @param maxAge Time To Live (in seconds) of observation.
- * @param qos Desired quality of service of the observation notifications.
+ * @param resource Observed resource.
+ * @param obsIdList List of observation ids that need to be notified.
+ * @param numberOfIds Number of observation ids included in obsIdList.
+ * @param notificationJSONPayload JSON encoded payload to send in notification.
+ * @param maxAge Time To Live (in seconds) of observation.
+ * @param qos Desired quality of service of the observation notifications.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult SendListObserverNotification (OCResource * resource,
/**
* Create a unique observation ID.
*
- * @param observationId Pointer to generated ID.
+ * @param observationId Pointer to generated ID.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult GenerateObserverId (OCObservationId *observationId);
/**
* Add observer for a resource.
*
- * @param resUri Resource URI string.
- * @param query Query string.
- * @param obsId Observation ID.
- * @param token Request token.
- * @param tokenLength Length of token.
- * @param resHandle Resource handle.
- * @param qos Quality of service of observation.
- * @param observer address
+ * @param resUri Resource URI string.
+ * @param query Query string.
+ * @param obsId Observation ID.
+ * @param token Request token.
+ * @param tokenLength Length of token.
+ * @param resHandle Resource handle.
+ * @param qos Quality of service of observation.
+ * @param devAddr Device address.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult AddObserver (const char *resUri,
/**
* Search the list of observers for the specified token.
*
- * @param token Token to search for.
- * @param tokenLength Length of token.
+ * @param token Token to search for.
+ * @param tokenLength Length of token.
*
* @return Pointer to found observer.
*/
/**
* Search the list of observers for the specified observe ID.
*
- * @param observeId Observer ID to search for
+ * @param observeId Observer ID to search for.
*
* @return Pointer to found observer.
*/
ResourceObserver* GetObserverUsingId (const OCObservationId observeId);
/**
- * Add observe header option to a request.
+ * Add observe header option to a request.
*
- * @param caHdrOpt Target request CA header option.
- * @param ocHdrOpt Pointer to existing options.
- * @param numOptions Number of existing options.
- * @param observeFlag Register/de-register observation. Should be either
- * ::OC_OBSERVE_REGISTER or ::OC_OBSERVE_DEREGISTER.
+ * @param caHdrOpt Target request CA header option.
+ * @param ocHdrOpt Pointer to existing options.
+ * @param numOptions Number of existing options.
+ * @param observeFlag Register/de-register observation. Should be either
+ * ::OC_OBSERVE_REGISTER or ::OC_OBSERVE_DEREGISTER.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
uint8_t observeFlag);
/**
- * Copy the observe option from a received request
+ * Copy the observe option from a received request.
*
- * @param observationOption Pointer to observe option value. Should be either
- * ::OC_OBSERVE_REGISTER, ::OC_OBSERVE_DEREGISTER, or ::OC_OBSERVE_NO_OPTION if observe not found.
+ * @param observationOption Pointer to observe option value. Should be either
+ * ::OC_OBSERVE_REGISTER, ::OC_OBSERVE_DEREGISTER, or
+ * ::OC_OBSERVE_NO_OPTION if observe not found.
*
- * @param options Options in received request. Observe option is removed if found.
- * @param numOptions Number of options in the received request. Decremented if observe option is
- * extracted.
+ * @param options Options in received request. Observe option is removed if found.
+ * @param numOptions Number of options in the received request. Decremented if observe
+ * option is extracted.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+/**
+ * @file
+ *
+ * This file contains the definition, types and interfaces for resource and attributes
+ *
+ */
+
+
#ifndef OCRESOURCE_H_
#define OCRESOURCE_H_
#include "ocstackconfig.h"
#include "occlientcb.h"
+/** Macro Definitions for observers */
+
+/** Observer not interested. */
#define OC_OBSERVER_NOT_INTERESTED (0)
+
+/** Observer still interested. */
#define OC_OBSERVER_STILL_INTERESTED (1)
+
+/** Failed communication. */
#define OC_OBSERVER_FAILED_COMM (2)
-//-----------------------------------------------------------------------------
-// Virtual Resource Presence Attributes
-//-----------------------------------------------------------------------------
+/**
+ *Virtual Resource Presence Attributes
+ */
+
#ifdef WITH_PRESENCE
typedef struct PRESENCERESOURCE{
OCResourceHandle handle;
} PresenceResource;
#endif
-//-----------------------------------------------------------------------------
-// Forward declarations
-//-----------------------------------------------------------------------------
+/**
+ * Forward declarations
+ */
+
struct rsrc_t;
-//-----------------------------------------------------------------------------
-// Typedefs
-//-----------------------------------------------------------------------------
+/**
+ * Typedefs for stack interface
+ * IF here stands for Interface
+ */
-// IF here stands for Interface
typedef enum {
STACK_IF_DEFAULT = 0,
STACK_IF_LL,
STACK_IF_INVALID
} OCStackIfTypes;
-// following structure will be created in occollection.
+/**
+ * following structure will be created in occollection.
+ */
+
typedef struct occapability {
+ /** Linked list; for multiple capabilities.*/
struct occapability* next;
- char *capability; // It is a name about resource capability.
- char *status; // It is mean status of capability.
+ /** It is a name about resource capability. */
+ char *capability;
+
+ /** It is mean status of capability. */
+ char *status;
} OCCapability;
+/**
+ * following structure will be created in occollection.
+ */
-// following structure will be created in occollection.
typedef struct ocaction {
+ /** linked list; for multiple actions. */
struct ocaction *next;
- // Target Uri.
- // It will be used to execute the action.
+ /** Target Uri. It will be used to execute the action. */
char *resourceUri;
+ /** head pointer of a linked list of capability nodes.*/
OCCapability* head;
} OCAction;
-// following structure will be created in occollection.
+/**
+ * following structure will be created in occollection.
+ */
+
typedef struct ocactionset
{
+ /** linked list; for list of action set. */
struct ocactionset *next;
+ /** Name of the action set.*/
char *actionsetName;
+
+ /** Time stamp.*/
long int timesteps;
+
+ /** Type of action.*/
unsigned int type;
+ /** head pointer of a linked list of Actions.*/
OCAction* head;
} OCActionSet;
+/**
+ * Data structure for holding name and data types for each OIC resource.
+ */
typedef struct resourcetype_t {
- struct resourcetype_t *next; // linked list; for multiple types on resource
-
- // Name of the type; this string is ‘.’ (dot) separate list of segments where each segment is a
- // namespace and the final segment is the type; type and sub-types can be separate with
- // ‘-‘ (dash) usually only two segments would be defined. Either way this string is meant to be
- // human friendly and is used opaquely and not parsed by code. This name is used in the “rt=”
- // parameter of a resource description when resources are introspected and is also use in the
- // <base URI>/types list of available types.
+
+ /** linked list; for multiple types on resource. */
+ struct resourcetype_t *next;
+
+ /**
+ * Name of the type; this string is ‘.’ (dot) separate list of segments where each segment is a
+ * namespace and the final segment is the type; type and sub-types can be separate with
+ * ‘-‘ (dash) usually only two segments would be defined. Either way this string is meant to be
+ * human friendly and is used opaquely and not parsed by code. This name is used in the “rt=”
+ * parameter of a resource description when resources are introspected and is also use in the
+ * " <base URI>/types " list of available types.
+ */
char *resourcetypename;
} OCResourceType;
+/**
+ * Data structure for data type and definition for attributes that the resource exposes.
+ */
typedef struct attr_t {
- struct attr_t *next; // Points to next resource in list
- // The name of the attribute; used to look up the attribute in list;
- // for a given attribute SHOULD not be changed once assigned
+ /** Points to next resource in list.*/
+ struct attr_t *next;
+
+ /** The name of the attribute; used to look up the attribute in list.
+ * for a given attribute SHOULD not be changed once assigned.
+ */
const char *attrName;
- char *attrValue; // value of the attribute as string
+
+ /** value of the attribute as string.*/
+ char *attrValue;
} OCAttribute;
+/**
+ * Data structure for holding a resource interface
+ */
typedef struct resourceinterface_t {
- struct resourceinterface_t *next; // linked list; for multiple interfaces on resource
- // Name of the interface; this is ‘.’ (dot) separate list of segments where each segment is a
- // namespace and the final segment is the interface; usually only two segments would be
- // defined. Either way this string is opaque and not parsed by segment
+ /** linked list; for multiple interfaces on resource.*/
+ struct resourceinterface_t *next;
+
+ /** Name of the interface; this is ‘.’ (dot) separate list of segments where each segment is a
+ * namespace and the final segment is the interface; usually only two segments would be
+ * defined. Either way this string is opaque and not parsed by segment.*/
char *name ;
- // Supported content types to serialize request and response on this interface
- // (REMOVE for V1 – only jSON for all but core.ll that uses Link Format)
+ /** Supported content types to serialize request and response on this interface
+ * (REMOVE for V1 – only jSON for all but core.ll that uses Link Format)*/
#if 0
char *inputContentType ;
char *outputContentType ;
#endif
- /*** Future placeholder for access control and policy ***/
+ /** Future placeholder for access control and policy.*/
} OCResourceInterface;
+
+/**
+ * Data structure for holding data type and definition for OIC resource.
+ */
typedef struct OCResource {
- struct OCResource *next; // Points to next resource in list
- // Relative path on the device; will be combined with base url to create fully qualified path
+
+ /** Points to next resource in list.*/
+ struct rsrc_t *next;
+
+ /** Relative path on the device; will be combined with base url to create fully qualified path.*/
char *uri;
- OCResourceType *rsrcType; // Resource type(s); linked list
- OCResourceInterface *rsrcInterface; // Resource interface(s); linked list
- OCAttribute *rsrcAttributes; // Resource interface(s); linked list
- // Array of pointers to resources; can be used to represent a container of resources
- // (i.e. hierarchies of resources) or for reference resources (i.e. for a resource collection)
- struct OCResource *rsrcResources[MAX_CONTAINED_RESOURCES];
- //struct rsrc_t *rsrcResources;
- // Pointer to function that handles the entity bound to the resource.
- // This handler has to be explicitly defined by the programmer
+
+ /** Resource type(s); linked list.*/
+ OCResourceType *rsrcType;
+
+ /** Resource interface(s); linked list.*/
+ OCResourceInterface *rsrcInterface;
+
+ /** Resource interface(s); linked list.*/
+ OCAttribute *rsrcAttributes;
+
+ /** Array of pointers to resources; can be used to represent a container of resources.
+ * (i.e. hierarchies of resources) or for reference resources (i.e. for a resource collection).*/
+
+ struct rsrc_t *rsrcResources[MAX_CONTAINED_RESOURCES];
+
+ /** Pointer to function that handles the entity bound to the resource.
+ * This handler has to be explicitly defined by the programmer.*/
OCEntityHandler entityHandler;
- // callback parameter
+
+ /** Callback parameter.*/
void * entityHandlerCallbackParam;
- // Properties on the resource – defines meta information on the resource
- OCResourceProperty resourceProperties ; /* ACTIVE, DISCOVERABLE etc */
- // NOTE: Methods supported by this resource should be based on the interface targeted
- // i.e. look into the interface structure based on the query request Can be removed here;
- // place holder for the note above
+
+ /** Properties on the resource – defines meta information on the resource.
+ * (ACTIVE, DISCOVERABLE etc ). */
+
+ OCResourceProperty resourceProperties ;
+
+ /* @note: Methods supported by this resource should be based on the interface targeted
+ * i.e. look into the interface structure based on the query request Can be removed here;
+ * place holder for the note above.*/
/* method_t methods; */
- // Sequence number for observable resources. Per the CoAP standard it is a 24 bit value.
+
+
+ /** Sequence number for observable resources. Per the CoAP standard it is a 24 bit value.*/
uint32_t sequenceNum;
- // Pointer of ActionSet which to support group action.
+
+ /** Pointer of ActionSet which to support group action.*/
OCActionSet *actionsetHead;
} OCResource;
#define OC_RESOURCE_SECURE 1
/**
- * OIC Virtual resources supported by every OIC device.
+ * OIC Virtual resources supported by every OIC device.
*/
typedef enum
{
+ /** unknown URI.*/
OC_UNKNOWN_URI =0,
- OC_WELL_KNOWN_URI, ///< "/oic/res"
- OC_DEVICE_URI, ///< "/oic/d"
- OC_PLATFORM_URI, ///< "/oic/p"
- OC_RESOURCE_TYPES_URI, ///< "/oic/res/types/d"
-#ifdef WITH_PRESENCE
- OC_PRESENCE, ///< "/oic/ad"
-#endif
+
+ /** "/oic/res".*/
+ OC_WELL_KNOWN_URI,
+
+ /** "/oic/d" .*/
+ OC_DEVICE_URI,
+
+ /** "/oic/p" .*/
+ OC_PLATFORM_URI,
+
+ /** "/oic/res/d/type" .*/
+ OC_RESOURCE_TYPES_URI,
+
+ #ifdef WITH_PRESENCE
+ /** "/oic/ad" .*/
+ OC_PRESENCE,
+ #endif
+
+ /** Max items in the list */
+ OC_MAX_VIRTUAL_RESOURCES //<s Max items in the list
} OCVirtualResources;
/**
/**
* Find and retrieve pointer to a resource associated with a specific resource
* URI.
+ * @return pointer to found resource
*/
OCResource *FindResourceByUri(const char* resourceUri);
/**
- * Returns true if the specificed resource URI aligns with a pre-existing
+ * This function checks whether the specified resource URI aligns with a pre-existing
* virtual resource; returns false otherwise.
+ * @return true or false.
*/
bool IsVirtualResource(const char* resourceUri);
/**
* Parameter @ref handling returns by-reference the type of resource handling
* required by the internal stack based on the specified @ref request.
+ * @return ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult DetermineResourceHandling (const OCServerRequest *request,
ResourceHandling *handling,
/**
* Processes the specified @ref request based on the type of resource handling
* @ref resHandling.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult ProcessRequest(ResourceHandling resHandling,
OCResource *resource,
/**
* Internal API used to save all of the platform's information for use in platform
* discovery requests.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult SavePlatformInfo(OCPlatformInfo info);
/**
* Internal API used to save all of the device's information for use in platform
* discovery requests.
- * The device name is received from the appliation.
- * The deviceID, spec version and data model verson are initialized by the stack.
+ * @param info Device name is received from the application.
+ * DeviceID, spec version and data model version are initialized by the stack.
+ * @return ::OC_STACK_OK for Success, otherwise some error value.
*/
OCStackResult SaveDeviceInfo(OCDeviceInfo info);
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+/**
+ * @file
+ *
+ * This file contains the definition, types and interfaces for server request
+ *
+ */
+
#ifndef OC_SERVER_REQUEST_H
#define OC_SERVER_REQUEST_H
#include "cacommon.h"
#include "cainterface.h"
+
/**
* The signature of the internal call back functions to handle responses from entity handler
*/
typedef OCStackResult (* OCEHResponseHandler)(OCEntityHandlerResponse * ehResponse);
-// following structure will be created in occoap and passed up the stack on the server side
+/**
+ * following structure will be created in occoap and passed up the stack on the server side.
+ */
typedef struct OCServerRequest
{
- // the REST method retrieved from received request PDU
+ /** The REST method retrieved from received request PDU.*/
OCMethod method;
- // resourceUrl will be filled in occoap using the path options in received request PDU
+
+ /** resourceUrl will be filled in occoap using the path options in received request PDU.*/
char resourceUrl[MAX_URI_LENGTH];
- // resource query send by client
+
+ /** resource query send by client.*/
char query[MAX_QUERY_LENGTH];
- // qos is indicating if the request is CON or NON
+ /** qos is indicating if the request is CON or NON.*/
OCQualityOfService qos;
- // Observe option field
+
+ /** Observe option field.*/
+
uint32_t observationOption;
+
+ /** Observe Result field.*/
OCStackResult observeResult;
+
+ /** number of Responses.*/
uint8_t numResponses;
+
+ /** Response Entity Handler .*/
OCEHResponseHandler ehResponseHandler;
+
/** Remote endpoint address **/
OCDevAddr devAddr;
- // token for the request
+
+ /** Token for the request.*/
CAToken_t requestToken;
- // token length the request
+
+ /** token length the request.*/
uint8_t tokenLength;
- // The ID of CoAP pdu //Kept in
- uint16_t coapID; //CoAP
+
+ /** The ID of CoAP pdu (Kept in CoAp).*/
+ uint16_t coapID;
+
+ /** For Delayed Response.*/
uint8_t delayedResNeeded;
- //////////////////////////////////////////////////////////
- // An array of the received vendor specific header options
+
+ /** Number of vendor specific header options.*/
uint8_t numRcvdVendorSpecificHeaderOptions;
+
+ /** An Array of received vendor specific header options.*/
OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
+
+ /** Request to complete.*/
uint8_t requestComplete;
+
+ /** Linked list; for multiple server request.*/
struct OCServerRequest * next;
- // Flag indicating slow response
+
+ /** Flag indicating slow response.*/
uint8_t slowFlag;
+
+ /** Flag indicating notification.*/
uint8_t notificationFlag;
+
+ /** Payload Size.*/
size_t payloadSize;
- // payload is retrieved from the payload of the received request PDU
+
+ /** payload is retrieved from the payload of the received request PDU.*/
uint8_t payload[1];
+
} OCServerRequest;
-// following structure will be created in ocstack to aggregate responses (in future: for block transfer)
+/**
+ * Following structure will be created in ocstack to aggregate responses
+ * (in future: for block transfer).
+ */
typedef struct OCServerResponse {
+
+ /** Linked list; for multiple server response.*/
struct OCServerResponse * next;
- // this is the pointer to server payload data to be transferred
+
+ /** this is the pointer to server payload data to be transferred.*/
OCPayload* payload;
+
+ /** Remaining size of the payload data to be transferred.*/
+ uint16_t remainingPayloadSize;
+
+ /** Requests to handle.*/
OCRequestHandle requestHandle;
} OCServerResponse;
/**
* Handler function for sending a response from a single resource
*
- * @param ehResponse - pointer to the response from the resource
+ * @param ehResponse Pointer to the response from the resource.
*
* @return
- * OCStackResult
+ * ::OCStackResult
*/
OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse);
*
* TODO: Need to add a timeout in case a (remote?) resource does not respond
*
- * @param ehResponse - pointer to the response from the resource
+ * @param ehResponse Pointer to the response from the resource.
*
* @return
- * OCStackResult
+ * ::OCStackResult
*/
OCStackResult HandleAggregateResponse(OCEntityHandlerResponse * ehResponse);
/**
* Get a server request from the server request list using the specified token.
*
- * @param token - token of server request
- * @param tokenLength - length of token
+ * @param token Token of server request.
+ * @param tokenLength Length of token.
*
* @return
* OCServerRequest*
/**
* Get a server request from the server request list using the specified handle
*
- * @param handle - handle of server request
+ * @param handle Handle of server request.
* @return
* OCServerRequest*
*/
/**
* Get a server response from the server response list using the specified handle
*
- * @param handle - handle of server response
+ * @param handle handle of server response.
*
* @return
* OCServerResponse*
/**
* Add a server request to the server request list
*
- * @param request - initialized server request that is created by this function
- * @param coapID - ID of CoAP pdu
- * @param delayedResNeeded - delayed response required 0=no 1=yes
- * @param secured - secure endpoint 0=no 1=yes
- * @param notificationFlag - //TODO: remove - does not appear to be used any longer
- * @param method - RESTful method
- * @param numRcvdVendorSpecificHeaderOptions - number of received vendor specific header options
- * @param observationOption - value of observation option
- * @param qos - request QOS
- * @param query - request query
- * @param rcvdVendorSpecificHeaderOptions - received vendor specific header options
- * @param reqJSONPayload - request JSON payload
- * @param requestToken - request token
- * @param tokenLength - request token length
- * @param resourceUrl - URL of resource
- * @param reqTotalSize - total size of the request
- * @param devAddr - OCDevAddr
+ * @param request Initialized server request that is created by this function.
+ * @param coapID ID of CoAP pdu.
+ * @param delayedResNeeded Delayed response required 0=no 1=yes.
+ * @param notificationFlag TODO: remove - does not appear to be used any longer.
+ * @param method RESTful method.
+ * @param numRcvdVendorSpecificHeaderOptions Number of received vendor specific header options.
+ * @param observationOption Value of observation option.
+ * @param qos Request QOS.
+ * @param query Request query.
+ * @param rcvdVendorSpecificHeaderOptions Received vendor specific header options.
+ * @param reqJSONPayload Request JSON payload.
+ * @param requestToken Request token.
+ * @param tokenLength Request token length.
+ * @param resourceUrl URL of resource.
+ * @param reqTotalSize Total size of the request.
+ * @param devAddr Device Address.
*
* @return
- * OCStackResult
+ * ::OCStackResult
*/
OCStackResult AddServerRequest (OCServerRequest ** request, uint16_t coapID,
uint8_t delayedResNeeded, uint8_t notificationFlag, OCMethod method,
/**
* Form the OCEntityHandlerRequest struct that is passed to a resource's entity handler
*
- * @param entityHandlerRequest - pointer to the OCEntityHandlerRequest struct that is created
- * @param request - request handle
- * @param method - RESTful method
- * @param endpoint - requesting endpoint
- * @param resource - resource handle
- * @param queryBuf - resource query of request
- * @param payload - payload of request
- * @param payloadSize - size of the payload request
- * @param numVendorOptions - number of vendor options
- * @param vendorOptions - vendor options
- * @param observeAction - observe action flag
- * @param observeID - observe ID
+ * @param entityHandlerRequest pointer to the OCEntityHandlerRequest struct that is created.
+ * @param request Request handle.
+ * @param method RESTful method.
+ * @param resource Resource handle.
+ * @param queryBuf Resource query of request.
+ * @param bufReqPayload JSON payload of request.
+ * @param numVendorOptions Number of vendor options.
+ * @param vendorOptions Vendor options.
+ * @param observeAction Observe action flag.
+ * @param observeID Observe ID.
*
* @return
* OCStackResult
/**
* Find a server request in the server request list and delete
*
- * @param serverRequest - server request to find and delete
+ * @param serverRequest server request to find and delete.
*/
void FindAndDeleteServerRequest(OCServerRequest * serverRequest);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
-//-----------------------------------------------------------------------------
-// Internal include file used by lower layers of the OC stack
-//-----------------------------------------------------------------------------
+
+
+/**
+ * @file
+ *
+ * This file contains the Internal include file used by lower layers of the OC stack
+ *
+ */
+
#ifndef OCSTACKINTERNAL_H_
#define OCSTACKINTERNAL_H_
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
+
+/** Default device entity Handler.*/
extern OCDeviceEntityHandler defaultDeviceHandler;
+
+/** Default Callback parameter.*/
extern void* defaultDeviceHandlerCallbackParameter;
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
+
+/** The coap scheme */
#define OC_COAP_SCHEME "coap://"
-#define OC_OFFSET_SEQUENCE_NUMBER (4) // the first outgoing sequence number will be 5
+
+/** the first outgoing sequence number will be 5*/
+#define OC_OFFSET_SEQUENCE_NUMBER (4)
/**
* This structure will be created in occoap and passed up the stack on the server side.
*/
typedef struct
{
- // Observe option field
+ /** Observe option field.*/
uint32_t observationOption;
- // the REST method retrieved from received request PDU
+
+ /** The REST method retrieved from received request PDU.*/
OCMethod method;
- // resourceUrl will be filled in occoap using the path options in received request PDU
+
+ /** resourceUrl will be filled in occoap using the path options in received request PDU.*/
char resourceUrl[MAX_URI_LENGTH];
- // resource query send by client
+
+ /** resource query send by client.*/
char query[MAX_QUERY_LENGTH];
- // reqJSON is retrieved from the payload of the received request PDU
+
+ /** reqJSON is retrieved from the payload of the received request PDU.*/
uint8_t payload[MAX_REQUEST_LENGTH];
- // qos is indicating if the request is CON or NON
+
+ /** qos is indicating if the request is CON or NON.*/
OCQualityOfService qos;
- // An array of the received vendor specific header options
+
+ /** Number of the received vendor specific header options.*/
uint8_t numRcvdVendorSpecificHeaderOptions;
+
+ /** Array of received vendor specific header option .*/
OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
- /** Remote endpoint address **/
+ /** Remote end-point address **/
OCDevAddr devAddr;
- //token for the observe request
+ /** Token for the observe request.*/
CAToken_t requestToken;
- uint8_t tokenLength; //token length
- // The ID of CoAP pdu
+
+ /** token length.*/
+ uint8_t tokenLength;
+
+ /** The ID of CoAP PDU.*/
uint16_t coapID;
+
+ /** For delayed Response.*/
uint8_t delayedResNeeded;
+
+ /** For More packet.*/
uint8_t reqMorePacket;
+
+ /** The number of requested packet.*/
uint32_t reqPacketNum;
+
+ /** The size of requested packet.*/
uint16_t reqPacketSize;
+
+ /** The number of responded packet.*/
uint32_t resPacketNum;
+
+ /** Responded packet size.*/
uint16_t resPacketSize;
+
+ /** The total size of requested packet.*/
size_t reqTotalSize;
} OCServerProtocolRequest;
*/
typedef struct
{
- // handle is retrieved by comparing the token-handle pair in the PDU.
+ /** handle is retrieved by comparing the token-handle pair in the PDU.*/
ClientCB * cbNode;
- // This is how long this response is valid for (in seconds).
+
+ /** This is how long this response is valid for (in seconds).*/
uint32_t maxAge;
- // This is the Uri of the resource. (ex. "coap://192.168.1.1/a/led")
+
+ /** This is the Uri of the resource. (ex. "coap://192.168.1.1/a/led").*/
char * fullUri;
- // This is the relative Uri of the resource. (ex. "/a/led")
+
+ /** This is the relative Uri of the resource. (ex. "/a/led").*/
char * rcvdUri;
- // This is the received payload.
+
+ /** This is the received payload.*/
char * bufRes;
- // This is the token received OTA.
+ /** This is the token received OTA.*/
CAToken_t rcvdToken;
- // this structure will be passed to client
+ /** this structure will be passed to client.*/
OCClientResponse * clientResponse;
} OCResponse;
//-----------------------------------------------------------------------------
+/**
+ * Handler function for sending a response from multiple resources, such as a collection.
+ * Aggregates responses from multiple resource until all responses are received then sends the
+ * concatenated response
+ *
+ * TODO: Need to add a timeout in case a (remote?) resource does not respond
+ *
+ * @param token Token to search for.
+ * @param tokenLength Length of token.
+ * @param status Feedback status.
+ * @return
+ * ::OCStackResult
+ */
+
OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t status);
+
+/**
+ * Handler function to execute stack requests
+ *
+ * @param protocolRequest Pointer to the protocol requests from server.
+ *
+ * @return
+ * ::OCStackResult
+ */
OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest);
OCStackResult SendDirectStackResponse(const CAEndpoint_t* endPoint, const uint16_t coapID,
/**
* Notify Presence subscribers that a resource has been modified.
*
- * @param resourceType Handle to the resourceType linked list of resource
- * that was modified.
- * @param trigger The simplified reason this API was invoked. Valid values are
- * @ref OC_PRESENCE_TRIGGER_CREATE, @ref OC_PRESENCE_TRIGGER_CHANGE,
- * @ref OC_PRESENCE_TRIGGER_DELETE.
+ * @param resourceType Handle to the resourceType linked list of resource that was modified.
+ * @param trigger The simplified reason this API was invoked.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult SendPresenceNotification(OCResourceType *resourceType,
*/
OCStackResult SendStopNotification();
#endif // WITH_PRESENCE
+
+/**
+ * Function to parse the IPv4 address.
+ *
+ * @param ipAddrStr Pointer to a string of IPv4 address.
+ * @param ipAddr pointer to IPv4 adress.
+ * @param port Port number.
+ *
+ * @return true on success, false upon failure.
+ */
bool ParseIPv4Address(char * ipAddrStr, uint8_t * ipAddr, uint16_t * port);
/**
*
* @param resource Target resource.
* @param resourceInterfaceName Resource interface.
+ *
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult BindResourceInterfaceToResource(OCResource* resource,
const char *resourceInterfaceName);
/**
- * Bind a resourcetype to a resource.
+ * Bind a resource type to a resource.
*
* @param resource Target resource.
* @param resourceTypeName Name of resource type.
OCStackResult BindResourceTypeToResource(OCResource* resource,
const char *resourceTypeName);
-// Converts a CAResult_t type to a OCStackResult type.
+
/**
* Converts a CAResult_t type to a OCStackResult type.
*
- * @param caResult CAResult_t value to convert
+ * @param caResult CAResult_t value to convert.
* @return OCStackResult that was converted from the input CAResult_t value.
*/
OCStackResult CAResultToOCResult(CAResult_t caResult);
/**
* Get a byte representation of the server instance ID.
* The memory is managed internal to this function, so freeing it externally will
- * result in a runtime error
+ * result in a runtime error.
*
* Note: This will NOT seed the RNG, so it must be called after the RNG is seeded.
* This is done automatically during the OCInit process,
/**
* Get a string representation the server instance ID.
* The memory is managed internal to this function, so freeing externally will result
- * in a runtime error
+ * in a runtime error.
* Note: This will NOT seed the RNG, so it must be called after the RNG is seeded.
* This is done automatically during the OCInit process,
* so ensure that this call is done after that.
* Map OCQualityOfService to CAMessageType.
*
* @param qos Input qos.
+ *
* @return CA message type for a given qos.
*/
CAMessageType_t qualityOfServiceToMessageType(OCQualityOfService qos);
/**
* Enable/disable a resource property.
*
- * @param inputProperty Pointer to resource property.
- * @param resourceProperties Property to be enabled/disabled.
- * @param enable 0:disable, 1:enable.
+ * @param inputProperty Pointer to resource property.
+ * @param resourceProperties Property to be enabled/disabled.
+ * @param enable 0:disable, 1:enable.
*
* @return OCStackResult that was converted from the input CAResult_t value.
*/
#define OCPRESENCE_H_
#ifdef WITH_PRESENCE
+
/**
* The OCPresenceTrigger enum delineates the three spec-compliant modes for
- * "Trigger." These enum values are then mapped to strings
+ * "Trigger." These enum values are then mapped to strings
* "create", "change", "delete", respectively, before getting encoded into
- * the payload payload.
- *
- * @enum OC_PRESENCE_TRIGGER_CREATE The creation of a resource is associated with
- * this invocation of @ref SendPresenceNotification.
- * @enum OC_PRESENCE_TRIGGER_CHANGE The change/update of a resource is associated
- * this invocation of @ref SendPresenceNotification.
- * @enum OC_PRESENCE_TRIGGER_DELETE The deletion of a resource is associated with
- * this invocation of @ref SendPresenceNotification.
- *
+ * the payload.
*/
typedef enum
{
+ /** The creation of a resource is associated with this invocation. */
OC_PRESENCE_TRIGGER_CREATE = 0,
+
+ /** The change/update of a resource is associated this invocation. */
OC_PRESENCE_TRIGGER_CHANGE = 1,
+
+ /** The deletion of a resource is associated with this invocation.*/
OC_PRESENCE_TRIGGER_DELETE = 2
} OCPresenceTrigger;
#endif
// limitations under the License.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+
+/**
+ * @file
+ *
+ * This file contains APIs for OIC Stack to be implemented.
+ */
#ifndef OCSTACK_H_
#define OCSTACK_H_
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
+
+/** Macro to use Random port.*/
#define USE_RANDOM_PORT (0)
-//-----------------------------------------------------------------------------
-// Function prototypes
-//-----------------------------------------------------------------------------
+/*
+ * Function prototypes
+ */
/**
- * Initialize the OC Stack. Must be called prior to starting the stack.
+ * This function Initializes the OC Stack. Must be called prior to starting the stack.
*
- * @param mode
- * Host device is client, server, or client-server.
- * @param serverFlags
- * Default server transport flags.
- * @param clientFlags
- * Default client transport flags.
+ * @param mode OCMode Host device is client, server, or client-server.
+ * @param serverFlags OCTransportFlags Default server transport flags.
+ * @param clientFlags OCTransportFlags Default client transport flags.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCInit1(OCMode mode, OCTransportFlags serverFlags, OCTransportFlags clientFlags);
/**
- * Initialize the OC Stack. Must be called prior to starting the stack.
+ * This function Initializes the OC Stack. Must be called prior to starting the stack.
*
- * @param ipAddr
- * IP Address of host device. Deprecated parameter.
- * @param port
- * Port of host device. Deprecated parameter.
- * @param mode
- * Host device is client, server, or client-server.
+ * @param ipAddr IP Address of host device. Deprecated parameter.
+ * @param port Port of host device. Deprecated parameter.
+ * @param mode OCMode Host device is client, server, or client-server.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
#endif
/**
- * Stop the OC stack. Use for a controlled shutdown.
+ * This function Stops the OC stack. Use for a controlled shutdown.
*
- * Note: OCStop() performs operations similar to OCStopPresence(), as well as OCDeleteResource() on
+ * @note: OCStop() performs operations similar to OCStopPresence(), as well as OCDeleteResource() on
* all resources this server is hosting. OCDeleteResource() performs operations similar to
* OCNotifyAllObservers() to notify all client observers that the respective resource is being
* deleted.
OCStackResult OCStop();
/**
- * Called in main loop of OC client or server. Allows low-level processing of
- * stack services.
+ * This function is Called in main loop of OC client or server.
+ * Allows low-level processing of stack services.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCProcess();
/**
- * Discover or Perform requests on a specified resource (specified by that Resource's respective
- * URI).
- *
- * @param handle @ref OCDoHandle to refer to the request sent out on behalf of
- * calling this API. This handle can be used to cancel this operation
- * via the OCCancel API.
- * Note: This reference is handled internally, and
- * should not be free'd by the consumer. A NULL handle is permitted
- * in the event where the caller has no use for the return value.
- * @param method @ref OCMethod to perform on the resource.
- * @param requiredUri URI of the resource to interact with. (Address prefix
- * is deprecated in favor of destination.)
- * @param destination Complete description of destination.
- * @param request JSON encoded request.
- * @param connectivityType Modifier flags when destination is not given.
- * @param qos Quality of service. Note that if this API is called on a uri with
- * the well-known multicast IP address, the qos will be forced to
- * ::OC_LOW_QOS
- * since it is impractical to send other QOS levels on such addresses.
- * @param cbData Asynchronous callback function that is invoked
- * by the stack when discovery or resource interaction is complete.
- * @param options The address of an array containing the vendor specific
- * header options to be sent with the request.
- * @param numOptions Number of header options to be included.
- *
- * Note: Presence subscription amendments (ie. adding additional resource type filters by calling
+ * This function discovers or Perform requests on a specified resource
+ * (specified by that Resource's respective URI).
+ *
+ * @param handle To refer to the request sent out on behalf of
+ * calling this API. This handle can be used to cancel this operation
+ * via the OCCancel API.
+ * @note: This reference is handled internally, and should not be free'd by
+ * the consumer. A NULL handle is permitted in the event where the caller
+ * has no use for the return value.
+ * @param method To perform on the resource.
+ * @param requestUri URI of the resource to interact with. (Address prefix is deprecated in
+ * favor of destination.)
+ * @param destination Complete description of destination.
+ * @param payload Encoded request payload.
+ * @param connectivityType Modifier flags when destination is not given.
+ * @param qos Quality of service. Note that if this API is called on a uri with the
+ * well-known multicast IP address, the qos will be forced to ::OC_LOW_QOS
+ * since it is impractical to send other QOS levels on such addresses.
+ * @param cbData Asynchronous callback function that is invoked by the stack when
+ * discovery or resource interaction is complete.
+ * @param options The address of an array containing the vendor specific header options
+ * to be sent with the request.
+ * @param numOptions Number of header options to be included.
+ *
+ * @note: Presence subscription amendments (i.e. adding additional resource type filters by calling
* this API again) require the use of the same base URI as the original request to successfully
* amend the presence filters.
*
OCHeaderOption *options,
uint8_t numOptions);
/**
- * Cancel a request associated with a specific @ref OCDoResource invocation.
+ * This function cancels a request associated with a specific @ref OCDoResource invocation.
*
- * @param handle - Used to identify a specific OCDoResource invocation.
- * @param qos - used to specify Quality of Service (read below for more info)
- * @param options- used to specify vendor specific header options when sending
- * explicit observe cancellation
- * @param numOptions- Number of header options to be included
+ * @param handle Used to identify a specific OCDoResource invocation.
+ * @param qos Used to specify Quality of Service(read below).
+ * @param options Used to specify vendor specific header options when sending
+ * explicit observe cancellation.
+ * @param numOptions Number of header options to be included.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
uint8_t numOptions);
/**
- * @brief Register Persistent storage callback.
- * @param persistentStorageHandler [IN] Pointers to open, read, write, close & unlink handlers.
+ * Register Persistent storage callback.
+ * @param persistentStorageHandler Pointers to open, read, write, close & unlink handlers.
+ *
* @return
- * OC_STACK_OK - No errors; Success
- * OC_STACK_INVALID_PARAM - Invalid parameter
+ * OC_STACK_OK No errors; Success.
+ * OC_STACK_INVALID_PARAM Invalid parameter.
*/
OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler);
#ifdef WITH_PRESENCE
/**
- * When operating in @ref OCServer or @ref OCClientServer mode, this API will start sending out
- * presence notifications to clients via multicast. Once this API has been called with a success,
- * clients may query for this server's presence and this server's stack will respond via multicast.
+ * When operating in OCServer or OCClientServer mode,
+ * this API will start sending out presence notifications to clients via multicast.
+ * Once this API has been called with a success, clients may query for this server's presence and
+ * this server's stack will respond via multicast.
*
* 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.
*
- * @param ttl Time To Live in seconds.
- * Note: 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.
+ * @param ttl Time To Live in seconds.
+ * @note: 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.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCStartPresence(const uint32_t ttl);
/**
- * When operating in @ref OCServer or @ref OCClientServer mode, this API will stop sending out
- * presence notifications to clients via multicast. Once this API has been called with a success,
- * this server's stack will not respond to clients querying for this server's presence.
+ * When operating in OCServer or OCClientServer mode, this API will stop sending
+ * out presence notifications to clients via multicast.
+ * Once this API has been called with a success this server's stack will not respond to clients
+ * querying for this server's presence.
*
* Server can call this function when it is terminating, going offline, or when going
* away from network.
/**
- * Set default device entity handler.
+ * This function sets default device entity handler.
*
- * @param entityHandler Entity handler function that is called by ocstack to handle requests for
- * any undefined resources or default actions.
- * If NULL is passed it removes the device default entity handler.
- * @param callbackParameter paramter passed back when entityHandler is called.
+ * @param entityHandler Entity handler function that is called by ocstack to handle requests
+ * for any undefined resources or default actions.If NULL is passed it
+ * removes the device default entity handler.
+ * @param callbackParameter Parameter passed back when entityHandler is called.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCSetDefaultDeviceEntityHandler(OCDeviceEntityHandler entityHandler, void* callbackParameter);
/**
- * Set device information.
- *
- * @param deviceInfo - Structure passed by the server application containing
- * the device information.
+ * This function sets device information.
*
+ * @param deviceInfo Structure passed by the server application containing the device information.
*
* @return
- * OC_STACK_OK - no errors
- * OC_STACK_INVALID_PARAM - invalid paramerter
- * OC_STACK_ERROR - stack process error
+ * ::OC_STACK_OK no errors.
+ * ::OC_STACK_INVALID_PARAM invalid parameter.
+ * ::OC_STACK_ERROR stack process error.
*/
OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo);
/**
- * Set platform information.
+ * This function sets platform information.
*
- * @param platformInfo - Structure passed by the server application containing
- * the platform information.
+ * @param platformInfo Structure passed by the server application containing
+ * the platform information.
*
*
* @return
- * OC_STACK_OK - no errors
- * OC_STACK_INVALID_PARAM - invalid paramerter
- * OC_STACK_ERROR - stack process error
+ * ::OC_STACK_OK no errors.
+ * ::OC_STACK_INVALID_PARAM invalid parameter.
+ * ::OC_STACK_ERROR stack process error.
*/
OCStackResult OCSetPlatformInfo(OCPlatformInfo platformInfo);
/**
- * Create a resource.
+ * This function creates a resource.
*
- * @param handle Pointer to handle to newly created resource. Set by ocstack and
- * used to refer to resource.
- * @param resourceTypeName Name of resource type. Example: "core.led".
+ * @param handle Pointer to handle to newly created resource. Set by ocstack and
+ * used to refer to resource.
+ * @param resourceTypeName Name of resource type. Example: "core.led".
* @param resourceInterfaceName Name of resource interface. Example: "core.rw".
- * @param uri URI of the resource. Example: "/a/led".
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- * NULL for default entity handler.
- * @param callbackParameter paramter passed back when entityHandler is called.
- * @param resourceProperties Properties supported by resource.
- * Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE.
+ * @param uri URI of the resource. Example: "/a/led".
+ * @param entityHandler Entity handler function that is called by ocstack to handle
+ * requests, etc.
+ * NULL for default entity handler.
+ * @param callbackParam parameter passed back when entityHandler is called.
+ * @param resourceProperties Properties supported by resource.
+ * Example: ::OC_DISCOVERABLE|::OC_OBSERVABLE.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
/**
- * Add a resource to a collection resource.
+ * This function adds a resource to a collection resource.
*
- * @param collectionHandle Handle to the collection resource.
- * @param resourceHandle Handle to resource to be added to the collection resource.
+ * @param collectionHandle Handle to the collection resource.
+ * @param resourceHandle Handle to resource to be added to the collection resource.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle);
/**
- * Remove a resource from a collection resource.
+ * This function removes a resource from a collection resource.
*
- * @param collectionHandle Handle to the collection resource.
- * @param resourceHandle Handle to resource to be removed from the collection resource.
+ * @param collectionHandle Handle to the collection resource.
+ * @param resourceHandle Handle to resource to be removed from the collection resource.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCUnBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle);
/**
- * Bind a resourcetype to a resource.
+ * This function binds a resource type to a resource.
*
- * @param handle Handle to the resource.
- * @param resourceTypeName Name of resource type. Example: "core.led".
+ * @param handle Handle to the resource.
+ * @param resourceTypeName Name of resource type. Example: "core.led".
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
const char *resourceTypeName);
/**
- * Bind a resource interface to a resource.
+ * This function binds a resource interface to a resource.
*
- * @param handle Handle to the resource.
- * @param resourceInterfaceName Name of resource interface. Example: "core.rw".
+ * @param handle Handle to the resource.
+ * @param resourceInterfaceName Name of resource interface. Example: "core.rw".
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
const char *resourceInterfaceName);
/**
- * Bind an entity handler to the resource.
+ * This function binds an entity handler to the resource.
+ *
+ * @param handle Handle to the resource that the contained resource is to be bound.
+ * @param entityHandler Entity handler function that is called by ocstack to handle requests.
+ * @param callbackParameter Context parameter that will be passed to entityHandler.
*
- * @param handle Handle to the resource that the contained resource is to be bound.
- * @param entityHandler Entity handler function that is called by ocstack to handle requests, etc.
- * @param callbackParameter context paremeter that will be passed to entityHandler
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCBindResourceHandler(OCResourceHandle handle, OCEntityHandler entityHandler,
void *callbackParameter);
/**
- * Get the number of resources that have been created in the stack.
+ * This function gets the number of resources that have been created in the stack.
*
- * @param numResources Pointer to count variable.
+ * @param numResources Pointer to count variable.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCGetNumberOfResources(uint8_t *numResources);
/**
- * Get a resource handle by index.
+ * This function gets a resource handle by index.
*
- * @param index Index of resource, 0 to Count - 1.
+ * @param index Index of resource, 0 to Count - 1.
*
- * @return Found resource handle or NULL if not found.
+ * @return Found resource handle or NULL if not found.
*/
OCResourceHandle OCGetResourceHandle(uint8_t index);
/**
- * Delete resource specified by handle. Deletes resource and all resourcetype and resourceinterface
- * linked lists.
+ * This function deletes resource specified by handle. Deletes resource and all
+ * resource type and resource interface linked lists.
*
- * Note: OCDeleteResource() performs operations similar to OCNotifyAllObservers() to notify all
+ * @note: OCDeleteResource() performs operations similar to OCNotifyAllObservers() to notify all
* client observers that "this" resource is being deleted.
*
- * @param handle Handle of resource to be deleted.
+ * @param handle Handle of resource to be deleted.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCDeleteResource(OCResourceHandle handle);
/**
- * Get the URI of the resource specified by handle.
+ * This function gets the URI of the resource specified by handle.
+ *
+ * @param handle Handle of resource.
*
- * @param handle Handle of resource.
* @return URI string if resource found or NULL if not found.
*/
const char *OCGetResourceUri(OCResourceHandle handle);
/**
- * Get the properties of the resource specified by handle.
- * NOTE: that after a resource is created, the OC_ACTIVE property is set
- * for the resource by the stack.
+ * This function gets the properties of the resource specified by handle.
+ *
+ * @param handle Handle of resource.
*
- * @param handle Handle of resource.
- * @return OCResourceProperty Bitmask or -1 if resource is not found.
+ * @return OCResourceProperty Bitmask or -1 if resource is not found.
+ *
+ * @note that after a resource is created, the OC_ACTIVE property is set for the resource by the
+ * stack.
*/
OCResourceProperty OCGetResourceProperties(OCResourceHandle handle);
/**
- * Get the number of resource types of the resource.
+ * This function gets the number of resource types of the resource.
*
- * @param handle Handle of resource.
- * @param numResourceTypes Pointer to count variable.
+ * @param handle Handle of resource.
+ * @param numResourceTypes Pointer to count variable.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
OCStackResult OCGetNumberOfResourceTypes(OCResourceHandle handle, uint8_t *numResourceTypes);
/**
- * Get name of resource type of the resource.
+ * This function gets name of resource type of the resource.
*
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle Handle of resource.
+ * @param index Index of resource, 0 to Count - 1.
*
* @return Resource type name if resource found or NULL if resource not found.
*/
const char *OCGetResourceTypeName(OCResourceHandle handle, uint8_t index);
/**
- * Get the number of resource interfaces of the resource.
+ * This function gets the number of resource interfaces of the resource.
*
- * @param handle Handle of resource.
- * @param numResourceInterfaces Pointer to count variable.
+ * @param handle Handle of resource.
+ * @param numResourceInterfaces Pointer to count variable.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
uint8_t *numResourceInterfaces);
/**
- * Get name of resource interface of the resource.
+ * This function gets name of resource interface of the resource.
*
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle Handle of resource.
+ * @param index Index of resource, 0 to Count - 1.
*
* @return Resource interface name if resource found or NULL if resource not found.
*/
const char *OCGetResourceInterfaceName(OCResourceHandle handle, uint8_t index);
/**
- * Get methods of resource interface of the resource.
+ * This function gets methods of resource interface of the resource.
*
- * @param handle Handle of resource.
- * @param index Index of resource, 0 to Count - 1.
+ * @param handle Handle of resource.
+ * @param index Index of resource, 0 to Count - 1.
*
* @return Allowed methods if resource found or NULL if resource not found.
*/
uint8_t OCGetResourceInterfaceAllowedMethods(OCResourceHandle handle, uint8_t index);
/**
- * Get resource handle from the collection resource by index.
+ * This function gets resource handle from the collection resource by index.
*
- * @param collectionHandle Handle of collection resource.
- * @param index Index of contained resource, 0 to Count - 1.
+ * @param collectionHandle Handle of collection resource.
+ * @param index Index of contained resource, 0 to Count - 1.
*
* @return Handle to contained resource if resource found or NULL if resource not found.
*/
uint8_t index);
/**
- * Get the entity handler for a resource.
+ * This function gets the entity handler for a resource.
*
- * @param handle Handle of resource.
+ * @param handle Handle of resource.
*
* @return Entity handler if resource found or NULL resource not found.
*/
OCEntityHandler OCGetResourceHandler(OCResourceHandle handle);
/**
- * Notify all registered observers that the resource representation has
- * changed. If observation includes a query the client is notified only
- * if the query is valid after the resource representation has changed.
+ * This function notify all registered observers that the resource representation has
+ * changed. If observation includes a query the client is notified only if the query is valid after
+ * the resource representation has changed.
*
- * @param handle Handle of resource.
- * @param qos Desired quality of service for the observation notifications.
+ * @param handle Handle of resource.
+ * @param qos Desired quality of service for the observation notifications.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
* Before this API is invoked by entity handler it has finished processing
* queries for the associated observers.
*
- * @param handle Handle of resource.
- * @param obsIdList List of observation ids that need to be notified.
- * @param numberOfIds Number of observation ids included in obsIdList.
- * @param payload OCRepresentationPayload object representing the notification
- * @param qos Desired quality of service of the observation notifications.
- * NOTE: The memory for obsIdList and notificationJSONPayload is managed by the
- * entity invoking the API. The maximum size of the notification is 1015 bytes
- * for non-Arduino platforms. For Arduino the maximum size is 247 bytes.
+ * @param handle Handle of resource.
+ * @param obsIdList List of observation IDs that need to be notified.
+ * @param numberOfIds Number of observation IDs included in obsIdList.
+ * @param payload Object representing the notification
+ * @param qos Desired quality of service of the observation notifications.
+ *
+ * @note: The memory for obsIdList and payload is managed by the entity invoking the API.
+ * The maximum size of the notification is 1015 bytes for non-Arduino platforms. For Arduino
+ * the maximum size is 247 bytes.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
/**
- * Send a response to a request.
+ * This function sends a response to a request.
* The response can be a normal, slow, or block (i.e. a response that
* is too large to be sent in a single PDU and must span multiple transmissions).
*
- * @param response Pointer to structure that contains response parameters.
+ * @param response Pointer to structure that contains response parameters.
*
* @return ::OC_STACK_OK on success, some other value upon failure.
*/
//******************************************************************
//
-// Copyright 2014 Intel Corporation All Rights Reserved.
+// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//******************************************************************
+
+
+/**
+ * @file
+ *
+ * This file contains all the variables which can be configured/modified as
+ * per platform or specific product usage scenarios.
+ */
#ifndef OCSTACK_CONFIG_H_
#define OCSTACK_CONFIG_H_
-// This file contains all the variables which can be configured/modified as
-// per platform or specific product usage scenarios.
-
/** This would need to be updated in future as we move to support IPv6 and other
* technologies.
*/
* Maximum length of the response supported by Server for any REST request.
* The actual repsonse length is 256 for Arduino and 1024 for other platforms.
* Note that the stack will add a prefix and suffix to the payload.
+ * @code
* Prefix : {"oic":[
* Suffix : ]}
+ * @endcode
* They have a combined size of 10 bytes.
*/
#ifdef WITH_ARDUINO
/**
* Maximum length of the Manufacturer name supported by the server
- * for manufacturer name
+ * for manufacturer name.
*/
#define MAX_MANUFACTURER_NAME_LENGTH (16)
#define MAX_CONTAINED_RESOURCES (5)
/**
- * Maximum number of vendor specific header options an application can set or receive in pdu
+ * Maximum number of vendor specific header options an application can set or receive
+ * in PDU
*/
#define MAX_HEADER_OPTIONS (2)
*/
#define MAX_HEADER_OPTION_DATA_LENGTH (16)
-/*
- * Sets the time to live (TTL) for response callbacks.
- * The callbacks will be up for deletion after such time but are not guaranteed
+/**
+ * Sets the time to live (TTL) for response callback(s).
+ * The callback(s) will be up for deletion after such time but are not guaranteed
* to be deleted immediately and you may get responses even after timeout.
* This timeout will NOT apply to OBSERVE requests. OBSERVE needs an explicit cancel using OCCancel().
- * NOTE: Changing the setting to a very long duration may lead to unsupported and untested
+ * @note: Changing the setting to a very long duration may lead to unsupported and untested
* operation. Setting this to as small a value as reasonable will reclaim memory faster.
*/
#define MAX_CB_TIMEOUT_SECONDS (2 * 60 * 60) // 2 hours = 7200 seconds.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//******************************************************************
+
+
+/**
+ * @file
+ *
+ * This file contains the definition, types and APIs for resource(s) be implemented.
+ */
#ifndef OCTYPES_H_
#define OCTYPES_H_
extern "C" {
#endif // __cplusplus
+
+/** For the feature presence.*/
#define WITH_PRESENCE
+
#include "ocpresence.h"
//-----------------------------------------------------------------------------
// Defines
/**
* OIC Virtual resources supported by every OIC device.
*/
+/**
+ * Default discovery mechanism using '/oic/res' is supported by all OIC devices
+ * That are Discoverable.
+ */
#define OC_RSRVD_WELL_KNOWN_URI "/oic/res"
+
+/** Device URI.*/
#define OC_RSRVD_DEVICE_URI "/oic/d"
+
+/** Platform URI.*/
#define OC_RSRVD_PLATFORM_URI "/oic/p"
+
+/** Resource Type.*/
#define OC_RSRVD_RESOURCE_TYPES_URI "/oic/res/types/d"
+
#ifdef WITH_PRESENCE
+
+/** Presence URI through which the OIC devices advertise their presence.*/
#define OC_RSRVD_PRESENCE_URI "/oic/ad"
+
+/** Sets the default time to live (TTL) for presence.*/
#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
-/// OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
-/// NOTE: Changing the setting to a longer duration may lead to unsupported and untested
-/// operation.
-#define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24) // 60 sec/min * 60 min/hr * 24 hr/day
-#endif
-///Separtor for multiple query string
+/** For multicast Discovery mechanism.*/
+#define OC_MULTICAST_DISCOVERY_URI "/oic/res"
+
+/** Separator for multiple query string.*/
#define OC_QUERY_SEPARATOR "&;"
/**
- * Attributes used to form a proper OIC conforming JSON message.
+ * OC_DEFAULT_PRESENCE_TTL_SECONDS sets the default time to live (TTL) for presence.
*/
-//#define OC_RSRVD_OC "oic"
+#define OC_DEFAULT_PRESENCE_TTL_SECONDS (60)
+
+/**
+ * OC_MAX_PRESENCE_TTL_SECONDS sets the maximum time to live (TTL) for presence.
+ * NOTE: Changing the setting to a longer duration may lead to unsupported and untested
+ * operation.
+ * 60 sec/min * 60 min/hr * 24 hr/day
+ */
+#define OC_MAX_PRESENCE_TTL_SECONDS (60 * 60 * 24)
+#endif
+
+/**
+ * Presence "Announcement Triggers".
+ */
+
+/** To create.*/
+#define OC_RSRVD_TRIGGER_CREATE "create"
+
+/** To change.*/
+#define OC_RSRVD_TRIGGER_CHANGE "change"
+
+/** To delete.*/
+#define OC_RSRVD_TRIGGER_DELETE "delete"
+
+/**
+ * Attributes used to form a proper OIC conforming JSON message.
+ */
+
+#define OC_RSRVD_OC "oic"
+
+/** For payload. */
+
#define OC_RSRVD_PAYLOAD "payload"
+
+/** To represent href */
#define OC_RSRVD_HREF "href"
+
+/** To represent property*/
#define OC_RSRVD_PROPERTY "prop"
+
+/** For representation.*/
#define OC_RSRVD_REPRESENTATION "rep"
+
+/** To represent content type.*/
#define OC_RSRVD_CONTENT_TYPE "ct"
+
+/** To represent resource type.*/
#define OC_RSRVD_RESOURCE_TYPE "rt"
+
+/** To represent resource type with presence.*/
#define OC_RSRVD_RESOURCE_TYPE_PRESENCE "oic.wk.ad"
+
+/** To represent interface.*/
#define OC_RSRVD_INTERFACE "if"
+
+/** To represent time to live.*/
#define OC_RSRVD_TTL "ttl"
+
+/** To represent non*/
#define OC_RSRVD_NONCE "non"
+
+/** To represent trigger type.*/
#define OC_RSRVD_TRIGGER "trg"
+
+/** To represent links.*/
#define OC_RSRVD_LINKS "links"
+/** To represent default interface.*/
#define OC_RSRVD_INTERFACE_DEFAULT "oic.if.baseline"
+
+/** To represent ll interface.*/
#define OC_RSRVD_INTERFACE_LL "oic.if.ll"
+
+/** To represent batch interface.*/
#define OC_RSRVD_INTERFACE_BATCH "oic.if.b"
+
+/** To represent interface group.*/
#define OC_RSRVD_INTERFACE_GROUP "oic.mi.grp"
+
+/** To represent MFG date.*/
#define OC_RSRVD_MFG_DATE "mndt"
+
+/** To represent FW version.*/
#define OC_RSRVD_FW_VERSION "mnfv"
+
+/** To represent host name.*/
#define OC_RSRVD_HOST_NAME "hn"
+
+/** To represent version.*/
#define OC_RSRVD_VERSION "icv"
+
+/** To represent policy.*/
#define OC_RSRVD_POLICY "p"
+
+/** To represent bitmap.*/
#define OC_RSRVD_BITMAP "bm"
+
+/** For security.*/
#define OC_RSRVD_SECURE "sec"
+
+/** Port. */
#define OC_RSRVD_HOSTING_PORT "port"
+
+/** For Server instance ID.*/
#define OC_RSRVD_SERVER_INSTANCE_ID "sid"
-//**** Presence "Announcement Triggers" ****
-#define OC_RSRVD_TRIGGER_CREATE "create"
-#define OC_RSRVD_TRIGGER_CHANGE "change"
-#define OC_RSRVD_TRIGGER_DELETE "delete"
-//*******************
+/**
+ * Platform.
+ */
-//**** Platform ****
+/** Platform ID. */
#define OC_RSRVD_PLATFORM_ID "pi"
+
+/** Platform MFG NAME. */
#define OC_RSRVD_MFG_NAME "mnmn"
+
+/** Platform URL. */
#define OC_RSRVD_MFG_URL "mnml"
+
+/** Model Number.*/
#define OC_RSRVD_MODEL_NUM "mnmo"
+
+/** Platform MFG Date.*/
#define OC_RSRVD_MFG_DATE "mndt"
+
+/** Platform versio.n */
#define OC_RSRVD_PLATFORM_VERSION "mnpv"
+
+/** Platform Operating system version. */
#define OC_RSRVD_OS_VERSION "mnos"
+
+/** Platform Hardware version. */
#define OC_RSRVD_HARDWARE_VERSION "mnhw"
+
+/**Platform Firmware version. */
#define OC_RSRVD_FIRMWARE_VERSION "mnfv"
+
+/** Support URL for the platform. */
#define OC_RSRVD_SUPPORT_URL "mnsl"
+
+/** System time for the platform. */
#define OC_RSRVD_SYSTEM_TIME "st"
-//*******************
-//**** Device ****
+/**
+ * Device.
+ */
+
+/** Device ID.*/
#define OC_RSRVD_DEVICE_ID "di"
+
+/** Device Name.*/
#define OC_RSRVD_DEVICE_NAME "n"
+
+/** Device specification version.*/
#define OC_RSRVD_SPEC_VERSION "lcv"
+
+/** Device data model.*/
#define OC_RSRVD_DATA_MODEL_VERSION "dmv"
+/** Device specification version.*/
#define OC_SPEC_VERSION "0.9.0"
+
+/** Device Data Model version.*/
#define OC_DATA_MODEL_VERSION "sec.0.95"
-//*******************
-// These provide backward compatibility - their use is deprecated
+/**
+ * These provide backward compatibility - their use is deprecated.
+ */
#ifndef GOING_AWAY
+
+/** Multicast Prefix.*/
#define OC_MULTICAST_PREFIX "224.0.1.187:5683"
+
+/** Multicast IP address.*/
#define OC_MULTICAST_IP "224.0.1.187"
+
+/** Multicast Port.*/
#define OC_MULTICAST_PORT 5683
#endif // GOING_AWAY
-//-----------------------------------------------------------------------------
-// Typedefs
-//-----------------------------------------------------------------------------
#ifdef RA_ADAPTER
#define MAX_ADDR_STR_SIZE (256)
#else
#define MAX_IDENTITY_SIZE (32)
+/** Max Device address size. */
+#define MAX_ADDR_STR_SIZE (40)
+
+/** Max identity size. */
+#define MAX_IDENTITY_SIZE (32)
-/*
+/**
* These enums (OCTransportAdapter and OCTransportFlags) must
* be kept synchronized with OCConnectivityType (below) as well as
* CATransportAdapter and CATransportFlags (in CACommon.h).
*/
-
typedef enum
{
+ /** value zero indicates discovery.*/
OC_DEFAULT_ADAPTER = 0,
- // value zero indicates discovery
- OC_ADAPTER_IP = (1 << 0), // IPv4 and IPv6, including 6LoWPAN
- OC_ADAPTER_GATT_BTLE = (1 << 1), // GATT over Bluetooth LE
- OC_ADAPTER_RFCOMM_BTEDR = (1 << 2), // RFCOMM over Bluetooth EDR
+ /** IPv4 and IPv6, including 6LoWPAN.*/
+ OC_ADAPTER_IP = (1 << 0),
+
+ /** GATT over Bluetooth LE.*/
+ OC_ADAPTER_GATT_BTLE = (1 << 1),
+
+ /** RFCOMM over Bluetooth EDR.*/
+ OC_ADAPTER_RFCOMM_BTEDR = (1 << 2),
+
+#ifdef RA_ADAPTER
+ /**Remote Access over XMPP.*/
+ OC_ADAPTER_REMOTE_ACCESS = (1 << 3)
+#endif
- #ifdef RA_ADAPTER
- OC_ADAPTER_REMOTE_ACCESS = (1 << 3) // Remote Access over XMPP.
- #endif
} OCTransportAdapter;
-// enum layout assumes some targets have 16-bit integer (e.g., Arduino)
+/**
+ * Enum layout assumes some targets have 16-bit integer (e.g., Arduino).
+ */
typedef enum
{
+ /** default flag is 0*/
OC_DEFAULT_FLAGS = 0,
- // Insecure transport is the default (subject to change)
- OC_FLAG_SECURE = (1 << 4), // secure the transport path
+ /** Insecure transport is the default (subject to change).*/
+ /** secure the transport path*/
+ OC_FLAG_SECURE = (1 << 4),
+
+ /** IPv4 & IPv6 auto-selection is the default.*/
+ /** IP adapter only.*/
+ OC_IP_USE_V6 = (1 << 5),
- // IPv4 & IPv6 autoselection is the default
- OC_IP_USE_V6 = (1 << 5), // IP adapter only
- OC_IP_USE_V4 = (1 << 6), // IP adapter only
+ /** IP adapter only.*/
+ OC_IP_USE_V4 = (1 << 6),
+ /** internal use only.*/
OC_RESERVED1 = (1 << 7), // internal use only
- // Link-Local multicast is the default multicast scope for IPv6.
- // These are placed here to correspond to the IPv6 multicast address bits.
- OC_SCOPE_INTERFACE = 0x1, // IPv6 Interface-Local scope (loopback)
- OC_SCOPE_LINK = 0x2, // IPv6 Link-Local scope (default)
- OC_SCOPE_REALM = 0x3, // IPv6 Realm-Local scope
- OC_SCOPE_ADMIN = 0x4, // IPv6 Admin-Local scope
- OC_SCOPE_SITE = 0x5, // IPv6 Site-Local scope
- OC_SCOPE_ORG = 0x8, // IPv6 Organization-Local scope
- OC_SCOPE_GLOBAL = 0xE, // IPv6 Global scope
+ /** Link-Local multicast is the default multicast scope for IPv6.
+ * These are placed here to correspond to the IPv6 multicast address bits.*/
+
+ /** IPv6 Interface-Local scope (loopback).*/
+ OC_SCOPE_INTERFACE = 0x1,
+
+ /** IPv6 Link-Local scope (default).*/
+ OC_SCOPE_LINK = 0x2,
+
+ /** IPv6 Realm-Local scope. */
+ OC_SCOPE_REALM = 0x3,
+
+ /** IPv6 Admin-Local scope. */
+ OC_SCOPE_ADMIN = 0x4,
+
+ /** IPv6 Site-Local scope. */
+ OC_SCOPE_SITE = 0x5,
+
+ /** IPv6 Organization-Local scope. */
+ OC_SCOPE_ORG = 0x8,
+
+ /**IPv6 Global scope. */
+ OC_SCOPE_GLOBAL = 0xE,
+
} OCTransportFlags;
+/** Bit mask for scope.*/
#define OC_MASK_SCOPE (0x000F)
+
+/** Bit mask for Mods.*/
#define OC_MASK_MODS (0x0FF0)
#define OC_MASK_FAMS (OC_IP_USE_V6|OC_IP_USE_V4)
-/*
- * endpoint identity
+/**
+ * End point identity.
*/
typedef struct
{
+ /** Identity Length */
uint16_t id_length;
+
+ /** Array of end point identity.*/
unsigned char id[MAX_IDENTITY_SIZE];
} OCIdentity;
/**
* Data structure to encapsulate IPv4/IPv6/Contiki/lwIP device addresses.
- *
* OCDevAddr must be the same as CAEndpoint (in CACommon.h).
*/
typedef struct
{
- OCTransportAdapter adapter; // adapter type
- OCTransportFlags flags; // transport modifiers
- char addr[MAX_ADDR_STR_SIZE]; // address for all adapters
- uint32_t interface; // usually zero for default interface
- uint16_t port; // for IP
- OCIdentity identity; // secure node identity
+ /** adapter type.*/
+ OCTransportAdapter adapter;
+
+ /** transport modifiers.*/
+ OCTransportFlags flags;
+
+ /** address for all adapters.*/
+ char addr[MAX_ADDR_STR_SIZE];
+
+ /** usually zero for default interface.*/
+ uint32_t interface;
+
+ /** for IP.*/
+ uint16_t port;
+
+ /** secure node identity.*/
+ OCIdentity identity;
} OCDevAddr;
-/*
- * OCConnectivityType includes elements of both OCTransportAdapter
- * and OCTransportFlags. It is defined conditionally because the
- * smaller definition limits expandability on 32/64 bit integer machines,
- * and the larger definition won't fit into an enum on 16-bit integer
- * machines like Arduino.
+/**
+ * This enum type includes elements of both ::OCTransportAdapter and ::OCTransportFlags.
+ * It is defined conditionally because the smaller definition limits expandability on 32/64 bit
+ * integer machines, and the larger definition won't fit into an enum on 16-bit integer machines
+ * like Arduino.
*
- * This structure must directly correspond to OCTransportAdapter
- * and OCTransportFlags.
+ * This structure must directly correspond to ::OCTransportAdapter and ::OCTransportFlags.
*/
typedef enum
{
- CT_DEFAULT = 0, // use when defaults are ok
+ /** use when defaults are ok. */
+ CT_DEFAULT = 0,
+
+ /** 16-bit int. */
+ #if defined (__UINT32_MAX__) && (__UINT32_MAX__ == 65535)
+
+ /** IPv4 and IPv6, including 6LoWPAN.*/
+ CT_ADAPTER_IP = (1 << 10),
+
+ /** GATT over Bluetooth LE.*/
+ CT_ADAPTER_GATT_BTLE = (1 << 11),
+
+ /** RFCOMM over Bluetooth EDR.*/
+ CT_ADAPTER_RFCOMM_BTEDR = (1 << 12),
+
+ /** assume 32-bit int. */
+ #else
+
+ /** IPv4 and IPv6, including 6LoWPAN.*/
+ CT_ADAPTER_IP = (1 << 16),
+
+ /** GATT over Bluetooth LE.*/
+ CT_ADAPTER_GATT_BTLE = (1 << 17),
+
+ /** RFCOMM over Bluetooth EDR.*/
+ CT_ADAPTER_RFCOMM_BTEDR = (1 << 18),
- #if defined (__UINT32_MAX__) && (__UINT32_MAX__ == 65535) // 16-bit int
- CT_ADAPTER_IP = (1 << 10), // IPv4 and IPv6, including 6LoWPAN
- CT_ADAPTER_GATT_BTLE = (1 << 11), // GATT over Bluetooth LE
- CT_ADAPTER_RFCOMM_BTEDR = (1 << 12), // RFCOMM over Bluetooth EDR
#ifdef RA_ADAPTER
- CT_ADAPTER_REMOTE_ACCESS = (1 << 13), // Remote Access over XMPP
+ /** Remote Access over XMPP.*/
+ CT_ADAPTER_REMOTE_ACCESS = (1 << 19),
#endif
+
+ /** bit shift required for connectivity adapter.*/
#define CT_ADAPTER_SHIFT 10
+
+ /** Mask Flag.*/
#define CT_MASK_FLAGS 0x03FF
+
+ /** Mask Adapter.*/
#define CT_MASK_ADAPTER 0xFC00
- #else // assume 32-bit int
- CT_ADAPTER_IP = (1 << 16), // IPv4 and IPv6, including 6LoWPAN
- CT_ADAPTER_GATT_BTLE = (1 << 17), // GATT over Bluetooth LE
- CT_ADAPTER_RFCOMM_BTEDR = (1 << 18), // RFCOMM over Bluetooth EDR
- #ifdef RA_ADAPTER
- CT_ADAPTER_REMOTE_ACCESS = (1 << 19), // Remote Access over XMPP
- #endif
- #define CT_ADAPTER_SHIFT 16
- #define CT_MASK_FLAGS 0xFFFF
- #define CT_MASK_ADAPTER 0xFFFF0000
+
#endif
- // Insecure transport is the default (subject to change)
- CT_FLAG_SECURE = (1 << 4), // secure the transport path
-
- // IPv4 & IPv6 autoselection is the default
- CT_IP_USE_V6 = (1 << 5), // IP adapter only
- CT_IP_USE_V4 = (1 << 6), // IP adapter only
-
- // Link-Local multicast is the default multicast scope for IPv6.
- // These are placed here to correspond to the IPv6 address bits.
- CT_SCOPE_INTERFACE = 0x1, // IPv6 Interface-Local scope (loopback)
- CT_SCOPE_LINK = 0x2, // IPv6 Link-Local scope (default)
- CT_SCOPE_REALM = 0x3, // IPv6 Realm-Local scope
- CT_SCOPE_ADMIN = 0x4, // IPv6 Admin-Local scope
- CT_SCOPE_SITE = 0x5, // IPv6 Site-Local scope
- CT_SCOPE_ORG = 0x8, // IPv6 Organization-Local scope
- CT_SCOPE_GLOBAL = 0xE, // IPv6 Global scope
+ /** Insecure transport is the default (subject to change).*/
+
+ /** secure the transport path.*/
+ CT_FLAG_SECURE = (1 << 4),
+
+ /** IPv4 & IPv6 autoselection is the default.*/
+
+ /** IP adapter only.*/
+ CT_IP_USE_V6 = (1 << 5),
+
+ /** IP adapter only.*/
+ CT_IP_USE_V4 = (1 << 6),
+
+ /** Link-Local multicast is the default multicast scope for IPv6.
+ * These are placed here to correspond to the IPv6 address bits.*/
+
+ /** IPv6 Interface-Local scope(loopback).*/
+ CT_SCOPE_INTERFACE = 0x1,
+
+ /** IPv6 Link-Local scope (default).*/
+ CT_SCOPE_LINK = 0x2,
+
+ /** IPv6 Realm-Local scope.*/
+ CT_SCOPE_REALM = 0x3,
+
+ /** IPv6 Admin-Local scope.*/
+ CT_SCOPE_ADMIN = 0x4,
+
+ /** IPv6 Site-Local scope.*/
+ CT_SCOPE_SITE = 0x5,
+
+ /** IPv6 Organization-Local scope.*/
+ CT_SCOPE_ORG = 0x8,
+
+ /** IPv6 Global scope.*/
+ CT_SCOPE_GLOBAL = 0xE,
} OCConnectivityType;
/**
- * OCDoResource methods
+ * OCDoResource methods to dispatch the request
*/
typedef enum
{
OC_REST_NOMETHOD = 0,
- OC_REST_GET = (1 << 0), ///< Read
- OC_REST_PUT = (1 << 1), ///< Write
- OC_REST_POST = (1 << 2), ///< Update
- OC_REST_DELETE = (1 << 3), ///< Delete
- /// Register observe request for most up date notifications ONLY.
+
+ /** Read.*/
+ OC_REST_GET = (1 << 0),
+
+ /** Write.*/
+ OC_REST_PUT = (1 << 1),
+
+ /** Update.*/
+ OC_REST_POST = (1 << 2),
+
+ /** Delete.*/
+ OC_REST_DELETE = (1 << 3),
+
+ /** Register observe request for most up date notifications ONLY.*/
OC_REST_OBSERVE = (1 << 4),
- /// Register observe request for all notifications, including stale notifications.
+
+ /** Register observe request for all notifications, including stale notifications.*/
OC_REST_OBSERVE_ALL = (1 << 5),
- /// Deregister observation, intended for internal use
+
+ /** De-register observation, intended for internal use.*/
OC_REST_CANCEL_OBSERVE = (1 << 6),
+
#ifdef WITH_PRESENCE
- /// Subscribe for all presence notifications of a particular resource.
+ /** Subscribe for all presence notifications of a particular resource.*/
OC_REST_PRESENCE = (1 << 7),
+
#endif
- /// Allows OCDoResource caller to do discovery.
+ /** Allows OCDoResource caller to do discovery.*/
OC_REST_DISCOVER = (1 << 8)
} OCMethod;
} OCMode;
/**
- * Quality of Service.
- *
- * OCQualityOfService attempts to abstract the guarantees provided by the underlying transport
- * protocol. The precise definitions of each quality of service level depend on the
- * implementation. In descriptions below are for the current implementation and may changed
+ * Quality of Service attempts to abstract the guarantees provided by the underlying transport
+ * protocol. The precise definitions of each quality of service level depend on the
+ * implementation. In descriptions below are for the current implementation and may changed
* over time.
*/
typedef enum
{
- /// Packet delivery is best effort
+ /** Packet delivery is best effort.*/
OC_LOW_QOS = 0,
- /// Packet delivery is best effort
+
+ /** Packet delivery is best effort.*/
OC_MEDIUM_QOS,
- /// Acknowledgements are used to confirm delivery
+
+ /** Acknowledgments are used to confirm delivery.*/
OC_HIGH_QOS,
- /// No Quality is defined, let the stack decide
+
+ /** No Quality is defined, let the stack decide.*/
OC_NA_QOS
} OCQualityOfService;
*
* ::OC_RES_PROP_NONE When none of the bits are set, the resource is non-discoverable &
* non-observable by the client.
- * ::OC_DISCOVERABLE When this bit is set, the resource is allowed to be discovered by clients.
- * ::OC_OBSERVABLE When this bit is set, the resource is allowed to be observed by clients.
- * ::OC_ACTIVE When this bit is set, the resource is initialized, otherwise the resource
- * is 'inactive'. 'inactive' signifies that the resource has been marked for
- * deletion or is already deleted.
- * ::OC_SLOW When this bit is set, the resource has been marked as 'slow'. 'slow'
- * signifies that responses from this resource can expect delays in
- * processing its requests from clients.
- * ::OC_SECURE When this bit is set, the resource is a secure resource.
+ * ::OC_DISCOVERABLE When this bit is set, the resource is allowed to be discovered by clients.
+ * ::OC_OBSERVABLE When this bit is set, the resource is allowed to be observed by clients.
+
*/
typedef enum
{
+ /** When none of the bits are set, the resource is non-discoverable &
+ * non-observable by the client.*/
OC_RES_PROP_NONE = (0),
+
+ /** When this bit is set, the resource is allowed to be discovered by clients.*/
OC_DISCOVERABLE = (1 << 0),
+
+ /** When this bit is set, the resource is allowed to be observed by clients.*/
OC_OBSERVABLE = (1 << 1),
+
+ /** When this bit is set, the resource is initialized, otherwise the resource
+ * is 'inactive'. 'inactive' signifies that the resource has been marked for
+ * deletion or is already deleted.*/
OC_ACTIVE = (1 << 2),
+
+ /** When this bit is set, the resource has been marked as 'slow'.
+ * 'slow' signifies that responses from this resource can expect delays in
+ * processing its requests from clients.*/
OC_SLOW = (1 << 3),
+
+ /** When this bit is set, the resource is a secure resource.*/
OC_SECURE = (1 << 4)
} OCResourceProperty;
*/
typedef enum
{
+ /** For invalid ID.*/
OC_INVALID_ID = (1 << 0),
+
+ /* For coap ID.*/
OC_COAP_ID = (1 << 1)
} OCTransportProtocolID;
*/
typedef enum
{
- /* Success status code - START HERE */
+ /** Success status code - START HERE.*/
OC_STACK_OK = 0,
OC_STACK_RESOURCE_CREATED,
OC_STACK_RESOURCE_DELETED,
OC_STACK_CONTINUE,
- /* Success status code - END HERE */
- /* Error status code - START HERE */
+ /** Success status code - END HERE.*/
+
+ /** Error status code - START HERE.*/
OC_STACK_INVALID_URI = 20,
OC_STACK_INVALID_QUERY,
OC_STACK_INVALID_IP,
OC_STACK_INVALID_PORT,
OC_STACK_INVALID_CALLBACK,
OC_STACK_INVALID_METHOD,
+
+ /** Invalid parameter.*/
OC_STACK_INVALID_PARAM,
OC_STACK_INVALID_OBSERVE_PARAM,
OC_STACK_NO_MEMORY,
OC_STACK_TIMEOUT,
OC_STACK_ADAPTER_NOT_ENABLED,
OC_STACK_NOTIMPL,
- OC_STACK_NO_RESOURCE, /* resource not found */
- OC_STACK_RESOURCE_ERROR, /* ex: not supported method or interface */
+
+ /** Resource not found.*/
+ OC_STACK_NO_RESOURCE,
+
+ /** e.g: not supported method or interface.*/
+ OC_STACK_RESOURCE_ERROR,
OC_STACK_SLOW_RESOURCE,
OC_STACK_DUPLICATE_REQUEST,
- OC_STACK_NO_OBSERVERS, /* resource has no registered observers */
+
+ /** Resource has no registered observers.*/
+ OC_STACK_NO_OBSERVERS,
OC_STACK_OBSERVER_NOT_FOUND,
OC_STACK_VIRTUAL_DO_NOT_HANDLE,
OC_STACK_INVALID_OPTION,
- OC_STACK_MALFORMED_RESPONSE, /* the remote reply contained malformed data */
+
+ /** The remote reply contained malformed data.*/
+ OC_STACK_MALFORMED_RESPONSE,
OC_STACK_PERSISTENT_BUFFER_REQUIRED,
OC_STACK_INVALID_REQUEST_HANDLE,
OC_STACK_INVALID_DEVICE_INFO,
OC_STACK_INVALID_JSON,
- OC_STACK_UNAUTHORIZED_REQ, /**< Request is not authorized by Resource Server. */
- /* NOTE: Insert all new error codes here!*/
+
+ /** Request is not authorized by Resource Server. */
+ OC_STACK_UNAUTHORIZED_REQ,
+
+ /** Insert all new error codes here!.*/
#ifdef WITH_PRESENCE
OC_STACK_PRESENCE_STOPPED = 128,
OC_STACK_PRESENCE_TIMEOUT,
OC_STACK_PRESENCE_DO_NOT_HANDLE,
#endif
+ /** ERROR in stack.*/
OC_STACK_ERROR = 255
- /* Error status code - END HERE */
+ /** Error status code - END HERE.*/
} OCStackResult;
/**
- * Handle to an @ref OCDoResource invocation.
+ * Handle to an OCDoResource invocation.
*/
typedef void * OCDoHandle;
*/
typedef void * OCResourceHandle;
+/**
+ * Handle to an OCRequest object owned by the OCStack.
+ */
typedef void * OCRequestHandle;
/**
* Unique identifier for each observation request. Used when observations are
- * registered or deregistering. Used by entity handler to signal specific
+ * registered or de-registered. Used by entity handler to signal specific
* observers to be notified of resource changes.
* There can be maximum of 256 observations per server.
*/
*/
typedef enum
{
+ /** To Register. */
OC_OBSERVE_REGISTER = 0,
+
+ /** To Deregister. */
OC_OBSERVE_DEREGISTER = 1,
+
+ /** Others. */
OC_OBSERVE_NO_OPTION = 2
} OCObserveAction;
/**
- * Persistent storage handlers. An app must provide OCPersistentStorage handler pointers when it
- * calls OCRegisterPersistentStorageHandler.
+ * Persistent storage handlers. An APP must provide OCPersistentStorage handler pointers
+ * when it calls OCRegisterPersistentStorageHandler.
+ * Persistent storage open handler points to default file path.
+ * Application can point to appropriate SVR database path for it's IoTivity Server.
*/
typedef struct {
- /*
- * Persistent storage open handler points to default file path.
- * Application can point to appropriate SVR database path for its Iotivity Server.
- */
+ /** Persistent storage file path.*/
FILE* (* open)(const char *path, const char *mode);
- // Persistent storage read handler
+
+ /** Persistent storage read handler.*/
size_t (* read)(void *ptr, size_t size, size_t nmemb, FILE *stream);
- // Persistent storage write handler
+
+ /** Persistent storage write handler.*/
size_t (* write)(const void *ptr, size_t size, size_t nmemb, FILE *stream);
- // Persistent storage close handler
+
+ /** Persistent storage close handler.*/
int (* close)(FILE *fp);
- // Persistent storage unlink handler
+
+ /** Persistent storage unlink handler.*/
int (* unlink)(const char *path);
} OCPersistentStorage;
+/**
+ * Possible returned values from entity handler.
+ */
typedef struct
{
- // Action associated with observation request
+ /** Action associated with observation request.*/
OCObserveAction action;
- // Identifier for observation being registered/deregistered
+
+ /** Identifier for observation being registered/deregistered.*/
OCObservationId obsId;
} OCObservationInfo;
*/
typedef struct OCHeaderOption
{
- // The protocol ID this option applies to
+ /** The protocol ID this option applies to.*/
OCTransportProtocolID protocolID;
- // The header option ID which will be added to communication packets
+
+ /** The header option ID which will be added to communication packets.*/
uint16_t optionID;
- // its length 191
+
+ /** its length 191.*/
uint16_t optionLength;
- // pointer to its data
+
+ /** pointer to its data.*/
uint8_t optionData[MAX_HEADER_OPTION_DATA_LENGTH];
#ifdef __cplusplus
#endif
} OCHeaderOption;
+
/**
- * This structure describes the platform properties. All non-Null properties will be included
- * in a platform discovery request.
+ * This structure describes the platform properties. All non-Null properties will be
+ * included in a platform discovery request.
*/
typedef struct
{
+ /** Platform ID.*/
char *platformID;
+
+ /** Manufacturer name.*/
char *manufacturerName;
+
+ /** Manufacturer URL for platform property.*/
char *manufacturerUrl;
+
+ /** Model number.*/
char *modelNumber;
+
+ /** Manufacturer date.*/
char *dateOfManufacture;
+
+ /** Platform version.*/
char *platformVersion;
+
+ /** Operating system version.*/
char *operatingSystemVersion;
+
+ /** HW version.*/
char *hardwareVersion;
+
+ /** FW version.*/
char *firmwareVersion;
+
+ /** Platform support URL.*/
char *supportUrl;
+
+ /** System time.*/
char *systemTime;
} OCPlatformInfo;
+/**
+ * This structure is expected as input for device properties.
+ * device name is mandatory and expected from the application.
+ * device id of type UUID will be generated by the stack.
+ */
+typedef struct
+{
+ /** Pointer to the device name.*/
+ char *deviceName;
+
+} OCDeviceInfo;
+
#ifdef RA_ADAPTER
/**
- * @brief CA Remote Access information for XMPP Client
+ * CA Remote Access information for XMPP Client
*
*/
typedef struct
} OCRAInfo_t;
#endif /* RA_ADAPTER */
-/**
- * This structure is expected as input for device properties.
- * device name is mandatory and expected from the application.
- * device id of type UUID will be generated by the stack.
- */
-typedef struct
-{
- char *deviceName;
-
-} OCDeviceInfo;
-// Enum to describe the type of object held by the OCPayload object
+/** Enum to describe the type of object held by the OCPayload object.*/
typedef enum
{
PAYLOAD_TYPE_INVALID,
/**
* Incoming requests handled by the server. Requests are passed in as a parameter to the
- * @ref OCEntityHandler callback API.
- * @brief The @ref OCEntityHandler callback API must be implemented in the application in order
+ * OCEntityHandler callback API.
+ * The OCEntityHandler callback API must be implemented in the application in order
* to receive these requests.
*/
typedef struct
{
- // Associated resource
+ /** Associated resource.*/
OCResourceHandle resource;
+
+ /** Associated request handle.*/
OCRequestHandle requestHandle;
- // the REST method retrieved from received request PDU
+
+ /** the REST method retrieved from received request PDU.*/
OCMethod method;
- // description of endpoint that sent the request
+
+ /** description of endpoint that sent the request.*/
OCDevAddr devAddr;
- // resource query send by client
+
+ /** resource query send by client.*/
char * query;
- // Information associated with observation - valid only when OCEntityHandler
- // flag includes OC_OBSERVE_FLAG
+
+ /** Information associated with observation - valid only when OCEntityHandler flag includes
+ * ::OC_OBSERVE_FLAG.*/
OCObservationInfo obsInfo;
- // An array of the received vendor specific header options
+
+ /** Number of the received vendor specific header options.*/
uint8_t numRcvdVendorSpecificHeaderOptions;
+
+ /** Pointer to the array of the received vendor specific header options.*/
OCHeaderOption * rcvdVendorSpecificHeaderOptions;
- // the payload from the request PDU
+
+ /** the payload from the request PDU.*/
OCPayload *payload;
+
+
} OCEntityHandlerRequest;
+
/**
- * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
+ * Response from queries to remote servers. Queries are made by calling the OCDoResource API.
*/
typedef struct
{
- /// Address of remote server
+ /** Address of remote server.*/
OCDevAddr devAddr;
- OCDevAddr *addr; // backward compatibility (points to devAddr)
- OCConnectivityType connType; // backward compatibility
- /// the is the result of our stack, OCStackResult should contain coap/other error codes;
+
+ /** backward compatibility (points to devAddr).*/
+ OCDevAddr *addr;
+
+ /** backward compatibility.*/
+ OCConnectivityType connType;
+
+ /** the is the result of our stack, OCStackResult should contain coap/other error codes.*/
OCStackResult result;
- /// If associated with observe, this will represent the sequence of notifications from server.
+
+ /** If associated with observe, this will represent the sequence of notifications from server.*/
uint32_t sequenceNumber;
- /// resourceURI
+
+ /** resourceURI.*/
const char * resourceUri;
- // the payload for the response PDU
+
+ /** the payload for the response PDU.*/
OCPayload *payload;
- /// An array of the received vendor specific header options
+
+ /** Number of the received vendor specific header options.*/
uint8_t numRcvdVendorSpecificHeaderOptions;
+
+ /** An array of the received vendor specific header options.*/
OCHeaderOption rcvdVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
} OCClientResponse;
+/**
+ * Request handle is passed to server via the entity handler for each incoming request.
+ * Stack assigns when request is received, server sets to indicate what request response is for.
+ */
typedef struct
{
- // Request handle is passed to server via the entity handler for each incoming request.
- // Stack assigns when request is received, server sets to indicate what request response is for
+ /** Request handle.*/
OCRequestHandle requestHandle;
- // Resource handle
+
+ /** Resource handle.*/
OCResourceHandle resourceHandle;
- // Allow the entity handler to pass a result with the response
+
+ /** Allow the entity handler to pass a result with the response.*/
OCEntityHandlerResult ehResult;
- // this is the pointer to server payload data to be transferred
+
+ /** This is the pointer to server payload data to be transferred.*/
OCPayload* payload;
- // An array of the vendor specific header options the entity handler wishes to use in response
+
+ /** number of the vendor specific header options .*/
uint8_t numSendVendorSpecificHeaderOptions;
+
+ /** An array of the vendor specific header options the entity handler wishes to use in response.*/
OCHeaderOption sendVendorSpecificHeaderOptions[MAX_HEADER_OPTIONS];
- // URI of new resource that entity handler might create
+
+ /** URI of new resource that entity handler might create.*/
char resourceUri[MAX_URI_LENGTH];
- // Server sets to true for persistent response buffer, false for non-persistent response buffer
+
+ /** Server sets to true for persistent response buffer,false for non-persistent response buffer*/
uint8_t persistentBufferFlag;
} OCEntityHandlerResponse;
+/**
+ * Entity's state
+ */
typedef enum
{
+ /** Request state.*/
OC_REQUEST_FLAG = (1 << 1),
+ /** Observe state.*/
OC_OBSERVE_FLAG = (1 << 2)
-} OCEntityHandlerFlag; //entity_handler_flag_t ;
+} OCEntityHandlerFlag;
/**
* Possible returned values from client application.
*/
typedef enum
{
- OC_STACK_DELETE_TRANSACTION = 0,//!< OC_STACK_DELETE_TRANSACTION
- OC_STACK_KEEP_TRANSACTION //!< OC_STACK_KEEP_TRANSACTION
+ OC_STACK_DELETE_TRANSACTION = 0,
+ OC_STACK_KEEP_TRANSACTION
} OCStackApplicationResult;
-//-----------------------------------------------------------------------------
-// Callback function definitions
-//-----------------------------------------------------------------------------
+
+/*
+ * -------------------------------------------------------------------------------------------
+ * Callback function definitions
+ * -------------------------------------------------------------------------------------------
+ */
/**
* Client applications implement this callback to consume responses received from Servers.
*/
typedef struct OCCallbackData
{
+ /** Pointer to the context.*/
void *context;
- /// The pointer to a function the stack will call to handle the requests
+
+ /** The pointer to a function the stack will call to handle the requests.*/
OCClientResponseHandler cb;
- /// A pointer to a function to delete the context when this callback is removed
+
+ /** A pointer to a function to delete the context when this callback is removed.*/
OCClientContextDeleter cd;
+
#ifdef __cplusplus
OCCallbackData() = default;
OCCallbackData(void* ctx, OCClientResponseHandler callback, OCClientContextDeleter deleter)