From bf9d03f2d0187e501c84221a197d12052f4cb648 Mon Sep 17 00:00:00 2001 From: "hyuna0213.jo" Date: Wed, 12 Oct 2016 19:22:48 +0900 Subject: [PATCH] [IOT-1445] Add ins value when publishing a resource to rd The ins value has to be included when publishing a resource to resource-directory. Otherwise resource-directory will return error code. Currently, The ins is not included because the return value of OCGetResourceIns() was not checked properly. Change-Id: I11b1f405e000f36bb76ca7d24c8dbbbd6e7586fe Signed-off-by: hyuna0213.jo Reviewed-on: https://gerrit.iotivity.org/gerrit/13159 Tested-by: jenkins-iotivity Reviewed-by: Ashok Babu Channa (cherry picked from commit b5d331d2d779172bceebb9b92cc73eecc6d6cdae) Reviewed-on: https://gerrit.iotivity.org/gerrit/13225 --- resource/csdk/resource-directory/src/rd_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/resource/csdk/resource-directory/src/rd_client.c b/resource/csdk/resource-directory/src/rd_client.c index 442ba60..eb2ac3b 100644 --- a/resource/csdk/resource-directory/src/rd_client.c +++ b/resource/csdk/resource-directory/src/rd_client.c @@ -171,7 +171,7 @@ OCStackResult OCRDPublishWithDeviceId(const char *host, const unsigned char *id, } uint8_t ins = 0; - if (OCGetResourceIns(handle, &ins)) + if (OC_STACK_OK == OCGetResourceIns(handle, &ins)) { OCRepPayloadSetPropInt(link, OC_RSRVD_INS, ins); } @@ -244,13 +244,15 @@ OCStackResult OCRDDeleteWithDeviceId(const char *host, const unsigned char *id, char targetUri[MAX_URI_LENGTH] = { 0 }; snprintf(targetUri, MAX_URI_LENGTH, "%s%s?di=%s", host, OC_RSRVD_RD_URI, id); + uint8_t len = 0; char queryParam[MAX_URI_LENGTH] = { 0 }; for (uint8_t j = 0; j < nHandles; j++) { OCResource *handle = (OCResource *) resourceHandles[j]; uint8_t ins = 0; OCGetResourceIns(handle, &ins); - snprintf(queryParam, MAX_URI_LENGTH, "&ins=%u", ins); + len += snprintf(queryParam + len, MAX_URI_LENGTH, "&ins=%d", ins); + OIC_LOG_V(DEBUG, TAG, "queryParam [%s]", queryParam); } OICStrcatPartial(targetUri, sizeof(targetUri), queryParam, strlen(queryParam)); -- 2.7.4