ConnectionObserver

public protocol ConnectionObserver : AnyObject

A protocol allowing conforming objects registered to Bluejay to optionally respond to Bluetooth connection events.

Attention

Attention On initial subscription to Bluetooth events, bluetoothAvailable(_ available: Bool) will always be called immediately with whatever the current state is, and connected(to peripheral: PeripheralIdentifier) will also be called immediately if a device is already connected.

Note

Note Available callbacks:

  • func bluetoothAvailable(_ available: Bool)

  • func connected(to peripheral: PeripheralIdentifier)

  • func disconnected(from peripheral: PeripheralIdentifier)

    • bluetoothAvailable(_:) Default implementation

      Called whenever Bluetooth availability changes, as well as when an object first subscribes to become a ConnectionObserver.

      Default Implementation

      Declaration

      Swift

      func bluetoothAvailable(_ available: Bool)
    • connected(to:) Default implementation

      Called whenever a peripheral is connected, as well as when an object first subscribes to become a ConnectionObserver and the peripheral is already connected.

      Default Implementation

      Declaration

      Swift

      func connected(to peripheral: PeripheralIdentifier)
    • disconnected(from:) Default implementation

      Called whenever a peripheral is disconnected.

      Default Implementation

      Declaration

      Swift

      func disconnected(from peripheral: PeripheralIdentifier)