Peripheral
public class Peripheral: NSObject
An interface to the Bluetooth peripheral.
-
The UUID of the peripheral.
Declaration
Swift
public var uuid: PeripheralIdentifier
-
The name of the peripheral.
Declaration
Swift
public var name: String?
-
Requests the current RSSI value from the peripheral, and the value is returned via the
RSSIObserver
delegation.Declaration
Swift
public func readRSSI()
-
Register a RSSI observer that can receive the RSSI value when
readRSSI
is called.Declaration
Swift
public func register(observer: RSSIObserver)
-
Unregister a RSSI observer.
Declaration
Swift
public func unregister(observer: RSSIObserver)
-
Read from a specified characteristic.
Declaration
Swift
public func read<R: Receivable>(from characteristicIdentifier: CharacteristicIdentifier, completion: @escaping (ReadResult<R>) -> Void)
-
Write to a specified characteristic.
Declaration
Swift
public func write<S: Sendable>(to characteristicIdentifier: CharacteristicIdentifier, value: S, type: CBCharacteristicWriteType = .withResponse, completion: @escaping (WriteResult) -> Void)
-
Checks whether Bluejay is currently listening to the specified charactersitic.
Declaration
Swift
public func isListening(to characteristicIdentifier: CharacteristicIdentifier) -> Bool
-
Listen for notifications on a specified characterstic.
Declaration
Swift
public func listen<R: Receivable>(to characteristicIdentifier: CharacteristicIdentifier, completion: @escaping (ReadResult<R>) -> Void)
-
End listening on a specified characteristic.
Provides the ability to suppress the failure message to the listen callback. This is useful in the internal implimentation of some of the listening logic, since we want to be able to share the clear logic on a .done exit, but don’t need to send a failure in that case.
Note
Note Currently this can also cancel a regular in-progress read as well, but that behaviour may change down the road.Declaration
Swift
public func endListen(to characteristicIdentifier: CharacteristicIdentifier, error: Error? = nil, completion: ((WriteResult) -> Void)? = nil)
-
Restore a (believed to be) active listening session, so if we start up in response to a notification, we can receive it.
Declaration
Swift
public func restoreListen<R: Receivable>(to characteristicIdentifier: CharacteristicIdentifier, completion: @escaping (ReadResult<R>) -> Void)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?)