From: Habib Virji Date: Tue, 5 Apr 2016 00:01:49 +0000 (+0100) Subject: IOT-921 OCSetDeviceInfo to update resource type information X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44b021b3fcaa25a3efd2034c08b330ebd7c17f18;p=contrib%2Fiotivity.git 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 --- 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;