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.

Internal Structs

  • This is a simple struct to transfer interface information between the interface and the vendor device implementation.

    See more

    Declaration

    Swift

    internal struct DeviceInfoStruct

Internal Types

  • 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

Internal Instance Constants

  • 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

    queue

    The 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

    queue

    The 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.

RVS_BTDriver_Base_Interface_BLE

  • Callback for when the central manager changes state.

    Declaration

    Swift

    internal func centralManagerDidUpdateState(_ inCentral: CBCentralManager)

    Parameters

    inCentral

    The 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

    inCentral

    The CoreBluetooth Central Manager instance calling this.

    didFailToConnect

    The peripheral object that failed to connect.

    error

    The 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

    inCentral

    The CoreBluetooth Central Manager instance calling this.

    didDiscover

    The peripheral object that was discovered.

    advertidementData

    A String-keyed Dictionary of advertisement data for the peripheral.

    rssi

    The signal strength of the Bluetooh signal, in dB.

  • Called when a peripheral connects.

    Declaration

    Swift

    internal func centralManager(_ inCentral: CBCentralManager, didConnect inPeripheral: CBPeripheral)

    Parameters

    inCentral

    The manager instance.

    didConnect

    The peripheral that was successfully connected.

  • Callback for a disconnection.

    Declaration

    Swift

    internal func centralManager(_ inCentral: CBCentralManager, didDisconnectPeripheral inPeripheral: CBPeripheral, error inError: Error?)

    Parameters

    inCentral

    The CoreBluetooth Central Manager instance calling this.

    didDisconnectPeripheral

    The peripheral object that was disconnected.

    error

    Any error that occurred during the disconnection. May be nil.