Protocols
The following protocols are available globally.
-
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, andconnected(to peripheral: Peripheral)
will also be called immediately if a device is already connected.Note
Note Available callbacks:
func bluetoothAvailable(_ available: Bool)
func connected(to peripheral: Peripheral)
See morefunc disconnected(from peripheral: Peripheral)
Declaration
Swift
public protocol ConnectionObserver : AnyObject
-
A protocol allowing a single delegate registered to Bluejay to have a final say at the end of a disconnection, as well as evaluate and control the auto-reconnect behaviour.
Attention
Be careful with how you organize app and Bluejay logic inside your connect, explicit disconnect, the disconnect handler callbacks. It may be easy to create redundant or conflicting code. As a rule of thumb, we recommend putting light weight and repeatable logic, such as UI updates, inside your connect and disconnect callbacks. And for more major operations such as restarting any Bluetooth tasks, use the disconnect handler.Declaration
Swift
public protocol DisconnectHandler : AnyObject
-
A class protocol allowing notification of a characteristic being listened on, and provides an opportunity to restore its listen callback during Bluetooth state restoration.
Bluetooth state restoration occurs when the background mode capability is turned on, and if the app is backgrounded or even terminated while a Bluetooth operation is still ongoing, iOS may keep the Bluetooth state alive, and attempt to restore it on resuming the app, so that the connection and operation between the app and the Bluetooth accessory is not interrupted and severed.
See moreDeclaration
Swift
public protocol ListenRestorer : AnyObject
-
A protocol allowing conforming objects to monitor the RSSI changes of a connected peripheral.
See moreDeclaration
Swift
public protocol RSSIObserver : AnyObject
-
Protocol to indicate that a type can be received from the Bluetooth connection.
See moreDeclaration
Swift
public protocol Receivable