[IOT-1891] [RI] Issue fix OBSERVE Cancellation High QoS
authorarya.k <arya.kumar@samsung.com>
Fri, 5 May 2017 11:53:40 +0000 (17:23 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Thu, 11 May 2017 05:53:58 +0000 (05:53 +0000)
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 <arya.kumar@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/19651
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/src/ocstack.c
resource/examples/simpleclient.cpp
resource/examples/simpleclientHQ.cpp

index a53ec1b..0706e85 100644 (file)
@@ -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;
index 62cdc7e..f17da35 100644 (file)
@@ -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
             {
index 78a7794..29247ce 100644 (file)
@@ -37,6 +37,8 @@
 #include <windows.h>
 #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);