Fix Presence issue of not working on Ethernet
authorShilpa Sodani <shilpa.a.sodani@intel.com>
Thu, 26 Feb 2015 23:10:38 +0000 (15:10 -0800)
committerSashi Penta <sashi.kumar.penta@intel.com>
Fri, 6 Mar 2015 01:36:19 +0000 (01:36 +0000)
Change connectivityType of Presence resource to OC_ALL
Send presence notification on all the n/w interface
Fix IOT-351 & IOT-270
Fixed the if-statement for freeing header options

Change-Id: I553434b77885a466a63fba0968edf400abacb53f
Signed-off-by: Shilpa Sodani <shilpa.a.sodani@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/415
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/csdk/stack/src/ocserverrequest.c
resource/csdk/stack/src/ocstack.c

index 1d82d2e5be6cd9b69815511b0e480e8d4f350a12..2c853073e369116120230fa375cfdb662be278a3 100644 (file)
@@ -403,15 +403,46 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     strcat(payload, (const char *)OC_JSON_SUFFIX);
     responseInfo.info.payload = (CAPayload_t)payload;
 
+    #ifdef WITH_PRESENCE
+    //TODO: Add other connectivity types to CAConnTypes[] when enabled
+    CAConnectivityType_t CAConnTypes[] = {CA_ETHERNET, CA_WIFI};
+    const char * connTypes[] = {"ethernet", "wifi"};
+    int size = sizeof(CAConnTypes)/ sizeof(CAConnectivityType_t);
+    CAConnectivityType_t connType = responseEndpoint.connectivityType;
+    CAResult_t caResult = CA_STATUS_FAILED;
+    result = OC_STACK_OK;
+
+    //Sending response on all n/w interfaces
+    for(int i = 0; i < size; i++ )
+    {
+        responseEndpoint.connectivityType = connType & CAConnTypes[i];
+        if(responseEndpoint.connectivityType)
+        {
+            //The result is set to OC_STACK_OK only if CASendResponse succeeds in sending the
+            //response on all the n/w interfaces else it is set to OC_STACK_ERROR
+            caResult = CASendResponse(&responseEndpoint, &responseInfo);
+            if(caResult != CA_STATUS_OK)
+            {
+                OC_LOG_V(ERROR, TAG, "CASendResponse failed on %s", connTypes[i]);
+                result = OC_STACK_ERROR;
+            }
+            else
+            {
+                OC_LOG_V(INFO, TAG, "CASendResponse succeeded on %s", connTypes[i]);
+            }
+        }
+    }
+    #else
     CAResult_t caResult = CASendResponse(&responseEndpoint, &responseInfo);
     if(caResult != CA_STATUS_OK)
     {
-        OC_LOG(ERROR, TAG, PCF("CASendResponse error"));
+        OC_LOG(ERROR, TAG, PCF("CASendResponse failed"));
     }
     else
     {
         result = OC_STACK_OK;
     }
+    #endif
 
     OCFree(payload);
     //Delete the request
index 4695b770c6cb5d73f9e8c7c3139d24c2ce3ce046..fdb4d428dcb03fb77385a65db35ced9e1e2c39d4 100644 (file)
@@ -1871,9 +1871,11 @@ OCStackResult OCStartPresence(const uint32_t ttl)
             return OC_STACK_ERROR;
         }
 
+        CAConnectivityType_t connType;
+        OCToCAConnectivityType(OC_ALL, &connType );
         AddObserver(OC_PRESENCE_URI, NULL, 0, &caToken,
                 (OCResource *)presenceResource.handle, OC_LOW_QOS,
-                &addressInfo, CA_WIFI);
+                &addressInfo, connType);
     }
 
     // Each time OCStartPresence is called