RVS_BTDriver_Interface_BLE
internal class RVS_BTDriver_Interface_BLE : RVS_BTDriver_Base_Interface
extension RVS_BTDriver_Interface_BLE: CBCentralManagerDelegate
This is an interface for Bluetooth Low Energy (BLE), using CoreBluetooth.
-
This is a simple struct to transfer interface information between the interface and the vendor device implementation.
See moreDeclaration
Swift
internal struct DeviceInfoStruct
-
This is how we get the information for creating our device instance. The peripheral instance and the central manager instance are passed in.
Declaration
Swift
internal typealias DeviceInfo = DeviceInfoStruct
-
This is the signal strength range. Optimal is -50.
Declaration
Swift
private let _RSSI_range: Range<Int> -
Holds our SINGLETON
Declaration
Swift
internal static var internal_interface: RVS_BTDriver_InterfaceProtocol! -
This will create the SINGLETON, if it is not already created, or simply returns the one we have.
Declaration
Swift
internal static func makeInterface(queue inQueue: DispatchQueue!) -> RVS_BTDriver_InterfaceProtocol!Parameters
queueThe thread o use. Default is nil (main thread).
-
The manager instance associated with this interface. There is only one.
Declaration
Swift
internal var centralManager: CBCentralManager! -
Main initializer.
Declaration
Swift
internal init(queue inQueue: DispatchQueue! = nil)Parameters
queueThe thread to use. Default is nil (main thread).
-
Clean up after ourselves.
Declaration
Swift
deinit -
If true, then Bluetooth is available (powered on).
Declaration
Swift
internal override var isBTAvailable: Bool { get } -
Start or stop the scan for new peripherals.
Declaration
Swift
internal override var isScanning: Bool { get set } -
Read-only accessor for the interface.
Declaration
Swift
internal var interface: RVS_BTDriver_InterfaceProtocol! { get }Return Value
An instance of the interface for this type of device. Can be nil, if
makeInterface(:)has not yet been called.
-
Callback for when the central manager changes state.
Declaration
Swift
internal func centralManagerDidUpdateState(_ inCentral: CBCentralManager)Parameters
inCentralThe CoreBluetooth Central Manager instance calling this.
-
Callback for a connection failing.
Declaration
Swift
internal func centralManager(_ inCentral: CBCentralManager, didFailToConnect inPeripheral: CBPeripheral, error inError: Error?)Parameters
inCentralThe CoreBluetooth Central Manager instance calling this.
didFailToConnectThe peripheral object that failed to connect.
errorThe error that occurred during the failure. May be nil.
-
Callback for a device discovered during scanning.
Declaration
Swift
internal func centralManager(_ inCentral: CBCentralManager, didDiscover inPeripheral: CBPeripheral, advertisementData inAdvertisementData: [String : Any], rssi inRSSI: NSNumber)Parameters
inCentralThe CoreBluetooth Central Manager instance calling this.
didDiscoverThe peripheral object that was discovered.
advertidementDataA String-keyed Dictionary of advertisement data for the peripheral.
rssiThe signal strength of the Bluetooh signal, in dB.
-
Called when a peripheral connects.
Declaration
Swift
internal func centralManager(_ inCentral: CBCentralManager, didConnect inPeripheral: CBPeripheral)Parameters
inCentralThe manager instance.
didConnectThe peripheral that was successfully connected.
-
Callback for a disconnection.
Declaration
Swift
internal func centralManager(_ inCentral: CBCentralManager, didDisconnectPeripheral inPeripheral: CBPeripheral, error inError: Error?)Parameters
inCentralThe CoreBluetooth Central Manager instance calling this.
didDisconnectPeripheralThe peripheral object that was disconnected.
errorAny error that occurred during the disconnection. May be nil.
View on GitHub
RVS_BTDriver_Interface_BLE Class Reference