From f48c5200a71d2e443c7617bad90471386853269e Mon Sep 17 00:00:00 2001 From: Anton Sadovsky Date: Mon, 13 Nov 2017 12:18:36 +0700 Subject: [PATCH] Added IAdapter DeviceDisconnected invokation on bluetooth turn off (iOS only) --- Source/Plugin.BLE.iOS/Adapter.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Source/Plugin.BLE.iOS/Adapter.cs b/Source/Plugin.BLE.iOS/Adapter.cs index a7e896b1..edb0a6cf 100644 --- a/Source/Plugin.BLE.iOS/Adapter.cs +++ b/Source/Plugin.BLE.iOS/Adapter.cs @@ -49,6 +49,18 @@ public Adapter(CBCentralManager centralManager) { Trace.Message("UpdatedState: {0}", _centralManager.State); _stateChanged.Set(); + + //handle PoweredOff state + //notify subscribers about disconnection + if (_centralManager.State == CBCentralManagerState.PoweredOff) + { + foreach (var device in _deviceConnectionRegistry.Values.ToList()) + { + _deviceConnectionRegistry.Remove(device.Id.ToString()); + ((Device)device).ClearServices(); + HandleDisconnectedDevice(false, device); + } + } }; _centralManager.ConnectedPeripheral += (sender, e) =>