From: Sachin Agrawal Date: Thu, 11 Jun 2015 23:39:56 +0000 (-0700) Subject: Updated resource discovery parsing logic for new 'policy' node X-Git-Tag: 1.2.0+RC1~1605 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6206f9cd7c9cdf491718ab6968ea867ca6c12577;p=platform%2Fupstream%2Fiotivity.git Updated resource discovery parsing logic for new 'policy' node Recently resource discovery payload was updated to add a new policy node. This changeset updated the payload parsing logic for secure client application. Change-Id: I3b256a0f3f496fe058890eec92587eb5b2fab241 Signed-off-by: Sachin Agrawal Reviewed-on: https://gerrit.iotivity.org/gerrit/1246 Tested-by: jenkins-iotivity Reviewed-by: Erich Keane --- diff --git a/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp b/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp index e791a28..b3f1a42 100644 --- a/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp +++ b/resource/csdk/stack/samples/linux/secure/occlientbasicops.cpp @@ -432,24 +432,28 @@ int parseClientResponse(OCClientResponse * clientResponse) cJSON * prop = cJSON_GetObjectItem(resource,"prop"); if (prop) { - // If this is a secure resource, the info about the port at which the - // resource is hosted on server is embedded inside discovery JSON response - if (cJSON_GetObjectItem(prop, "sec")) + cJSON * policy = cJSON_GetObjectItem(prop,"p"); + if (policy) { - if ((cJSON_GetObjectItem(prop, "sec")->valueint) == 1) + // If this is a secure resource, the info about the port at which the + // resource is hosted on server is embedded inside discovery JSON response + if (cJSON_GetObjectItem(policy, "sec")) { - coapSecureResource = 1; + if ((cJSON_GetObjectItem(policy, "sec")->valueint) == 1) + { + coapSecureResource = 1; + } } - } - OC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO"); - if (cJSON_GetObjectItem(prop, "port")) - { - port = cJSON_GetObjectItem(prop, "port")->valueint; - OC_LOG_V(INFO, TAG, "Hosting Server Port (embedded inside JSON) -- %u", port); + OC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO"); + if (cJSON_GetObjectItem(policy, "port")) + { + port = cJSON_GetObjectItem(policy, "port")->valueint; + OC_LOG_V(INFO, TAG, "Hosting Server Port (embedded inside JSON) -- %u", port); - std::ostringstream ss; - ss << port; - coapServerPort = ss.str(); + std::ostringstream ss; + ss << port; + coapServerPort = ss.str(); + } } }