RVS_BTDriver_WatchOS_Test_Harness_Main_InterfaceController

class RVS_BTDriver_WatchOS_Test_Harness_Main_InterfaceController : WKInterfaceController
extension RVS_BTDriver_WatchOS_Test_Harness_Main_InterfaceController: RVS_BTDriverDelegate

This is the interface controller for the main screen (the one that lists devices).

Constants

  • The string used to instantiate our table rows.

    Declaration

    Swift

    let rowIDString: String
  • The ID for our settings push. Used to reset the driver.

    Declaration

    Swift

    let settingsSegueID: String

Instance Properties

  • This is a simple semaphore, to re-enable scanning.

    Declaration

    Swift

    var wasScanning: Bool
  • This is a simple semaphore, to indicate that the settings screen was called.

    Declaration

    Swift

    var settingsCalled: Bool
  • This is our instance of the actual BLE driver.

    Declaration

    Swift

    var driverInstance: RVS_BTDriver!
  • These are the shared persistent prefs for the test harness app.

    Declaration

IBOutlet Properties

  • The group that contains the “No Bluetooth” image.

    Declaration

    Swift

    @IBOutlet
    weak var noBTDisplay: WKInterfaceGroup!
  • The table that displays the list of discovered devices.

    Declaration

    Swift

    @IBOutlet
    weak var deviceDisplayTable: WKInterfaceTable!
  • The switch that controls whether or not the app is scanning for devices.

    Declaration

    Swift

    @IBOutlet
    weak var scanningButton: WKInterfaceSwitch!
  • The “gear” settings button. Touching this, brings in the settings screen.

    Declaration

    Swift

    @IBOutlet
    weak var settingsButton: WKInterfaceButton!

IBAction Methods

  • Called when the “Scanning” switch is pressed.

    Declaration

    Swift

    @IBAction
    func scanningButtonHit(_ inValue: Bool)

    Parameters

    inValue

    The on/off value of the scanning switch.

Internal Methods

  • This establishes the driver instance, wiping out any old one.

    Declaration

    Swift

    func setUpDriver()
  • Make sure the correct items are shown or hidden.

    Declaration

    Swift

    func setUpUI()
  • This adds devices to the table for display.

    Declaration

    Swift

    func populateTable()
  • This is called by the details screen, to delete a device from the list.

    Upon return from this, it should be assumed that the device instance is now invalid.

    Declaration

    Swift

    func deleteDevice(_ inDeviceInstance: RVS_BTDriver_DeviceProtocol)

    Parameters

    inDeviceInstance

    The device (driver class) that will be deleted.

  • Displays the given message and title in an alert with an “OK” button.

    Declaration

    Swift

    func displayAlert(header inTitle: String, message inMessage: String)

    Parameters

    inTitle

    a string to be displayed as the title of the alert. It is localized by this method.

    message

    a string to be displayed as the message of the alert. It is localized by this method.

Overridden Base Class Methods

  • Called when the instance is being initialized for use.

    Declaration

    Swift

    override func awake(withContext inContext: Any?)

    Parameters

    inContext

    The context (We ignore, but pass it to the base class).

  • Called just before we are displayed.

    We use this to update the UI, and reset things, if we need to do so (after settings).

    Declaration

    Swift

    override func willActivate()
  • Table touch handler.

    Declaration

    Swift

    override func contextForSegue(withIdentifier inSegueIdentifier: String, in inTable: WKInterfaceTable, rowIndex inRowIndex: Int) -> Any?

    Parameters

    withIdentifier

    The segue ID for this (we ignore)

    in

    The table instance

    rowIndex

    The vertical position (0-based) of the row that was touched.

  • This is called when we are about to bring in another sheet.

    Declaration

    Swift

    override func contextForSegue(withIdentifier inSegueIdentifier: String) -> Any?

    Parameters

    withIdentifier

    The segue ID for this (we ignore)

Driver delegate Methods

  • Simple error reporting method.

    Declaration

    Swift

    func btDriver(_ inDriver: RVS_BTDriver, encounteredThisError inError: RVS_BTDriver.Errors)

    Parameters

    inDriver

    The RVS_BTDriver instance that encountered the error.

    encounteredThisError

    The error that was encountered.

  • Called when a new device is discovered while scanning.

    Declaration

    Swift

    func btDriver(_ inDriver: RVS_BTDriver, newDeviceAdded inDevice: RVS_BTDriver_DeviceProtocol)

    Parameters

    inDriver

    The RVS_BTDriver instance that is calling this.

    newDeviceAdded

    The new device instance.

  • Called to indicate that the driver’s status should be checked.

    It may be called frequently, and there may not be any changes. This is mereley a “make you aware of the POSSIBILITY of a change” call.

    This is optional, and is NOT guaranteed to be called in the main thread.

    Declaration

    Swift

    func btDriverStatusUpdate(_ inDriver: RVS_BTDriver)

    Parameters

    driver

    The RVS_BTDriver instance calling this.