//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#ifndef OC_RESOURCE_H
-#define OC_RESOURCE_H
-
-#include "ocstack.h"
-#include "ocstackinternal.h"
-
-#define OC_RSRVD_OC "oc"
-#define OC_RSRVD_PAYLOAD "payload"
-#define OC_RSRVD_HREF "href"
-#define OC_RSRVD_RESOURCE_TYPE "rt"
-#define OC_RSRVD_INTERFACE "if"
-#define OC_RSRVD_INTERFACE_DEFAULT "oc.mi.def"
-#define OC_RSRVD_INTERFACE_LL "oc.mi.ll"
-#define OC_RSRVD_INTERFACE_BATCH "oc.mi.b"
-#define OC_RSRVD_OBSERVABLE "obs"
-#define OC_RSRVD_SECURE "sec"
-#define OC_RSRVD_HOSTING_PORT "port"
-
-#define OC_JSON_PREFIX "{\"oc\":["
-#define OC_JSON_PREFIX_LEN (sizeof(OC_JSON_PREFIX) - 1)
-#define OC_JSON_SUFFIX "]}"
-#define OC_JSON_SUFFIX_LEN (sizeof(OC_JSON_SUFFIX) - 1)
-#define OC_JSON_SEPARATOR ','
-
-#define OC_RESOURCE_OBSERVABLE 1
-#define OC_RESOURCE_SECURE 1
-
-typedef enum {
- STACK_RES_DISCOVERY_NOFILTER = 0,
- STACK_RES_DISCOVERY_IF_FILTER,
- STACK_RES_DISCOVERY_RT_FILTER
-} StackQueryTypes;
-
-typedef enum {
- OC_RESOURCE_VIRTUAL = 0,
- OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER,
- OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER,
- OC_RESOURCE_COLLECTION_WITH_ENTITYHANDLER,
- OC_RESOURCE_COLLECTION_DEFAULT_ENTITYHANDLER,
- OC_RESOURCE_DEFAULT_DEVICE_ENTITYHANDLER,
- OC_RESOURCE_NOT_SPECIFIED
-} ResourceHandling;
-
-OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag, OCEntityHandlerRequest * request);
-
-const char * GetVirtualResourceUri( OCVirtualResources resource);
-OCResource *FindResourceByUri(const char* resourceUri);
-uint8_t IsVirtualResource(const char* resourceUri);
-
-OCStackResult DetermineResourceHandling (OCRequest *request,
- ResourceHandling *handling,
- OCResource **resource);
-
-OCStackResult
-BuildJSONResponse(ResourceHandling resHandling, OCResource *resource, OCRequest *request);
-
-OCEntityHandlerResult
-BuildObsJSONResponse(OCResource *resource, OCEntityHandlerRequest *ehRequest);
-
-OCStackResult
-BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn,
- char *filterValue, char * out, uint16_t *remaining);
-
-OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
-
-#endif //OC_RESOURCE_H
+/**
+ * @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
+ */
+
+#ifdef WITH_PRESENCE
+typedef struct PRESENCERESOURCE{
+ OCResourceHandle handle;
+ uint32_t presenceTTL;
+} PresenceResource;
+#endif
+
+/**
+ * Forward declarations
+ */
+
+struct rsrc_t;
+
+/**
+ * following structure will be created in occollection.
+ */
+
+typedef struct occapability {
+ /** Linked list; for multiple capabilities.*/
+ struct occapability* next;
+
+ /** 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.
+ */
+
+typedef struct ocaction {
+ /** linked list; for multiple actions. */
+ struct ocaction *next;
+
+ /** 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.
+ */
+
+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 {
+
+ /** 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 {
+
+ /** 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.
+ */
+ char *attrName;
+
+ /** value of the attribute as void. To support both string and @OCStringLL value*/
+ void *attrValue;
+} OCAttribute;
+
+/**
+ * Data structure for holding a resource interface
+ */
+typedef struct resourceinterface_t {
+
+ /** 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)*/
+#if 0
+ char *inputContentType ;
+ char *outputContentType ;
+#endif
+ /** Future placeholder for access control and policy.*/
+} OCResourceInterface;
+
+/**
+ * Data structure for holding child resources associated with a collection
+ */
+typedef struct OCChildResource {
+ struct OCResource *rsrcResource;
+ struct OCChildResource *next;
+} OCChildResource;
+
+/**
+ * Data structure for holding data type and definition for OIC resource.
+ */
+typedef struct OCResource {
+
+ /** Points to next resource in list.*/
+ struct OCResource *next;
+
+ /** Relative path on the device; will be combined with base url to create fully qualified path.*/
+ char *uri;
+
+ /** 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).*/
+
+ /** Child resource(s); linked list.*/
+ OCChildResource *rsrcChildResourcesHead;
+
+ /** 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.*/
+ void * entityHandlerCallbackParam;
+
+ /** 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.*/
+ uint32_t sequenceNum;
+
+ /** Pointer of ActionSet which to support group action.*/
+ OCActionSet *actionsetHead;
+
+ /** The instance identifier for this web link in an array of web links - used in links. */
+ union
+ {
+ /** An ordinal number that is not repeated - must be unique in the collection context. */
+ int64_t ins;
+ /** Any unique string including a URI. */
+ char *uniqueStr;
+ /** Use UUID for universal uniqueness - used in /oic/res to identify the device. */
+ OCIdentity uniqueUUID;
+ };
+} OCResource;
+
+
+
+#endif /* OCRESOURCE_H_ */