DiscoveryData
public class DiscoveryData
This is a class, as opposed to a struct, because I want to make sure that it is referenced, and not copied.
-
This is a countdown timer, for use as a timeout trap during connection.
Declaration
Swift
private var _timer: Timer?
-
This holds the advertisement data that came with the discovery.
Declaration
Swift
public var advertisementData: AdvertisementData?
-
This is the signal strength, at the time of discovery, in dBm. This is also updated, as we receive RSSI change notifications.
Declaration
Swift
public var rssi: Int
-
This is the peripheral wrapper that is instantiated when the device is connected. It is nil, if the device is not connected. It is a strong reference.
Declaration
Swift
public var peripheralInstance: CGA_Bluetooth_Peripheral? { get set }
-
The Peripheral is capable of sending writes back (without response).
Declaration
Swift
public var canSendWriteWithoutResponse: Bool { get }
-
The assigned Peripheral Name
Declaration
Swift
public var name: String { get }
-
This is true, if the Peripheral advertisement data indicates the Peripheral can be connected.
Declaration
Swift
public var canConnect: Bool { get }
-
This is the “Local Name,” from the advertisement data.
Declaration
Swift
public var localName: String { get }
-
This is the local name, if available, or the Peripheral name, if the local name is not available.
Declaration
Swift
public var preferredName: String { get }
-
Returns the ID UUID as a String.
Declaration
Swift
public var identifier: String { get }
-
Returns true, if the peripheral is currently connected.
Declaration
Swift
public var isConnected: Bool { get }
-
Returns true, if the peripheral is currently disconnected (as opposed to connecting/disconnecting/connected).
Declaration
Swift
public var isDisconnected: Bool { get }
-
Returns true, if the peripheral is currently undergoing connection.
Declaration
Swift
public var isConnecting: Bool { get }
-
Returns true, if the peripheral is currently undergoing disconnection.
Declaration
Swift
public var isDisconnecting: Bool { get }
-
This asks the Central Manager to ignore this device.
Declaration
Swift
@discardableResult public func ignore() -> Bool
Return Value
True, if the ignore worked.
-
This asks the Central Manager to “unignore” this device.
Declaration
Swift
@discardableResult public func unignore() -> Bool
Return Value
True, if the unignore worked.
-
This asks the Central Manager to connect this device.
Declaration
Swift
@discardableResult public func connect() -> Bool
Return Value
True, if the attempt worked (not a guarantee of success, though).
-
This asks the Central Manager to disconnect this device.
Declaration
Swift
@discardableResult public func disconnect() -> Bool
Return Value
True, if the attempt worked (not a guarantee of success, though).
-
Cancels the timeout.
Declaration
Swift
public func clear()
-
The actual Peripheral instance. This is a strong reference. This will retain the allocation for the Peripheral, so it is a strong reference.
Declaration
Swift
internal var peripheral: Any
-
The Central manager that “owns” this discovered device. This is a weak reference.
Declaration
Swift
internal weak var central: RVS_BlueThoth?
-
The actual Peripheral instance, cast as CBPeripheral.
Declaration
Swift
internal var cbPeripheral: CBPeripheral? { get }
-
This is the callback for the timeout Timer firing. It is @objc, because it is a Timer callback.
Declaration
Swift
@objc internal func timeout(_ inTimer: Timer)
Parameters
inTimer
The timer instance that fired.
-
Basic Init
Declaration
Swift
internal init(central inCentralManager: RVS_BlueThoth, peripheral inPeripheral: CBPeripheral, advertisementData inAdvertisementData: [String : Any], rssi inRSSI: Int)
Parameters
central
The Central Manager instance that “owns” this instance.
peripheral
The CBPeripheral instance associated with this. This will be a strong reference, and will be the “anchor” for this instance.
advertisementData
The advertisement data of the discovered Peripheral.
rssi
The signal strength, in dBm.
-
Make sure that we don’t leave any open timers.
Declaration
Swift
deinit
-
Calling this starts the timeout clock.
Declaration
Swift
private func _startTimeout()
-
This stops the timeout clock, invalidates the timer, and clears the Timer instance.
Declaration
Swift
private func _cancelTimeout()