From: samanway Date: Wed, 20 Nov 2019 13:58:26 +0000 (+0530) Subject: Avoiding code duplications in tizen BLE VD client files. X-Git-Tag: submit/tizen/20191128.075235~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=49515e2825ea7997159ab81308ff3dae771d72b6;p=platform%2Fupstream%2Fiotivity.git Avoiding code duplications in tizen BLE VD client files. - Caleclient.c and Caleclient_vd.c two files had duplicate code - Hence merged them into a single one - Additionally, Sconscript is modified to enable build flag for VD https://github.sec.samsung.net/RS7-IOTIVITY/IoTivity/commit/0622badee7ed2f6d424ac69d6796d443f8949953 (cherry-picked from 0622badee7ed2f6d424ac69d6796d443f8949953) Change-Id: I24720556a7dce71a0a410da1ab7daf93fb55278e Signed-off-by: DoHyun Pyun --- diff --git a/resource/csdk/connectivity/src/bt_le_adapter/tizen/SConscript b/resource/csdk/connectivity/src/bt_le_adapter/tizen/SConscript index 2166547ae..7560a783b 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/tizen/SConscript +++ b/resource/csdk/connectivity/src/bt_le_adapter/tizen/SConscript @@ -38,7 +38,8 @@ if 'MCD' in division: 'caleutil.c', 'calenwmonitor.c'] elif 'VD' in division: - src_files = [ 'caleclient_vd.c', + env.AppendUnique(CPPDEFINES = ['TIZEN_VD']) + src_files = [ 'caleclient.c', 'caleserver_vd.c', 'caleutil.c', 'calenwmonitor_vd.c'] 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 fb5a92073..561e2bf62 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/tizen/caleclient.c @@ -58,6 +58,7 @@ 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 */ @@ -67,6 +68,7 @@ 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 @@ -288,8 +290,10 @@ 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 @@ -336,6 +340,11 @@ 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); @@ -349,6 +358,7 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress) oc_mutex_unlock(g_isDisconnectedMutex); } retry_flag = 0; +#endif } else { @@ -363,7 +373,7 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress) if (CA_STATUS_OK != CAGetLEServerInfo(g_LEServerList, remoteAddress, &serverInfo)) { oc_mutex_unlock(g_LEServerListMutex); - OIC_LOG_V(ERROR, TAG, "Could not get server info!"); + OIC_LOG_V(ERROR, TAG, "Could not get server info for [%s]", remoteAddress); return; } @@ -384,6 +394,7 @@ void CALEGattConnectionStateChanged(bool connected, const char *remoteAddress) OIC_LOG(ERROR, TAG, "addr is NULL"); return; } + CAResult_t ret = ca_thread_pool_add_task(g_LEClientThreadPool, CADiscoverLEServicesThread, addr, NULL); oc_mutex_unlock(g_LEClientThreadPoolMutex); @@ -431,13 +442,19 @@ static bool CALEIsHaveServiceImpl(bt_adapter_le_device_scan_result_info_s *scanI if (result == BT_ERROR_NONE && NULL != man_data) { - char *compare_man_data = OICMalloc((man_data_len*2)+1); int pos =0; + char *compare_man_data = OICCalloc(1, (man_data_len*2)+1); + if (!compare_man_data) + { + OIC_LOG(ERROR, TAG, "Memory allocation failed for compare_man_data"); + OICFree(man_data); + return false; + } + for(int i=0;iremoteAddress = addr; serverInfo->status = LE_STATUS_UNICAST_PENDING;