Adding retry logic for gatt connection for VD client
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / tizen / caleclient.c
index 561e2bf..f6cb5b8 100644 (file)
@@ -58,7 +58,6 @@ static int g_retrycount = 0;
 static int retry_flag = 0;
 uint64_t const TIMEOUT = 30 * MICROSECS_PER_SEC;
 
-#ifndef TIZEN_VD
 /**
  * Mutex to call connect only after disconnect during retry
  */
@@ -68,7 +67,6 @@ static oc_mutex g_isDisconnectedMutex = NULL;
  * Condition for calling connect during connection retry
  */
 static oc_cond g_LEDisconnectedCond = NULL;
-#endif
 
 /**
  * Flag to check if scanning is in progress
@@ -290,10 +288,8 @@ CAResult_t CALEGattInitiateConnection(const char *remoteAddress)
         return CA_STATUS_FAILED;
     }
     g_isConnectionInProgress = true;
-#ifndef TIZEN_VD
     // Set gatt connect retry count
     g_retrycount = RETRY_COUNT;
-#endif
     oc_mutex_unlock(g_isConnectionInProgressMutex);
 
     // Pause the scanning
@@ -340,11 +336,6 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress)
     if (!connected)
     {
         OIC_LOG_V(DEBUG, TAG, "DisConnected from [%s] ", remoteAddress);
-#ifdef TIZEN_VD
-        oc_mutex_lock(g_LEServerListMutex);
-        CARemoveLEServerInfoFromList(&g_LEServerList, remoteAddress);
-        oc_mutex_unlock(g_LEServerListMutex);
-#else
         if(!retry_flag)
         {
             oc_mutex_lock(g_LEServerListMutex);
@@ -358,7 +349,6 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress)
             oc_mutex_unlock(g_isDisconnectedMutex);
         }
         retry_flag = 0;
-#endif
     }
     else
     {
@@ -577,7 +567,6 @@ void CALEAdapterScanResultCb(int result, bt_adapter_le_device_scan_result_info_s
         oc_mutex_unlock(g_LEServerListMutex);
     }
 
-
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
@@ -941,7 +930,6 @@ CAResult_t CAInitGattClientMutexVariables()
         }
     }
 
-#ifndef TIZEN_VD
     if (NULL == g_isDisconnectedMutex)
     {
         g_isDisconnectedMutex = oc_mutex_new();
@@ -961,7 +949,6 @@ CAResult_t CAInitGattClientMutexVariables()
             return CA_STATUS_FAILED;
         }
     }
-#endif
 
     if (NULL == g_startTimerCond)
     {
@@ -1045,13 +1032,11 @@ void CATerminateGattClientMutexVariables()
     oc_mutex_free(g_threadMTUChangedMutex);
     g_threadMTUChangedMutex = NULL;
 
-#ifndef TIZEN_VD
     oc_mutex_free(g_isDisconnectedMutex);
     g_isDisconnectedMutex = NULL;
 
     oc_cond_free(g_LEDisconnectedCond);
     g_LEDisconnectedCond = NULL;
-#endif
 
     oc_cond_free(g_startTimerCond);
     g_startTimerCond = NULL;
@@ -1321,7 +1306,6 @@ void CADiscoverLEServicesThread(void *remoteAddress)
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
-#ifndef TIZEN_VD
 static int CALEWaittillDisconnect(oc_mutex mutex, oc_cond cv, int wait_seconds)
 {
     OIC_LOG(DEBUG, TAG, "Waiting for server to be disconnected...");
@@ -1344,7 +1328,6 @@ static CAResult_t CALEGattConnectionRetry(const char *remoteAddress)
     OIC_LOG(DEBUG, TAG, "OUT");
     return result;
 }
-#endif
 
 CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
 {
@@ -1370,9 +1353,7 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
     {
         OIC_LOG_V(ERROR, TAG,
                   "bt_gatt_client_get_service Failed with ret value [%s] ", CALEGetErrorMsg(ret));
-#ifdef TIZEN_VD
-        goto error_exit;
-#else
+
         if(g_retrycount)
         {
             OIC_LOG(DEBUG, TAG, "Retry will be attempted to connect Gatt Server");
@@ -1392,7 +1373,6 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
                 return CA_STATUS_FAILED;
             }
         }
-#endif
     }
 
     retry_flag = 0;