From 7f8b00932b2d75b6bd92f1b66792a5eaea29259b Mon Sep 17 00:00:00 2001 From: "arya.k" Date: Fri, 5 May 2017 17:23:40 +0530 Subject: [PATCH] [IOT-1891] [RI] Issue fix OBSERVE Cancellation High QoS When cancel observe is requested by client, the callback should return a sequence number greater than MAX_SEQUENCE_NUMBER, and with no observe header option. Currently it is returning 0 which is not correct.So stack has been modified to return a higher sequence number with the callback for cancel observe confirmed response. Change-Id: I85ea87454e3ca96f22fe7e414189ec0be7ea8dd8 Signed-off-by: arya.k Reviewed-on: https://gerrit.iotivity.org/gerrit/19651 Reviewed-by: Uze Choi Tested-by: jenkins-iotivity Reviewed-by: Ashok Babu Channa --- resource/csdk/stack/src/ocstack.c | 1 + resource/examples/simpleclient.cpp | 2 ++ resource/examples/simpleclientHQ.cpp | 4 +++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index a53ec1b..0706e85 100644 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -1673,6 +1673,7 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp } response->devAddr.adapter = OC_DEFAULT_ADAPTER; + response->sequenceNumber = MAX_SEQUENCE_NUMBER + 1; CopyEndpointToDevAddr(endPoint, &response->devAddr); FixUpClientResponse(response); response->resourceUri = responseInfo->info.resourceUri; diff --git a/resource/examples/simpleclient.cpp b/resource/examples/simpleclient.cpp index 62cdc7e..f17da35 100644 --- a/resource/examples/simpleclient.cpp +++ b/resource/examples/simpleclient.cpp @@ -110,6 +110,8 @@ void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& re std::cout << "No observe option header is returned in the response." << std::endl; std::cout << "For a registration request, it means the registration failed" << std::endl; + std::cout << "For a cancelation request, it means the cancelation was successful" + << std::endl; } else { diff --git a/resource/examples/simpleclientHQ.cpp b/resource/examples/simpleclientHQ.cpp index 78a7794..29247ce 100644 --- a/resource/examples/simpleclientHQ.cpp +++ b/resource/examples/simpleclientHQ.cpp @@ -37,6 +37,8 @@ #include #endif +#define MAX_SEQUENCE_NUMBER (0xFFFFFF) + using namespace OC; struct dereference_compare @@ -85,7 +87,7 @@ void onObserve(const HeaderOptions /*headerOptions*/, const OCRepresentation& re { std::cout << "\tObserve Registration Confirmed: "<< std::endl; } - else if (sequenceNumber == (int) ObserveAction::ObserveUnregister) + else if (sequenceNumber == (MAX_SEQUENCE_NUMBER + 1)) { std::cout << "\tObserve Cancel Confirmed: "<< std::endl; sleep(10); -- 2.7.4