From 9b656e9852485373aeed26a06cfe8bf9ef98a804 Mon Sep 17 00:00:00 2001 From: lishuo Date: Wed, 20 Jul 2022 13:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=AC=AC=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E6=96=AD=E5=BC=80=E8=AE=BE=E5=A4=87=E5=A4=B1=E8=B4=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Devices/Ble/mobile/BleMobileInterface.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/Devices/Ble/mobile/BleMobileInterface.cs b/Assets/Scripts/Devices/Ble/mobile/BleMobileInterface.cs index de8782a9..d799b589 100644 --- a/Assets/Scripts/Devices/Ble/mobile/BleMobileInterface.cs +++ b/Assets/Scripts/Devices/Ble/mobile/BleMobileInterface.cs @@ -31,14 +31,13 @@ namespace Assets.Scripts.Ble private Action _discoveredCallback; private Dictionary> callbacks = new Dictionary>(); - private Dictionary diconnectedCallbacks = new Dictionary(); private Dictionary>>> servicesCallbacks = new Dictionary>>>(); //private Dictionary>>> characteristicsCallbacks = new Dictionary>>>(); private Dictionary> characteristicNotificationCallbacks = new Dictionary>(); private Dictionary characteristicReadCallbacks = new Dictionary(); private Dictionary characteristicsDiscoveredCallbacks = new Dictionary(); - private Dictionary disconnectedCallback = new Dictionary(); + private Dictionary disconnectedCallback = new Dictionary(); private CharacteristicReadCallback characteristicReadEvent; public event CharacteristicReadCallback CharacteristicReadEvent @@ -323,7 +322,7 @@ namespace Assets.Scripts.Ble this.callbacks.Remove(currentCallback.First().Key); } - var currentDisconnectCallback = this.disconnectedCallback.Where(c => c.Key.MatchAddress(address)); + var currentDisconnectCallback = this.disconnectedCallback.Where(c => c.Key == address); if (currentDisconnectCallback.Any()) { this.disconnectedCallback.Remove(currentDisconnectCallback.First().Key); @@ -352,7 +351,7 @@ namespace Assets.Scripts.Ble //设备断开连接 public void DisconnectPeripheral(BlePeripheralInfo peripheral, Action callback) { - diconnectedCallbacks.Add(peripheral.Address,callback); + disconnectedCallback.Add(peripheral.Address,callback); BluetoothLEHardwareInterface.DisconnectPeripheral(peripheral.Address, (address) => { Debug.Log("断开回调" + address); @@ -360,7 +359,7 @@ namespace Assets.Scripts.Ble PeripheralDisconnected(address, ble); peripheralDisconnectedEvent(this, ble, null, true); - var currentCallback = diconnectedCallbacks.Where(c => c.Key.Equals(address)).Select(c=>c.Value).FirstOrDefault(); + var currentCallback = disconnectedCallback.Where(c => c.Key.Equals(address)).Select(c=>c.Value).FirstOrDefault(); currentCallback?.Invoke(); }); }