From b0fa88a6cccb231722810e8284e5c9d01e45bfcb Mon Sep 17 00:00:00 2001 From: "jean.bedard@exfo.com" Date: Tue, 30 Jan 2018 16:24:47 -0500 Subject: [PATCH] Fix issue #280 for iOS using Error.Code for peripheral disconnection --- Source/Plugin.BLE.iOS/Adapter.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Plugin.BLE.iOS/Adapter.cs b/Source/Plugin.BLE.iOS/Adapter.cs index edb0a6cf..4bd7b0ec 100644 --- a/Source/Plugin.BLE.iOS/Adapter.cs +++ b/Source/Plugin.BLE.iOS/Adapter.cs @@ -105,6 +105,12 @@ public Adapter(CBCentralManager centralManager) _deviceOperationRegistry.Remove(stringId); } + // check if it is a peripheral disconnection, which would be treated as normal + if(e.Error != null && e.Error.Code == 7 && e.Error.Domain == "CBErrorDomain") + { + isNormalDisconnect = true; + } + // remove from connected devices if (_deviceConnectionRegistry.TryGetValue(stringId, out foundDevice)) {