Removing resourceAttributeRepresentation and allowedMethods parameters through the...
authorSashi Penta <sashi.kumar.penta@intel.com>
Wed, 6 Aug 2014 21:41:19 +0000 (14:41 -0700)
committerSashi Penta <sashi.kumar.penta@intel.com>
Wed, 6 Aug 2014 21:41:19 +0000 (14:41 -0700)
OCLib/InProcServerWrapper.cpp
csdk/stack/include/internal/ocstackinternal.h
csdk/stack/include/ocstack.h
csdk/stack/samples/SimpleClientServer/ocserver.cpp
csdk/stack/src/ocstack.c

index a051ea4..df67b06 100644 (file)
@@ -190,9 +190,7 @@ namespace OC
 
             result = OCCreateResource(&resourceHandle, // OCResourceHandle *handle
                             resourceTypeName.c_str(), // const char * resourceTypeName
-                            "state:oc.bt.b;power:oc.bt.i", // TODO @SASHI why are we still sending this??
                             resourceInterface.c_str(), //const char * resourceInterfaceName //TODO fix this
-                            OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods
                             resourceURI.c_str(), // const char * uri
                             entityHandler, // OCEntityHandler entityHandler
                             resourceProperties // uint8_t resourceProperties
index b619d3f..879ae88 100644 (file)
@@ -59,10 +59,6 @@ typedef struct resourcetype_t {
     // 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;
-    // An array of strings; each string defines the attribute and attribute data type.
-    // NOTE: this is not the same as the request/response payload representation;
-    // but is the definition of attribute/value pairs that go into the payload
-    char *typerepresentation;
 } OCResourceType;
 
 typedef struct attr_t {
@@ -81,10 +77,7 @@ typedef struct resourceinterface_t {
     // 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 ;
-    // Allowed methods on this resource through this interface
-    // Use the methods in OCMethod to create a bitmap
-    // Example: OC_REST_GET|OC_REST_PUT.
-    uint8_t allowedMethods;
+
     // 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
index ec955da..6167834 100644 (file)
@@ -277,10 +277,7 @@ OCStackResult OCCancel(OCDoHandle handle);
  *
  * @param handle - pointer to handle to newly created resource.  Set by ocstack.  Used to refer to resource
  * @param resourceTypeName - name of resource type.  Example: "core.led"
- * @param resourceAttributeRepresentation - attribute representation.  list of attributes:type, with each pair
- *                                          separated by semicolons.  Example:  "state:oc.bt.b;power:oc.bt.i"
  * @param resourceInterfaceName - name of resource interface.  Example: "core.rw"
- * @param allowedMethods - methods permitted on interface.  Example: OC_REST_GET|OC_REST_PUT
  * @param uri - URI of the resource.  Example:  "/a/led"
  * @param entityHandler - entity handler function that is called by ocstack to handle requests, etc
  * @param resourceProperties - properties supported by resource.  Example: OC_DISCOVERABLE|OC_OBSERVABLE
@@ -291,9 +288,7 @@ OCStackResult OCCancel(OCDoHandle handle);
  */
 OCStackResult OCCreateResource(OCResourceHandle *handle,
                                const char *resourceTypeName,
-                               const char *resourceAttributeRepresentation,
                                const char *resourceInterfaceName,
-                               uint8_t allowedMethods,
                                const char *uri,
                                OCEntityHandler entityHandler,
                                uint8_t resourceProperties);
@@ -315,30 +310,25 @@ OCStackResult OCBindContainedResourceToResource(OCResourceHandle containerHandle
  *
  * @param handle - handle to the container resource
  * @param resourceTypeName - name of resource type.  Example: "core.led"
- * @param resourceAttributeRepresentation - attribute representation.  list of attributes:type, with each pair
- *                                          separated by semicolons.  Example:  "state:oc.bt.b;power:oc.bt.i"
  *
  * @return
  *     OC_STACK_OK    - no errors
  *     OC_STACK_ERROR - stack process error
  */
 OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
-                                           const char *resourceTypeName,
-                                           const char *resourceAttributeRepresentation);
+                                           const char *resourceTypeName);
 /**
  * Bind a resource interface to a resource.
  *
  * @param handle - handle to the container resource
  * @param resourceInterfaceName - name of resource interface.  Example: "core.rw"
- * @param allowedMethods - methods permitted on interface.  Example: OC_REST_GET|OC_REST_PUT
  *
  * @return
  *     OC_STACK_OK    - no errors
  *     OC_STACK_ERROR - stack process error
  */
 OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle,
-                                                const char *resourceInterfaceName,
-                                                uint8_t allowedMethods);
+                                                const char *resourceInterfaceName);
 
 /**
  * Bind an entity handler to the resource.
index d4bd3f5..cb9e222 100644 (file)
@@ -169,9 +169,7 @@ void createLEDResource() {
        LED.state = false;
        OCStackResult res = OCCreateResource(&LED.handle,
                        "core.led",
-                       "state:oc.bt.b;power:oc.bt.i",
                        "core.rw",
-                       OC_REST_GET|OC_REST_PUT,
                        "/a/led",
                        OCEntityHandlerCb,
                        OC_DISCOVERABLE|OC_OBSERVABLE);
index cea6415..8237f07 100644 (file)
@@ -416,10 +416,7 @@ OCStackResult OCProcess() {
  *
  * @param handle - pointer to handle to newly created resource.  Set by ocstack.  Used to refer to resource
  * @param resourceTypeName - name of resource type.  Example: "core.led"
- * @param resourceAttributeRepresentation - attribute representation.  list of attributes:type, with each pair
- *                                          separated by semicolons.  Example:  "state:oc.bt.b;power:oc.bt.i"
  * @param resourceInterfaceName - name of resource interface.  Example: "core.rw"
- * @param allowedMethods - methods permitted on interface.  Example: OC_REST_GET|OC_REST_PUT
  * @param uri - URI of the resource.  Example:  "/a/led"
  * @param entityHandler - entity handler function that is called by ocstack to handle requests, etc
  * @param resourceProperties - properties supported by resource.  Example: OC_DISCOVERABLE|OC_OBSERVABLE
@@ -430,8 +427,7 @@ OCStackResult OCProcess() {
  */
 OCStackResult OCCreateResource(OCResourceHandle *handle,
         const char *resourceTypeName,
-        const char *resourceAttributeRepresentation,
-        const char *resourceInterfaceName, uint8_t allowedMethods,
+        const char *resourceInterfaceName, 
         const char *uri, OCEntityHandler entityHandler,
         uint8_t resourceProperties) {
 
@@ -443,23 +439,12 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
     OC_LOG(INFO, TAG, PCF("Entering OCCreateResource"));
 
     // Validate parameters
-    // TODO:  Does resource attribute representation really have to be maintained in stack?
     // Is it presented during resource discovery?
-    //    VERIFY_NON_NULL(resourceAttributeRepresentation, ERROR, OC_STACK_ERROR);
     if (!handle || !resourceTypeName || !resourceInterfaceName || !uri) {
         OC_LOG(ERROR, TAG, PCF("Input parameter is NULL"));
         return OC_STACK_INVALID_PARAM;
     }
 
-    // Make sure allowedMethods bitmask has allowed methods specified
-    if ((allowedMethods
-            > (OC_REST_GET | OC_REST_PUT | OC_REST_POST | OC_REST_DELETE
-                    | OC_REST_OBSERVE))
-            || (allowedMethods == OC_REST_NOMETHOD)) {
-        OC_LOG(ERROR, TAG, PCF("Invalid method"));
-        return OC_STACK_INVALID_PARAM;
-    }
-
     // Make sure resourceProperties bitmask has allowed properties specified
     if (resourceProperties
             > (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW)) {
@@ -504,7 +489,7 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
 
     // Add the resourcetype to the resource
     result = OCBindResourceTypeToResource((OCResourceHandle) pointer,
-            resourceTypeName, resourceAttributeRepresentation);
+            resourceTypeName); 
     if (result != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, PCF("Error adding resourcetype"));
         goto exit;
@@ -512,7 +497,7 @@ OCStackResult OCCreateResource(OCResourceHandle *handle,
 
     // Add the resourceinterface to the resource
     result = OCBindResourceInterfaceToResource((OCResourceHandle) pointer,
-            resourceInterfaceName, allowedMethods);
+            resourceInterfaceName);
     if (result != OC_STACK_OK) {
         OC_LOG(ERROR, TAG, PCF("Error adding resourceinterface"));
         goto exit;
@@ -589,16 +574,13 @@ OCStackResult OCBindContainedResourceToResource(
  *
  * @param handle - handle to the container resource
  * @param resourceTypeName - name of resource type.  Example: "core.led"
- * @param resourceAttributeRepresentation - attribute representation.  list of attributes:type, with each pair
- *                                          separated by semicolons.  Example:  "state:oc.bt.b;power:oc.bt.i"
  *
  * @return
  *     OC_STACK_OK    - no errors
  *     OC_STACK_ERROR - stack process error
  */
 OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
-        const char *resourceTypeName,
-        const char *resourceAttributeRepresentation) {
+        const char *resourceTypeName) {
 
     OCResourceType *pointer = NULL;
     char *str = NULL;
@@ -612,7 +594,6 @@ OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
     VERIFY_NON_NULL(resourceTypeName, ERROR, OC_STACK_INVALID_PARAM);
     // TODO:  Does resource attribute resentation really have to be maintained in stack?
     // Is it presented during resource discovery?
-    // VERIFY_NON_NULL(resourceAttributeRepresentation, ERROR, OC_STACK_ERROR);
 
     // Make sure resource exists
     resource = findResource((OCResource *) handle);
@@ -639,17 +620,7 @@ OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
     strncpy(str, resourceTypeName, size);
     pointer->resourcetypename = str;
 
-    // If the resourceAttributeRepresentation is defined, add it.
-    if (resourceAttributeRepresentation) {
-        size = strlen(resourceAttributeRepresentation) + 1;
-        str = (char *) OCMalloc(size);
-        if (!str) {
-            goto exit;
-        }
-        strncpy(str, resourceAttributeRepresentation, size);
-        pointer->typerepresentation = str;
-    }
-    // Bind the resourcetype to the resource
+   // Bind the resourcetype to the resource
     insertResourceType(resource, pointer);
 
     result = OC_STACK_OK;
@@ -666,14 +637,13 @@ OCStackResult OCBindResourceTypeToResource(OCResourceHandle handle,
  *
  * @param handle - handle to the container resource
  * @param resourceInterfaceName - name of resource interface.  Example: "core.rw"
- * @param allowedMethods - methods permitted on interface.  Example: OC_REST_GET|OC_REST_PUT
  *
  * @return
  *     OC_STACK_OK    - no errors
  *     OC_STACK_ERROR - stack process error
  */
 OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle,
-        const char *resourceInterfaceName, uint8_t allowedMethods) {
+        const char *resourceInterfaceName) {
 
     OCResourceInterface *pointer = NULL;
     char *str = NULL;
@@ -686,15 +656,6 @@ OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle,
     // Validate parameters
     VERIFY_NON_NULL(resourceInterfaceName, ERROR, OC_STACK_INVALID_PARAM);
 
-    // Make sure allowedMethods bitmask has allowed methods specified
-    if ((allowedMethods
-            > (OC_REST_GET | OC_REST_PUT | OC_REST_POST | OC_REST_DELETE
-                    | OC_REST_OBSERVE))
-            || (allowedMethods == OC_REST_NOMETHOD)) {
-        OC_LOG(ERROR, TAG, PCF("Invalid method"));
-        return OC_STACK_INVALID_PARAM;
-    }
-
     // Make sure resource exists
     resource = findResource((OCResource *) handle);
     if (!resource) {
@@ -720,8 +681,6 @@ OCStackResult OCBindResourceInterfaceToResource(OCResourceHandle handle,
     strncpy(str, resourceInterfaceName, size);
     pointer->name = str;
 
-    pointer->allowedMethods = allowedMethods;
-
     // Bind the resourceinterface to the resource
     insertResourceInterface(resource, pointer);
 
@@ -899,28 +858,7 @@ const char *OCGetResourceTypeName(OCResourceHandle handle, uint8_t index) {
     return (const char *) NULL;
 }
 
-/**
- * Get attributes of resource type of the resource.
- *
- * @param handle - handle of resource
- * @param index - index of resource, 0 to Count - 1
- *
- * @return
- *    resource type attributes - if resource found
- *    NULL - resource not found
- */
-const char *OCGetResourceAttributeRepresentation(OCResourceHandle handle,
-        uint8_t index) {
-    OCResourceType *resourceType;
 
-    OC_LOG(INFO, TAG, PCF("Entering OCGetResourceAttributeRepresentation"));
-
-    resourceType = findResourceTypeAtIndex(handle, index);
-    if (resourceType) {
-        return resourceType->typerepresentation;
-    }
-    return (const char *) NULL;
-}
 
 /**
  * Get the number of resource interfaces of the resource.
@@ -978,29 +916,6 @@ const char *OCGetResourceInterfaceName(OCResourceHandle handle, uint8_t index) {
 }
 
 /**
- * Get methods of resource interface of the resource.
- *
- * @param handle - handle of resource
- * @param index - index of resource, 0 to Count - 1
- *
- * @return
- *    allowed methods - if resource found
- *    NULL - resource not found
- */
-uint8_t OCGetResourceInterfaceAllowedMethods(OCResourceHandle handle,
-        uint8_t index) {
-    OCResourceInterface *resourceInterface;
-
-    OC_LOG(INFO, TAG, PCF("Entering OCGetResourceInterfaceAllowedMethods"));
-
-    resourceInterface = findResourceInterfaceAtIndex(handle, index);
-    if (resourceInterface) {
-        return resourceInterface->allowedMethods;
-    }
-    return (uint8_t) 0;
-}
-
-/**
  * Get name of resource interface of the resource.
  *
  * @param containerHandle - handle of container resource
@@ -1247,7 +1162,6 @@ void deleteResourceType(OCResourceType *resourceType) {
     while (pointer) {
         next = pointer->next;
         OCFree(pointer->resourcetypename);
-        OCFree(pointer->typerepresentation);
         OCFree(pointer);
         pointer = next;
     }