From 44b021b3fcaa25a3efd2034c08b330ebd7c17f18 Mon Sep 17 00:00:00 2001 From: Habib Virji Date: Tue, 5 Apr 2016 01:01:49 +0100 Subject: [PATCH] IOT-921 OCSetDeviceInfo to update resource type information OCSaveDeviceInfo to update resource information. The code has been updated to include this information. Change-Id: Id30546d0e32f5347875a9346de9699a35d81734e Signed-off-by: Habib Virji Reviewed-on: https://gerrit.iotivity.org/gerrit/7585 Tested-by: jenkins-iotivity Reviewed-by: Markus Jung Reviewed-by: Uze Choi (cherry picked from commit 2ccfba677941ada7bc3730538132182ce9fb872d) Reviewed-on: https://gerrit.iotivity.org/gerrit/7833 --- .../samples/linux/SimpleClientServer/ocserver.cpp | 1 - .../samples/tizen/SimpleClientServer/ocserver.cpp | 1 - resource/csdk/stack/src/ocstack.c | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp index 5eaa227..cc5e968 100644 --- a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp +++ b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp @@ -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); diff --git a/resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp b/resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp index 9fa52e3..faf5108 100644 --- a/resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp +++ b/resource/csdk/stack/samples/tizen/SimpleClientServer/ocserver.cpp @@ -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); diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index 3112a1f..f3ff717 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -3038,6 +3038,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); } @@ -3389,6 +3406,7 @@ OCStackResult BindResourceTypeToResource(OCResource* resource, goto exit; } pointer->resourcetypename = str; + pointer->next = NULL; insertResourceType(resource, pointer); result = OC_STACK_OK; -- 2.7.4