Skip to content

Commit

Permalink
Merge pull request dotnet-bluetooth-le#263 from d768/iOS_Bluetooth_tu…
Browse files Browse the repository at this point in the history
…rn_off_fix

Added IAdapter DeviceDisconnected invokation on bluetooth turn off (iOS only)
  • Loading branch information
xabre authored Dec 10, 2017
2 parents b309501 + f48c520 commit 3ae6610
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Plugin.BLE.iOS/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down

0 comments on commit 3ae6610

Please sign in to comment.