Merge "Merge branch 'master' into notification-service" into notification-service
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / cautilinterface.c
index 35c21b7..6a848ff 100644 (file)
 
 #define TAG "OIC_CA_COMMON_UTILS"
 
-static CAAdapterStateChangedCB g_adapterStateCB = NULL;
-static CAConnectionStateChangedCB g_connStateCB = NULL;
-
-static void CAManagerAdapterMonitorHandler(CATransportAdapter_t adapter,
-                                           CANetworkStatus_t status)
-{
-    if (CA_INTERFACE_DOWN == status)
-    {
-        if (g_adapterStateCB)
-        {
-            g_adapterStateCB(adapter, false);
-            OIC_LOG(DEBUG, TAG, "Pass the disabled adapter state to upper layer");
-        }
-    }
-    else if (CA_INTERFACE_UP == status)
-    {
-        if (g_adapterStateCB)
-        {
-            g_adapterStateCB(adapter, true);
-            OIC_LOG(DEBUG, TAG, "Pass the enabled adapter state to upper layer");
-        }
-    }
-}
-
-static void CAManagerConnectionMonitorHandler(const CAEndpoint_t *info, bool isConnected)
-{
-    if (!info || !info->addr)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is NULL");
-        return;
-    }
-
-    if (isConnected)
-    {
-        if (g_connStateCB)
-        {
-            g_connStateCB(info->adapter, info->addr, isConnected);
-            OIC_LOG(DEBUG, TAG, "Pass the connected device info to upper layer");
-        }
-    }
-    else
-    {
-        if (g_connStateCB)
-        {
-            g_connStateCB(info->adapter, info->addr, isConnected);
-            OIC_LOG(DEBUG, TAG, "Pass the disconnected device info to upper layer");
-        }
-    }
-}
-
 CAResult_t CARegisterNetworkMonitorHandler(CAAdapterStateChangedCB adapterStateCB,
                                            CAConnectionStateChangedCB connStateCB)
 {
     OIC_LOG(DEBUG, TAG, "CARegisterNetworkMonitorHandler");
 
-    g_adapterStateCB = adapterStateCB;
-    g_connStateCB = connStateCB;
-
-    CASetNetworkMonitorCallbacks(CAManagerAdapterMonitorHandler,
-                                 CAManagerConnectionMonitorHandler);
+    CASetNetworkMonitorCallbacks(adapterStateCB, connStateCB);
     return CA_STATUS_OK;
 }
 
@@ -239,6 +185,12 @@ CAResult_t CAUtilClientInitialize(JNIEnv *env, JavaVM *jvm, jobject context)
         res = CA_STATUS_FAILED;
     }
 #endif
+
+#if !defined(LE_ADAPTER) && !defined(EDR_ADAPTER)
+    (void)env;
+    (void)jvm;
+    (void)context;
+#endif
     return res;
 }
 
@@ -301,4 +253,18 @@ void CAUtilSetFoundDeviceListener(jobject listener)
     (void)listener;
 #endif
 }
+
+CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount)
+{
+    OIC_LOG(DEBUG, TAG, "CAUtilSetLEScanInterval");
+#ifdef LE_ADAPTER
+    CAManagerLESetScanInterval(intervalTime, workingCount);
+    return CA_STATUS_OK;
+#else
+    (void)intervalTime;
+    (void)workingCount;
+    OIC_LOG(DEBUG, TAG, "it is not supported");
+    return CA_NOT_SUPPORTED;
+#endif
+}
 #endif