Bug Fixed CA InterfaceController for TC-33
authorjihwan.seo <jihwan.seo@samsung.com>
Thu, 9 Apr 2015 07:35:05 +0000 (16:35 +0900)
committerErich Keane <erich.keane@intel.com>
Thu, 9 Apr 2015 15:59:34 +0000 (15:59 +0000)
fixed some problem in TC-33 by transport option
when OIC base code is built with 'TARGET_TRANSPORT=WIFI'
now CA can return a suitable reason for the status
that Network has disabled

Change-Id: Iaf0142cad5db4b0ee287cbeec75add1431d2a754
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/685
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/cainterfacecontroller.c
resource/csdk/connectivity/src/cainterfacecontroller_singlethread.c
resource/csdk/connectivity/test/ca_api_unittest.cpp

index c06d542..96c32a2 100644 (file)
@@ -213,8 +213,6 @@ void CAStopAdapter(CAConnectivityType_t cType)
 
 CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
 {
-    CAResult_t res = CA_STATUS_FAILED;
-
     CALocalConnectivity_t *tempInfo[CA_CONNECTIVITY_TYPE_NUM];
     uint32_t tempSize[CA_CONNECTIVITY_TYPE_NUM];
 
@@ -223,6 +221,7 @@ CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
 
     // #1. get information each adapter
     uint8_t index = 0;
+    CAResult_t res = CA_STATUS_FAILED;
     for (index = 0; index < CA_CONNECTIVITY_TYPE_NUM; index++)
     {
         if (g_adapterHandler[index].GetnetInfo != NULL)
@@ -251,14 +250,18 @@ CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
 
     if (resSize <= 0)
     {
-        res = CA_STATUS_FAILED;
-        return res;
+        if (res == CA_ADAPTER_NOT_ENABLED || res == CA_NOT_SUPPORTED)
+        {
+            return res;
+        }
+        return CA_STATUS_FAILED;
     }
 
     // #3. add data into result
     // memory allocation
 
-    CALocalConnectivity_t *resInfo = (CALocalConnectivity_t *) OICCalloc(resSize, sizeof(CALocalConnectivity_t));
+    CALocalConnectivity_t *resInfo = (CALocalConnectivity_t *) OICCalloc(
+            resSize, sizeof(CALocalConnectivity_t));
     CA_MEMORY_ALLOC_CHECK(resInfo);
 
     uint8_t pos = 0;
@@ -290,11 +293,8 @@ CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
         *size = resSize;
     }
 
-    res = CA_STATUS_OK;
-
     OIC_LOG(DEBUG, TAG, "each network info save success!");
-
-    return res;
+    return CA_STATUS_OK;
 
     // memory error label.
 memory_error_exit:
index 9f26b69..40fff84 100644 (file)
@@ -211,12 +211,11 @@ CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
     VERIFY_NON_NULL(info, TAG, "info");
     VERIFY_NON_NULL(size, TAG, "size");
 
-    CAResult_t res = CA_STATUS_FAILED;
-
     CALocalConnectivity_t *tempInfo[CA_CONNECTIVITY_TYPE_NUM] = { 0 };
     uint32_t tempSize[CA_CONNECTIVITY_TYPE_NUM] = { 0 };
-    uint8_t index = 0;
 
+    uint8_t index = 0;
+    CAResult_t res = CA_STATUS_FAILED;
     // #1. get information each adapter
     for (index = 0; index < CA_CONNECTIVITY_TYPE_NUM; index++)
     {
@@ -245,7 +244,11 @@ CAResult_t CAGetNetworkInfo(CALocalConnectivity_t **info, uint32_t *size)
 
     if (resSize <= 0)
     {
-        return res;
+        if (CA_ADAPTER_NOT_ENABLED == res || CA_NOT_SUPPORTED == res)
+        {
+            return res;
+        }
+        return CA_STATUS_FAILED;
     }
 
     // #3. add data into result
index 863dbe8..a5c4178 100644 (file)
@@ -593,13 +593,11 @@ CAResult_t checkSelectNetwork()
 
     if (CA_STATUS_OK == res)
     {
-        std::cout << "ok";
         g_selectNetworkResult = res;
         return CA_STATUS_OK;
     }
     else if (CA_NOT_SUPPORTED == res)
     {
-        std::cout << "not supported";
         g_selectNetworkResult = res;
         return CA_STATUS_OK;
     }
@@ -726,7 +724,7 @@ CAResult_t checkGetNetworkInfo()
     CAResult_t res = CAGetNetworkInformation(&tempInfo, &tempSize);
 
     if (CA_STATUS_OK == res || CA_ADAPTER_NOT_ENABLED == res ||
-            CA_ADAPTER_NOT_ENABLED == res)
+            CA_NOT_SUPPORTED == res)
     {
         return CA_STATUS_OK;
     }