X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fsrc%2Fbt_le_adapter%2Ftizen%2Fcaleclient.c;h=67a44ea7b3309f51ba08bf006c1a4299b324a027;hb=1cee1631595cac6a6394ac2e0b365c6dd5a42c68;hp=3d4fd248f03e3cecc9174bb8b094c1f554f35cfa;hpb=390866079e285d2c74918432c0d597d5da52f8a0;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c index 3d4fd24..67a44ea 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c @@ -247,6 +247,9 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress) if (!connected) { OIC_LOG_V(DEBUG, TAG, "DisConnected from [%s] ", remoteAddress); + ca_mutex_lock(g_LEServerListMutex); + CARemoveLEServerInfoFromList(&g_LEServerList, remoteAddress); + ca_mutex_unlock(g_LEServerListMutex); } else { @@ -373,40 +376,12 @@ CAResult_t CAStartLEGattClient() { OIC_LOG(DEBUG, TAG, "IN"); - ca_mutex_lock(g_LEClientThreadPoolMutex); - if (NULL == g_LEClientThreadPool) - { - OIC_LOG(ERROR, TAG, "gBleServerThreadPool is NULL"); - CATerminateGattClientMutexVariables(); - ca_mutex_unlock(g_LEClientThreadPoolMutex); - return CA_STATUS_FAILED; - } - - CAResult_t result = ca_thread_pool_add_task(g_LEClientThreadPool, CAStartLEGattClientThread, - NULL); - if (CA_STATUS_OK != result) - { - OIC_LOG(ERROR, TAG, "ca_thread_pool_add_task failed"); - CATerminateGattClientMutexVariables(); - ca_mutex_unlock(g_LEClientThreadPoolMutex); - return CA_STATUS_FAILED; - } - ca_mutex_unlock(g_LEClientThreadPoolMutex); - - OIC_LOG(DEBUG, TAG, "OUT"); - return CA_STATUS_OK; -} - -void CAStartLEGattClientThread(void *data) -{ - OIC_LOG(DEBUG, TAG, "IN"); - ca_mutex_lock(g_LEClientStateMutex); if (true == g_isLEGattClientStarted) { OIC_LOG(ERROR, TAG, "Gatt Client is already running!!"); ca_mutex_unlock(g_LEClientStateMutex); - return; + return CA_STATUS_FAILED; } CAResult_t result = CALEGattSetCallbacks(); @@ -415,7 +390,7 @@ void CAStartLEGattClientThread(void *data) OIC_LOG(ERROR, TAG, "CABleGattSetCallbacks Failed"); ca_mutex_unlock(g_LEClientStateMutex); CATerminateLEGattClient(); - return; + return CA_STATUS_FAILED; } g_isLEGattClientStarted = true; @@ -427,7 +402,7 @@ void CAStartLEGattClientThread(void *data) OIC_LOG(ERROR, TAG, "gBleServerThreadPool is NULL"); CATerminateGattClientMutexVariables(); ca_mutex_unlock(g_LEClientThreadPoolMutex); - return; + return CA_STATUS_FAILED; } result = ca_thread_pool_add_task(g_LEClientThreadPool, CAStartTimerThread, @@ -435,22 +410,14 @@ void CAStartLEGattClientThread(void *data) if (CA_STATUS_OK != result) { OIC_LOG(ERROR, TAG, "ca_thread_pool_add_task failed"); + CATerminateGattClientMutexVariables(); ca_mutex_unlock(g_LEClientThreadPoolMutex); - return; + return CA_STATUS_FAILED; } ca_mutex_unlock(g_LEClientThreadPoolMutex); - OIC_LOG(DEBUG, TAG, "Giving the control to threadPool"); - - GMainContext *thread_context = g_main_context_new(); - - g_eventLoop = g_main_loop_new(thread_context, FALSE); - - g_main_context_push_thread_default(thread_context); - - g_main_loop_run(g_eventLoop); - OIC_LOG(DEBUG, TAG, "OUT"); + return CA_STATUS_OK; } void CAStartTimerThread(void *data) @@ -1020,7 +987,7 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress) CAResult_t result = CAAddLEServerInfoToList(&g_LEServerList, serverInfo); if (CA_STATUS_OK != result) { - OIC_LOG(ERROR, TAG, "CAAddBLEClientInfoToList failed"); + OIC_LOG(ERROR, TAG, "CAAddLEServerInfoToList failed"); bt_gatt_client_destroy(clientHandle); CALEGattDisConnect(remoteAddress); return CA_STATUS_FAILED;