Modified logic for LE scanning
[platform/upstream/iotivity.git] / resource / csdk / connectivity / src / bt_le_adapter / tizen / caleclient_vd.c
index 8bf7ebf..b6e1676 100644 (file)
@@ -426,7 +426,7 @@ static bool CALEIsHaveServiceImpl(bt_adapter_le_device_scan_result_info_s *scanI
             for(int i=0;i<man_data_len;i++){
                 pos += sprintf(compare_man_data+pos, "%.2x", man_data[i]);
             }
-            compare_man_data[man_data_len]='\0';
+            compare_man_data[(man_data_len*2)+1]='\0';
             if (man_id == samsung_code && 0 == strncasecmp(compare_man_data, service_uuid, CUSTOM_UUID_LEN))
             {
                 OIC_LOG_V(DEBUG, TAG, "Manufacture Data[%s] Found in %s",
@@ -1121,7 +1121,7 @@ CAResult_t CALEGattConnect(const char *remoteAddress)
     oc_mutex_lock(g_LEClientConnectMutex);
     CAResult_t result = CA_STATUS_OK;
 
-    int ret = bt_gatt_connect(remoteAddress, false);
+    int ret = bt_gatt_connect(remoteAddress, true);
     if (BT_ERROR_NONE != ret)
     {
         OIC_LOG_V(ERROR, TAG, "bt_gatt_connect Failed with ret value [%s] ",
@@ -1387,6 +1387,7 @@ CAResult_t CALEGattDiscoverServices(const char *remoteAddress)
 
 error_exit:
     bt_gatt_client_destroy(serverInfo->clientHandle);
+    serverInfo->clientHandle = NULL;
     oc_mutex_unlock(g_LEServerListMutex);
     CALEGattDisConnect(remoteAddress);
     return CA_STATUS_FAILED;
@@ -1448,7 +1449,10 @@ CAResult_t CAUpdateCharacteristicsToGattServer(const char *remoteAddress,
                 OIC_LOG(ERROR, TAG, "Could not add data to pending list");
                 return CA_STATUS_FAILED;
             }
+        }
 
+        if(serverInfo->status == LE_STATUS_UNICAST_PENDING)
+        {
             oc_mutex_lock(g_scanMutex);
             if (!g_isMulticastInProgress && !g_isUnicastScanInProgress)
             {