manolofdez / AsyncBluetooth

A small library that adds concurrency to CoreBluetooth APIs.
MIT License
160 stars 30 forks source link

Notifications when a peripheral gets disconnected #3

Closed maurovm closed 2 years ago

maurovm commented 2 years ago

I have successfully paired and connected to a given peripheral. After the device has been streaming data for a while, the user disconnected (or turned off) the device. How can my app get notified of events like these?.

Presumably, we need to forward the

func centralManager(
        _ central: CBCentralManager,  
           didDisconnectPeripheral peripheral: CBPeripheral, 
           error: Error?
          )

method from the Central Manager's delegate to a new "app delegate" we need to implement?

manolofdez commented 2 years ago

Good point! The central manager needs to be able to communicate events that happen out of its control. We can use a Publisher to notify clients.