Classes
The following classes are available globally.
-
Top-level interface to the BoseWearable library. Note that you must call
See moreBoseWearable.configure(_:)
before using theBoseWearableLib.shared
singleton instance. Failing to do so results in a fatal error.Declaration
Swift
public class BoseWearableLib
-
Encapsulates the device search and connection functionality. It requires a
See moreConnectUI
implementation that gets called to show and update the user interface throughout the search, connect, and secure pairing process.Declaration
Swift
public class ConnectionTask<ConnectUIImpl> : AnyConnectionTask where ConnectUIImpl : ConnectUI
-
The
See moreDeviceSearchTask
class encapsulates the device search functionality. It requires aDeviceSearchUserInterface
object that gets called to show and update the device picker which allows users to select a discovered device. TheDeviceSearchUserInterface
calls back into theDeviceSearchTask
via theDeviceSearchUserInterfaceDelegate
protocol.Declaration
Swift
@available(*, deprecated, message: "DeviceSearchTask has been replaced by ConnectionTask.") public class DeviceSearchTask
-
A
SensorDispatch
object is used to receive sensor readings. ASensorDispatch
object listens for the underlyingWearableDeviceEvent
notifications indicating that sensor data has been received. It then unpacks the individual values from the data and dispatches each to its appropriate callback block and to its handler (aSensorDispatchHandler
object).An app can have arbitrarily many
SensorDispatch
objects. This allows multiple handlers inside an app all to listen to the same sensor. EachSensorDispatch
automatically registers and deregisters for the appropriateWearableDeviceEvent
notifications.A
SensorDispatch
object is created with an associatedOperationQueue
. Specifying the.main
queue is suitable for when the app’s user interface should be updated in response to the event. Otherwise, a backgroundOperationQueue
can be provided.When a
WearableDeviceEvent.didReceiveSensorData(SensorData)
notification is received, theSensorDispatch
object does the following on theOperationQueue
provided to theSensorDispatch
initializer:- Dispatches the
SensorData
object tosensorDataCallback
and toSensorDispatchHandler.receivedSensorData(_:)
. - Each of the values in the
SensorData
object is dispatched to the appropriate handler:- Accelerometer values are dispatched to
accelerometerCallback
and toSensorDispatchHandler.receivedAccelerometer(vector:accuracy:timestamp:)
- Gyroscope values are dispatched to
gyroscopeCallback
and toSensorDispatchHandler.receivedGyroscope(vector:accuracy:timestamp:)
- Rotation values are dispatched to
rotationCallback
and toSensorDispatchHandler.receivedRotation(quaternion:accuracy:timestamp:)
. - Game rotation values are dispatched to
gameRotationCallback
and toSensorDispatchHandler.receivedGameRotation(quaternion:timestamp:)
. - Orientation values are dispatched to
orientationCallback
and toSensorDispatchHandler.receivedOrientation(vector:accuracy:timestamp:)
- Magnetometer values are dispatched to
magnetometerCallback
and toSensorDispatchHandler.receivedMagnetometer(vector:accuracy:timestamp:)
- Uncalibrated magnetometer values are dispatched to
uncalibratedMagnetometerCallback
and toSensorDispatchHandler.receivedUncalibratedMagnetometer(vector:bias:timestamp:)
- Accelerometer values are dispatched to
Callbacks are only invoked if they are non-nil. Thus you need only provide callback blocks for sensors you are interested in. Similarly, the
See moreSensorDispatchHandler
protocol provides default implementation of all of its handler functions. Thus you need only provide implementations for sensors you are interested in. ASensorDispatchHandler
and callback blocks can co-exist. Each callback is invoked before the correspondingSensorDispatchHandler
function.Declaration
Swift
public class SensorDispatch
- Dispatches the
-
An opaque token used to add and remove listeners backed by
NotificationCenter
. AListenerToken
object retains the token returned byNotificationCenter.addObserver(for:object:queue:)
as well as theNotificationCenter
. When the object is deallocated, we automatically remove the observer from the retainedNotificationCenter
using the retained token.Declaration
Swift
public class ListenerToken