Fix to notify connected state to Tizen LE client from network monitor
authorvimala.v <vimala.v@samsung.com>
Thu, 3 Mar 2016 08:32:29 +0000 (14:02 +0530)
committerJon A. Cruz <jon@joncruz.org>
Mon, 7 Mar 2016 02:54:31 +0000 (02:54 +0000)
Change-Id: I6d0c0cbf1c6c48f07c39b1d01c48ac0f29396eaa
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5339
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/connectivity/src/bt_le_adapter/tizen/calenwmonitor.c

index 18cd152b1514d24f673041172a3a5fd4535c3299..ed03e0282d5a3b40ceefa9ca28b2a9f532ea86cb 100644 (file)
@@ -342,22 +342,21 @@ void CALEAdapterStateChangedCb(int result, bt_adapter_state_e adapter_state,
 void CALENWConnectionStateChangedCb(int result, bool connected,
                                     const char *remoteAddress, void *userData)
 {
-    OIC_LOG(DEBUG, TAG, "IN ");
+    OIC_LOG(DEBUG, TAG, "IN");
 
     VERIFY_NON_NULL_VOID(remoteAddress, TAG, "remote address is NULL");
 
-    if (!connected)
+    ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
+    const char *addr = OICStrdup(remoteAddress);
+    if (NULL == addr)
     {
-        OIC_LOG_V(DEBUG, TAG, "disconnected [%s] ", remoteAddress);
-        ca_mutex_lock(g_bleConnectionStateChangedCbMutex);
-        const char *addr = OICStrdup(remoteAddress);
-        g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, addr, connected);
+        OIC_LOG(ERROR, TAG, "addr is NULL");
         ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
+        return;
     }
-    else
-    {
-        OIC_LOG_V(DEBUG, TAG, "connected [%s] ", remoteAddress);
-    }
+    g_bleConnectionStateChangedCallback(CA_ADAPTER_GATT_BTLE, addr, connected);
+    OICFree(addr);
+    ca_mutex_unlock(g_bleConnectionStateChangedCbMutex);
 
     OIC_LOG(DEBUG, TAG, "OUT");
 }