Skip to content

Commit

Permalink
Merge pull request #102 from everlof/remove-peripheral-on-disconnect
Browse files Browse the repository at this point in the history
Remove peripheral after disconnect
  • Loading branch information
philips77 committed Feb 19, 2024
2 parents a9652af + 94af7a1 commit df76c6a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CoreBluetoothMock/CBMCentralManagerNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class CBMCentralManagerNative: CBMCentralManager {
manager.delegate?.centralManager(manager,
didDisconnectPeripheral: getPeripheral(peripheral),
error: error)
removePeripheral(peripheral)
}

#if !os(macOS)
Expand Down Expand Up @@ -121,6 +122,10 @@ public class CBMCentralManagerNative: CBMCentralManager {
manager.peripherals[peripheral.identifier] = p
return p
}

private func removePeripheral(_ peripheral: CBPeripheral) {
manager.peripherals[peripheral.identifier] = nil
}
}

private class CBMCentralManagerDelegateWrapperWithRestoration: CBMCentralManagerDelegateWrapper {
Expand Down

0 comments on commit df76c6a

Please sign in to comment.