IOT-921 OCSetDeviceInfo to update resource type information
authorHabib Virji <habib.virji@samsung.com>
Tue, 5 Apr 2016 00:01:49 +0000 (01:01 +0100)
committerHabib Virji <habib.virji@samsung.com>
Thu, 7 Apr 2016 00:54:28 +0000 (00:54 +0000)
OCSaveDeviceInfo to  update resource information. The code has been
updated to include this information.

Change-Id: Id30546d0e32f5347875a9346de9699a35d81734e
Signed-off-by: Habib Virji <habib.virji@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7585
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp
resource/csdk/stack/src/ocstack.c

index 5eaa227..cc5e968 100644 (file)
@@ -1051,7 +1051,6 @@ int main(int argc, char* argv[])
         exit (EXIT_FAILURE);
     }
 
-    OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.wk.d");
     OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
 
     registrationResult = OCSetDeviceInfo(deviceInfo);
index 9fa52e3..faf5108 100644 (file)
@@ -992,7 +992,6 @@ int main(int argc, char* argv[])
         exit (EXIT_FAILURE);
     }
 
-    OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.wk.d");
     OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
 
     registrationResult = OCSetDeviceInfo(deviceInfo);
index 7fe2254..5ca4deb 100644 (file)
@@ -3042,6 +3042,23 @@ OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo)
         return OC_STACK_INVALID_PARAM;
     }
 
+    if (deviceInfo.types)
+    {
+        OCStringLL *type =  deviceInfo.types;
+        OCResource *resource = findResource((OCResource *) deviceResource);
+        if (!resource)
+        {
+            return OC_STACK_INVALID_PARAM;
+        }
+        deleteResourceType(resource->rsrcType);
+        resource->rsrcType = NULL;
+
+        while (type)
+        {
+            OCBindResourceTypeToResource(deviceResource, type->value);
+            type = type->next;
+        }
+    }
     return SaveDeviceInfo(deviceInfo);
 }
 
@@ -3393,6 +3410,7 @@ OCStackResult BindResourceTypeToResource(OCResource* resource,
         goto exit;
     }
     pointer->resourcetypename = str;
+    pointer->next = NULL;
 
     insertResourceType(resource, pointer);
     result = OC_STACK_OK;