RVS_BTDriver_Device_BLE
class RVS_BTDriver_Device_BLE : RVS_BTDriver_Device
extension RVS_BTDriver_Device_BLE: RVS_BTDriver_State_Machine
extension RVS_BTDriver_Device_BLE: CBPeripheralDelegate
This is a specialized class for BLE devices (peripherals).
-
This holds the device info we were created with.
Declaration
Swift
private var _deviceInfoStruct: RVS_BTDriver_Interface_BLE.DeviceInfo!
-
The initial state (unititialized).
Declaration
Swift
private var _state: RVS_BTDriver_State_Machine_StateEnum
-
This is a property that is set to a command receive for a mock.
Declaration
Swift
var commandReceiveFunc: ((String) -> Void)!
-
The central manager that controls this peripheral.
Declaration
Swift
internal var centralManager: CBCentralManager! { get }
-
The peripheral instance associated with this device.
Declaration
Swift
internal var peripheral: CBPeripheral! { get }
-
Accessor for our device info structure. It will be nil, if none assigned yet.
Declaration
Swift
public var deviceInfoStruct: RVS_BTDriver_Interface_BLE.DeviceInfo! { get set }
-
The UUID comes directly from the peripheral.
Declaration
Swift
internal override var uuid: String! { get set }
-
A name for the device (may be the model name, may be something else).
Declaration
Swift
public override internal(set) var deviceName: String! { get set }
-
If the device has a Device Info Service with a model name, it is available here.
Declaration
Swift
public override internal(set) var modelName: String! { get set }
-
If the device has a Device Info Service with a manufacturer name, it is available here.
Declaration
Swift
public override internal(set) var manufacturerName: String! { get set }
-
If the device has a Device Info Service with a serial number, it is available here.
Declaration
Swift
public override internal(set) var serialNumber: String! { get set }
-
If the device has a Device Info Service with a hardware revision, it is available here.
Declaration
Swift
public override internal(set) var hardwareRevision: String! { get set }
-
If the device has a Device Info Service with a firmware revision, it is available here.
Declaration
Swift
public override internal(set) var firmwareRevision: String! { get set }
-
If the device has a Device Info Service with a software revision, it is available here.
Declaration
Swift
public override internal(set) var softwareRevision: String! { get set }
-
Connection indicator.
Declaration
Swift
internal override var isConnected: Bool { get set }
Return Value
true, if the peripheral is currently connected.
-
Connectable indicator.
Declaration
Swift
public override var canConnect: Bool { get set }
Return Value
true, if the peripheral is connectable.
-
Called to initiate a connection.
Declaration
Swift
internal override func connect()
-
Called to close a connection.
Declaration
Swift
internal override func disconnect()
-
This one does nothing. It should be overridden.
Declaration
Swift
public override func discoverServices()
-
Called if there was a connection, after initializing.
Declaration
Swift
internal func connectedPostInit()
-
Called if there was a disconnection, after initializing.
Declaration
Swift
internal func disconnectedPostInit()
-
This searches the device, and returns a service that “owns” the given characteristic.
Declaration
Swift
internal func serviceInstanceForCBCharacteristic(_ inCBCharacteristic: CBCharacteristic) -> RVS_BTDriver_Service_BLE!
Parameters
inCBCharacteristic
The CoreBluetooth Characteristic we are matching.
Return Value
The Service instance for the characteristic. Nil, if it can’t be matched.
-
This searches the device, and returns a service that has a certain UUID.
Declaration
Swift
internal func serviceInstanceForCBUUID(_ inUUIDString: String) -> RVS_BTDriver_Service_BLE!
Parameters
inUUIDString
A String, with the UUID we are searching for.
Return Value
The Service instance for the UUID. Nil, if it can’t be matched.
-
This searches the device, and returns a property that “owns” the given characteristic.
Declaration
Swift
internal func propertyInstanceForCBCharacteristic(_ inCBCharacteristic: CBCharacteristic) -> RVS_BTDriver_Property_BLE!
Parameters
inCBCharacteristic
The CoreBluetooth Characteristic we are matching.
Return Value
The Property instance for the characteristic. Nil, if it can’t be matched.
-
This searches the device, and returns a property that “owns” the given characteristic, identified by its UUID (as a String).
Declaration
Swift
internal func propertyInstanceForCBUUID(_ inUUIDString: String) -> RVS_BTDriver_Property_BLE!
Parameters
inUUIDString
The CoreBluetooth Characteristic UID (as a String) we are matching.
Return Value
The Property instance for the UID. Nil, if it can’t be matched.
-
This searches the device, and returns a property that “owns” the given characteristic, identified by its UUID (as a String).
This method will search only the main (final) list. It will not search the holding pen.
Declaration
Swift
internal func propertyInstanceForCBUUIDInMainList(_ inUUIDString: String) -> RVS_BTDriver_Property_BLE!
Parameters
inUUIDString
The CoreBluetooth Characteristic UID (as a String) we are matching.
Return Value
The Property instance for the UID. Nil, if it can’t be matched.
-
The current state of this instance.
Declaration
Swift
internal var state: RVS_BTDriver_State_Machine_StateEnum { get }
-
Start initialization.
Declaration
Swift
internal func startInit()
-
Called if there was a connection, before initializing.
Declaration
Swift
internal func connectedPreInit()
-
Called if there was a service discovery event, before initializing.
Declaration
Swift
internal func discoveryPreInit()
-
Abort initialization.
Declaration
Swift
internal func abortInit()
-
Called when we have discovered services for the peripheral.
See moreDeclaration
Swift
internal func peripheral(_ inPeripheral: CBPeripheral, didDiscoverServices inError: Error?)
Parameters
inPeripheral
The peripheral we have received notification on.
didDiscoverServices
Any errors that ocurred.
-
Called when the peripheral is ready.
Declaration
Swift
internal func peripheral(_ inPeripheral: CBPeripheral, didDiscoverCharacteristicsFor inService: CBService, error inError: Error?)
Parameters
inPeripheral
The peripheral for this device.
inService
The service with the characteristics that have been discovered.
error
Any error that may have occurred. It can be nil.
-
Called when the peripheral is ready.
Declaration
Swift
internal func peripheralIsReady(toSendWriteWithoutResponse inPeripheral: CBPeripheral)
Parameters
toSendWriteWithoutResponse
The peripheral that is ready.
-
Declaration
Swift
internal func peripheral(_ inPeripheral: CBPeripheral, didUpdateValueFor inCharacteristic: CBCharacteristic, error inError: Error?)
Parameters
inPeripheral
The peripheral for this device.
didUpdateValueFor
The characteristic that was updated.
error
Any error that may have occurred. It can be nil.
-
Declaration
Swift
internal func peripheralDidUpdateName(_ inPeripheral: CBPeripheral)
Parameters
inPeripheral
The peripheral for this device.