CGA_PeripheralViewController

class CGA_PeripheralViewController : CGA_BaseViewController
extension CGA_PeripheralViewController: CGA_UpdatableScreenViewController
extension CGA_PeripheralViewController: UITableViewDataSource
extension CGA_PeripheralViewController: UITableViewDelegate

This controls the Peripheral Information View.

  • The reuse ID that we use for creating new table cells.

    Declaration

    Swift

    private static let _deviceRowReuseID: String
  • The ID of the segue that is executed to display Service details.

    Declaration

    Swift

    private static let _serviceDetailSegueID: String
  • This implements a “pull to refresh.”

    Declaration

    Swift

    private let _refreshControl: UIRefreshControl
  • This contains the device discovery data.

    Declaration

    Swift

    var deviceAdvInfo: RVS_BlueThoth.DiscoveryData!
  • This contains the device instance, once the connection is successful. It is a weak reference.

    Declaration

    Swift

    weak var deviceInstance: CGA_Bluetooth_Peripheral? { get }
  • This is the table that will list the discovered devices.

    Declaration

    Swift

    @IBOutlet
    weak var serviceTableView: UITableView!
  • This is the “Busy” animation that is displayed while the device connects.

    Declaration

    Swift

    @IBOutlet
    weak var busyAnimationActivityIndicatorView: UIActivityIndicatorView!
  • The label that displays the “CONNECTING…” message.

    Declaration

    Swift

    @IBOutlet
    weak var connectingLabel: UILabel!
  • The stack view that contains all the device information.

    Declaration

    Swift

    @IBOutlet
    weak var deviceInfoTextView: UITextView!
  • The label for the Services table.

    Declaration

    Swift

    @IBOutlet
    weak var servicesLabel: UILabel!

Private Methods

  • This sets up the accessibility and voiceover strings for the screen.

    Declaration

    Swift

    func setUpAccessibility()

Callback/Observer Methods

  • This is called by the table’s “pull to refresh” handler.

    When this is called, the Peripheral wipes out its Services, and starts over from scratch.

    Declaration

    Swift

    @objc
    func startOver(_: Any)

CGA_UpdatableScreenViewController Conformance

  • This simply makes sure that the UI matches the state of the device.

    Declaration

    Swift

    func updateUI()

Base Class Override Methods

  • Called after the view data has been loaded.

    Declaration

    Swift

    override func viewDidLoad()
  • Called just before the view is to disappear (slide out, usually, or get covered). We use this to make sure that any connection timeouts are canceled.

    Declaration

    Swift

    override func viewWillDisappear(_ inAnimated: Bool)

    Parameters

    inAnimated

    This is true, if the disappearance is to be animated.

  • Called just before the view is to appear.

    Declaration

    Swift

    override func viewWillAppear(_ inAnimated: Bool)

    Parameters

    inAnimated

    This is true, if the disappearance is to be animated.

  • This is called just before we bring in the Service screen.

    Declaration

    Swift

    override func prepare(for inSegue: UIStoryboardSegue, sender inSender: Any?)

    Parameters

    for

    The segue being executed.

    sender

    The data we want passed into the destination.

UITableViewDataSource Conformance

  • This returns the number of available rows, in the given section.

    Declaration

    Swift

    func tableView(_ inTableView: UITableView, numberOfRowsInSection inSection: Int) -> Int

    Parameters

    inTableView

    The table view that is asking for the row count.

    numberOfRowsInSection

    The 0-based section index being queried.

    Return Value

    The number of rows in the given section.

  • This returns a view, with the data for the given row and section.

    Declaration

    Swift

    func tableView(_ inTableView: UITableView, cellForRowAt inIndexPath: IndexPath) -> UITableViewCell

    Parameters

    inTableView

    The table view that is asking for the cell.

    cellForRowAt

    The index path (section, row) for the cell.

UITableViewDelegate Conformance

  • Called when a row is selected.

    Declaration

    Swift

    func tableView(_ inTableView: UITableView, didSelectRowAt inIndexPath: IndexPath)

    Parameters

    inTableView

    The table view that is asking for the cell.

    didSelectRowAt

    The index path (section, row) for the cell.