CGA_InitialViewController
class CGA_InitialViewController : CGA_BaseViewController
extension CGA_InitialViewController: CGA_UpdatableScreenViewController
extension CGA_InitialViewController: UITableViewDataSource
extension CGA_InitialViewController: UITableViewDelegate
extension CGA_InitialViewController: CGA_BlueThoth_Delegate
-
Used to generate table rows.
Declaration
Swift
static let discoveryTableCellReuseID: String
-
The segue ID of the “Show Discovery Details” screen.
Declaration
Swift
static let showDetailsSegueID: String
-
The segue ID of the “Show Settings” screen.
Declaration
Swift
static let showSettingsSegueID: String
-
This is a simple accessor for the app Central Manager Instance.
Declaration
Swift
var centralManager: RVS_BlueThoth! { get }
-
Returns the pushed device details screen. Nil, if none.
Declaration
Swift
private var _currentDeviceScreen: CGA_UpdatableScreenViewController! { get }
-
The image that is displayed if bluetooth is not available.
Declaration
Swift
@IBOutlet weak var noBTImage: UIImageView!
-
This segmented control manages the scanning state of the app.
Declaration
Swift
@IBOutlet weak var scanningSegmentedControl: UISegmentedControl!
-
This table lists all discovered devices.
Declaration
Swift
@IBOutlet weak var discoveryTableView: UITableView!
-
Returns true, if the Central Manager is currently scanning.
Declaration
Swift
var isScanning: Bool { get }
-
Used as a semaphore (yuck) to indicate that the Central was (or was not) scanning before the view disappeared. It is also used for editing the table, to prevent it from aborting deletes.
Declaration
Swift
var wasScanning: Bool
-
Make sure that the Navigation Controller is at tits baseline.
Declaration
Swift
private func _resetToRoot()
-
Starts scanning for Peripherals. If already scanning, nothing happens.
Declaration
Swift
private func _startScanning()
-
Makes sure that we have all devices disconnected.
Declaration
Swift
private func _clearAllConnections()
-
Stops scanning for Peripherals. If already stopped, nothing happens.
Declaration
Swift
private func _stopScanning()
-
This sets up the accessibility and voiceover strings for the screen.
Declaration
Swift
func setUpAccessibility()
-
Called when the scanning control changes.
Declaration
Swift
@IBAction func scanningControlChanged(_ inSegmentedControl: UISegmentedControl)
Parameters
inSegmentedControl
The control that changed.
-
Called after the view data has been loaded.
Declaration
Swift
override func viewDidLoad()
-
Called just before the view appears. We use this to hide the navBar.
Declaration
Swift
override func viewWillAppear(_ inAnimated: Bool)
Parameters
inAnimated
True, if the appearance is animated (we ignore this).
-
Called just before the view disappears.
Declaration
Swift
override func viewWillDisappear(_ inAnimated: Bool)
Parameters
inAnimated
True, if the appearance is animated (we ignore this).
-
Called just before the discovery details screen is pushed.
Declaration
Swift
override func prepare(for inSegue: UIStoryboardSegue, sender inSender: Any?)
Parameters
for
The segue that is being executed.
sender
The discovery information.
-
This simply makes sure that the table is displayed if BT is available, or the “No BT” image is shown, if it is not.
Declaration
Swift
func updateUI()
-
Called to provide the data to display in the indicated table cell.
Declaration
Swift
func tableView(_ inTableView: UITableView, cellForRowAt inIndexPath: IndexPath) -> UITableViewCell
Parameters
inTableView
The Table View that is asking for this View.
cellForRowAt
The IndexPath of the cell.
Return Value
A new view, set up for the indicated cell.
-
Declaration
Swift
func tableView(_: UITableView, numberOfRowsInSection: Int) -> Int
Return Value
The number of rows in the table.
-
Called when a row is selected.
Declaration
Swift
func tableView(_: UITableView, didSelectRowAt inIndexPath: IndexPath)
Parameters
didSelectRowAt
The IndexPath of the selected row.
-
Called to report an error.
Declaration
Swift
func handleError(_ inError: CGA_Errors, from inCentralManager: RVS_BlueThoth)
Parameters
inError
The error being reported.
from
The manager wrapper view that is calling this.
-
Called to tell the instance that the state of the Central manager just became “powered on.”
Declaration
Swift
func centralManagerPoweredOn(_ inCentralManager: RVS_BlueThoth)
Parameters
inCentralManager
The central manager that is calling this.
-
Called to tell this controller to recalculate its table.
Declaration
Swift
func updateFrom(_ inCentralManager: RVS_BlueThoth)
Parameters
inCentralManager
The manager wrapper view that is calling this.
-
Called to tell the instance that a Peripheral device has been connected.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, didConnectThisDevice inDevice: CGA_Bluetooth_Peripheral)
Parameters
inCentralManager
The central manager that is calling this.
didConnectThisDevice
The device instance that was connected.
-
Called to tell the instance that a peripheral device is about to be disconnected. We use this to reset the view stack to the initial (Peripheral List) screen.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, willDisconnectThisDevice inDevice: CGA_Bluetooth_Peripheral)
Parameters
inCentralManager
The central manager that is calling this.
willDisconnectThisDevice
The device instance that will be removed after this call.
-
This is called to tell the instance that a Peripheral device has had some change.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, deviceInfoChanged inDevice: CGA_Bluetooth_Peripheral)
Parameters
inCentralManager
The central manager that is calling this.
deviceInfoChanged
The device instance that was connected.
-
Called to tell the instance that a Service changed.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, changedService inService: CGA_Bluetooth_Service)
Parameters
inCentralManager
The central manager that is calling this.
device
The device instance that contained the changed Service.
changedService
The Service instance that contained the changed Characteristic.
-
Called to tell the instance that a Characteristic changed its notification state.
Declaration
Swift
func centralManager(_ inCentral: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, changedCharacteristicNotificationState inCharacteristic: CGA_Bluetooth_Characteristic)
Parameters
inCentralManager
The central manager that is calling this.
device
The device instance that contained the changed Service.
service
The Service instance that contained the changed Characteristic.
changedCharacteristicNotificationState
The Characteristic that was changed.
-
Called to tell the instance that a Characteristic changed its value.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, changedCharacteristic inCharacteristic: CGA_Bluetooth_Characteristic)
Parameters
inCentralManager
The central manager that is calling this.
device
The device instance that contained the changed Service.
service
The Service instance that contained the changed Characteristic.
changedCharacteristic
The Characteristic that was changed.
-
Called to tell the instance that a Descriptor changed.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, device inDevice: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, characteristic inCharacteristic: CGA_Bluetooth_Characteristic, changedDescriptor inDescriptor: CGA_Bluetooth_Descriptor)
Parameters
inCentralManager
The central manager that is calling this.
device
The device instance that contained the changed Service.
service
The Service instance that contained the changed Characteristic.
characteristic
The Characteristic that contains the Descriptor that was changed.
changedDescriptor
The Descriptor that was changed.
-
This is called to tell the instance that a Characteristic write with response received its response.
Declaration
Swift
func centralManager(_ inCentralManager: RVS_BlueThoth, device inPeripheral: CGA_Bluetooth_Peripheral, service inService: CGA_Bluetooth_Service, characteristicWriteComplete inCharacteristic: CGA_Bluetooth_Characteristic)
Parameters
inCentralManager
The central manager that is calling this.
device
The device instance that contained the changed Service.
service
The Service instance that contained the changed Characteristic.
characteristicWriteComplete
The Characteristic that had its write completed.