replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / util / src / camanager / bt_le_manager / tizen / caleconnectionmanager.c
@@ -43,35 +43,32 @@ void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
 {
     OIC_LOG(DEBUG, TAG, "CASetLENetworkMonitorCallbacks");
 
-    g_adapterStateCB = adapterStateCB;
-    CASetNetworkMonitorCallback(CAManagerAdapterMonitorHandler);
-
-    g_connStateCB = connStateCB;
-    CASetLEConnectionStateChangedCallback(CAManagerConnectionMonitorHandler);
 }
 
-void CAStartServerLEAdvertising()
+CAResult_t CAManagerLEStartAdvertising()
 {
-    OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+    OIC_LOG(DEBUG, TAG, "CAManagerLEStartAdvertising");
 
-    CAResult_t res = CALEStartAdvertise(CA_GATT_SERVICE_UUID);
+    CAResult_t res = CALEStartAdvertise();
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to start le advertising [%d]", res);
-        return;
+        return res;
     }
+    return res;
 }
 
-void CAStopServerLEAdvertising()
+CAResult_t CAManagerLEStopAdvertising()
 {
-    OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+    OIC_LOG(DEBUG, TAG, "CAManagerLEStopAdvertising");
 
     CAResult_t res = CALEStopAdvertise();
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to stop le advertising [%d]", res);
-        return;
+        return res;
     }
+    return res;
 }
 
 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
@@ -87,58 +84,28 @@ CAResult_t CAUnsetLEClientAutoConnectionDeviceInfo(const char * address)
     (void)address;
     return CA_NOT_SUPPORTED;
 }
-
-static void CAManagerAdapterMonitorHandler(const CAEndpoint_t *info, CANetworkStatus_t status)
+#if defined(__TIZEN__) && defined(LE_ADAPTER) && defined(BLE_CUSTOM_ADVERTISE)
+CAResult_t CAManagerLEServerSetAdvertisementData(const char *data, int length)
 {
-    if (CA_INTERFACE_DOWN == status)
-    {
-        if (info && g_adapterStateCB)
-        {
-            g_adapterStateCB(info->adapter, false);
-            OIC_LOG(DEBUG, TAG, "Pass the disabled adapter state to upper layer");
-        }
-    }
-    else if (CA_INTERFACE_UP == status)
+
+    CAResult_t res =  CAsetServerAdvertisementData(data, length);
+
+    if (CA_STATUS_OK != res)
     {
-        if (info && g_adapterStateCB)
-        {
-            g_adapterStateCB(info->adapter, true);
-            OIC_LOG(DEBUG, TAG, "Pass the enabled adapter state to upper layer");
-        }
+        OIC_LOG_V(ERROR, TAG, "Failed to stop le CAManagerLEServerSetAdvertisementData [%d]", res);
+        return;
     }
 }
 
-static void CAManagerConnectionMonitorHandler(CATransportAdapter_t adapter,
-                                              const char *remoteAddress, bool connected)
+CAResult_t CAManagerLEServerSetScanResponseData(const char *data, int length)
 {
-    (void)adapter;
 
-    if (!remoteAddress)
-    {
-        OIC_LOG(ERROR, TAG, "remoteAddress is NULL");
-        return;
-    }
+    CAResult_t res =  CAsetServerSanResponseData(data, length);
 
-    if (connected)
-    {
-        if (g_connStateCB)
-        {
-            g_connStateCB(CA_ADAPTER_GATT_BTLE, remoteAddress, true);
-            OIC_LOG(DEBUG, TAG, "Pass the connected device info to upper layer");
-
-            // stop le advertising
-            CAStopServerLEAdvertising();
-        }
-    }
-    else
+    if (CA_STATUS_OK != res)
     {
-        if (g_connStateCB)
-        {
-            g_connStateCB(CA_ADAPTER_GATT_BTLE, remoteAddress, false);
-            OIC_LOG(DEBUG, TAG, "Pass the disconnected device info to upper layer");
-
-            // start le advertising to receive new connection request.
-            CAStartServerLEAdvertising();
-        }
+        OIC_LOG_V(ERROR, TAG, "Failed to stop le CAsetServerSanResponseData [%d]", res);
+        return;
     }
 }
+#endif