Send ack response when the request is CON for presence
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Tue, 23 Aug 2016 01:15:53 +0000 (10:15 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Wed, 24 Aug 2016 12:00:48 +0000 (12:00 +0000)
If resource-client subscribe presence with CON, resource-server
should send the response message to stop the retransmission.

Change-Id: I90008dffc6a8940c9f1645c27d4ded6efa6d9421
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/10755
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/src/ocresource.c

index a559413..42b1e24 100755 (executable)
@@ -827,6 +827,15 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
     if ((virtualUriInRequest == OC_PRESENCE) &&
         (resource->resourceProperties & OC_ACTIVE))
     {
+        // Need to send ACK when the request is CON.
+        if (request->qos == OC_HIGH_QOS)
+        {
+            CAEndpoint_t endpoint = { .adapter = CA_DEFAULT_ADAPTER };
+            CopyDevAddrToEndpoint(&request->devAddr, &endpoint);
+            SendDirectStackResponse(&endpoint, request->coapID, CA_EMPTY, CA_MSG_ACKNOWLEDGE,
+                                    0, NULL, NULL, 0, NULL, CA_RESPONSE_FOR_RES);
+        }
+
         // Presence uses observer notification api to respond via SendPresenceNotification.
         SendPresenceNotification(resource->rsrcType, OC_PRESENCE_TRIGGER_CHANGE);
     }