[Bluetooth][Non-ACR] Fix GattConnection event not occured issue (#1735)
authorwootak <wootak.jung@samsung.com>
Mon, 22 Jun 2020 23:59:22 +0000 (08:59 +0900)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2020 23:59:22 +0000 (08:59 +0900)
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs
src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs

index 1385dd1f97216f8e97e4470aacc61fa8f7387de2..bb7bb75f9033a7f8a22bab0ab671d61cc044917c 100644 (file)
@@ -261,11 +261,19 @@ namespace Tizen.Network.Bluetooth
         private static event EventHandler<GattConnectionStateChangedEventArgs> s_connectionStateChanged;
         private static Interop.Bluetooth.GattConnectionStateChangedCallBack s_connectionStateChangeCallback;
 
-        internal BluetoothGattClient(string remoteAddress)
+        internal BluetoothGattClient(string remoteAddress, bool fromLe)
         {
             _impl = new BluetoothGattClientImpl(remoteAddress);
             _remoteAddress = remoteAddress;
-            StaticConnectionStateChanged += OnConnectionStateChanged;
+            if (fromLe == false)
+            {
+                StaticConnectionStateChanged += OnConnectionStateChanged;
+            }
+            else
+            {
+                // fromLe will be removed after BluetoothLeDevice.GattConnect removed for backward compatibility.
+                // BluetoothLeDevice.GattConnectionStateChanged event will be occured in this case.
+            }
         }
 
         /// <summary>
@@ -279,7 +287,13 @@ namespace Tizen.Network.Bluetooth
         /// <since_tizen> 6 </since_tizen>
         public static BluetoothGattClient CreateClient(string remoteAddress)
         {
-            BluetoothGattClient client = new BluetoothGattClient(remoteAddress);
+            BluetoothGattClient client = new BluetoothGattClient(remoteAddress, false);
+            return client.Isvalid() ? client : null;
+        }
+
+        internal static BluetoothGattClient CreateClient(string remoteAddress, bool fromLe)
+        {
+            BluetoothGattClient client = new BluetoothGattClient(remoteAddress, fromLe);
             return client.Isvalid() ? client : null;
         }
 
index c603bf898d546658c3b3cb824fb78656f193d4cc..6b7a28a06e5ea1151614b2475cc3db4d941f8ce9 100644 (file)
@@ -514,7 +514,7 @@ namespace Tizen.Network.Bluetooth {
                 }
                 else
                 {
-                    client = BluetoothGattClient.CreateClient(_remoteAddress);
+                    client = BluetoothGattClient.CreateClient(_remoteAddress, true);
                 }
             }
             else