From 1ece44c4d3f041fb9d3d2271d3e1e42e538683f4 Mon Sep 17 00:00:00 2001 From: wootak Date: Tue, 23 Jun 2020 08:59:22 +0900 Subject: [PATCH] [Bluetooth][Non-ACR] Fix GattConnection event not occured issue (#1735) Signed-off-by: Wootak Jung --- .../Tizen.Network.Bluetooth/BluetoothGatt.cs | 20 +++++++++++++++++--- .../Tizen.Network.Bluetooth/BluetoothLeAdapter.cs | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs index 1385dd1..bb7bb75 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothGatt.cs @@ -261,11 +261,19 @@ namespace Tizen.Network.Bluetooth private static event EventHandler 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. + } } /// @@ -279,7 +287,13 @@ namespace Tizen.Network.Bluetooth /// 6 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; } diff --git a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs index c603bf8..6b7a28a 100644 --- a/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs +++ b/src/Tizen.Network.Bluetooth/Tizen.Network.Bluetooth/BluetoothLeAdapter.cs @@ -514,7 +514,7 @@ namespace Tizen.Network.Bluetooth { } else { - client = BluetoothGattClient.CreateClient(_remoteAddress); + client = BluetoothGattClient.CreateClient(_remoteAddress, true); } } else -- 2.7.4