SwiftBluetooth icon indicating copy to clipboard operation
SwiftBluetooth copied to clipboard

Receive disconnect event

Open aviwad opened this issue 1 year ago • 3 comments

Hi! Great project. Would appreciate a method to receive a change in the disconnect event without having to use regular Core-Bluetooth's Delegate functionality. Thanks a lot 😄

aviwad avatar Oct 16 '24 00:10 aviwad

This is possible.

var switchDisconnectSubscription : AsyncSubscription<PeripheralEvent> = peripheral.eventSubscriptions.queue { event, done in
    guard case .didDisconnect(let error) = event else { return }

    print("did disconnect: \(String(describing: error))")
}

As far as I know, it's not directly documented, it's more of a feature of this repository that I had to dig for.

pinefin avatar Nov 04 '24 19:11 pinefin

Thank you very much <3

aviwad avatar Nov 11 '24 20:11 aviwad

Sorry, how did you get this to work? eventSubscription is marked internal. Did you fork the repo?

aviwad avatar Nov 11 '24 20:11 aviwad