[IOT-1043] [RI] Canceling observation using RESET is not working
authorAbhishek Sharma <ce.abhishek@samsung.com>
Wed, 30 Mar 2016 00:15:57 +0000 (09:15 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Fri, 1 Apr 2016 06:59:16 +0000 (06:59 +0000)
Related JIRA ticket : https://jira.iotivity.org/browse/IOT-1043

Change-Id: I7f984fe8f649af0681352fed14f8a37d73b2eba9
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Signed-off-by: Abhishek Sharma <ce.abhishek@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7451
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sungkyu Ko <sungkyu.ko@samsung.com>
Reviewed-by: Gihong Kim <k1358.kim@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/cablockwisetransfer.c
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/stack/samples/linux/SimpleClientServer/occlient.cpp

index ad4cee3..c93ca1c 100644 (file)
@@ -314,12 +314,16 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
     {
         OIC_LOG(DEBUG, TAG, "code is CA_EMPTY..");
 
-        // get token from block-wise transfer list when CA_EMPTY(RST/ACK) is received
-        CAResult_t res = CAGetTokenFromBlockDataList(pdu, endpoint, receivedData->responseInfo);
-        if (CA_STATUS_OK != res)
+        if (!receivedData->responseInfo->info.token)
         {
-            OIC_LOG(ERROR, TAG, "fail to get token");
-            return res;
+            // get token from block-wise transfer list when CA_EMPTY(RST/ACK) is received
+            CAResult_t res = CAGetTokenFromBlockDataList(pdu, endpoint,
+                                                         receivedData->responseInfo);
+            if (CA_STATUS_OK != res)
+            {
+                OIC_LOG(ERROR, TAG, "fail to get token");
+                return res;
+            }
         }
 
         CABlockDataID_t* blockDataID = CACreateBlockDatablockId(
@@ -334,12 +338,10 @@ CAResult_t CAReceiveBlockWiseData(coap_pdu_t *pdu, const CAEndpoint_t *endpoint,
                 OIC_LOG(INFO, TAG, "retransmission was stopped");
                 return CA_REQUEST_TIMEOUT;
             }
-            else
-            {
-                OIC_LOG(ERROR, TAG, "blockId is null");
-                CADestroyBlockID(blockDataID);
-                return CA_STATUS_FAILED;
-            }
+
+            OIC_LOG(ERROR, TAG, "blockId is null");
+            CADestroyBlockID(blockDataID);
+            return CA_STATUS_FAILED;
         }
 
         CARemoveBlockDataFromList(blockDataID);
index 09b5b4b..e2eb295 100644 (file)
@@ -781,7 +781,6 @@ static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
             CARetransmissionReceivedData(&g_retransmissionContext, cadata->remoteEndpoint, pdu->hdr,
                                          pdu->length, &retransmissionPdu);
 
-#ifndef WITH_BWT
             // get token from saved data in retransmission list
             if (retransmissionPdu && CA_EMPTY == code)
             {
@@ -798,7 +797,6 @@ static void CAReceivedPacketCallback(const CASecureEndpoint_t *sep,
                     }
                 }
             }
-#endif
             OICFree(retransmissionPdu);
         }
     }
index 5a4671b..23053e7 100644 (file)
@@ -396,12 +396,22 @@ OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
         }
 
         OCResourcePayload *resource = (OCResourcePayload*) payload->resources;
-        if (!resource)
+        int found = 0;
+        while (resource)
         {
-            OIC_LOG_V (INFO, TAG, "No resources in payload");
-            return OC_STACK_DELETE_TRANSACTION;
+            if(resource->uri && strcmp(resource->uri, coapServerResource.c_str()) == 0)
+            {
+                found = 1;
+                break;
+            }
+            resource = resource->next;
+        }
+
+        if(!found)
+        {
+            OIC_LOG_V (INFO, TAG, "No /a/light in payload");
+            return OC_STACK_KEEP_TRANSACTION;
         }
-        coapServerResource =  resource->uri;
 
         switch(TestCase)
         {