WearableDeviceSession
public protocol WearableDeviceSession
Represents a connection with a wearable device. A WearableDeviceSession
must be retained for as long as you are interested in the connection. Once a WearableDeviceSession
is deallocated, the connection is automatically closed and disposed.
In the event that a session has closed, you will be notified via the WearableDeviceSessionDelegate.session(_:didCloseWithError:)
delegate function. To re-establish communication with the remote device, you can do one of two things:
- You can call
WearableDeviceSession.open()
to open the connection again. Note that if the session was closed due to the remote device being powered down or moved out of range, it must be powered back on or moved back into range in order for this to succeed. - You can perform a device search (via
BoseWearable.startDeviceSearch(mode:completionHandler:)
orDeviceSearchTask
). Note that you must first release the closedWearableDeviceSession
by setting any retained references tonil
.
-
The pairing delegate gets notified when a device is required to be put into pairing mode in order to proceed with the connection. This is only required if you are implementing a custom connection UI.
Declaration
Swift
var pairingDelegate: WearableDeviceSessionPairingDelegate? { get set }
-
The delegate gets notified of connection-related events.
Declaration
Swift
var delegate: WearableDeviceSessionDelegate? { get set }
-
The wearable device. If there was an error opening the session, this will be
nil
.Declaration
Swift
var device: WearableDevice? { get }
-
The current state of this session.
Declaration
Swift
var state: WearableDeviceSessionState { get }
-
Opens the connection and establishes communications with the wearable device. Note that attempting to open a session that is not closed results in a fatal error.
Declaration
Swift
func open()
-
Closes the connection and terminates communications with the wearable device.
Declaration
Swift
func close()
-
The connection timeout interval.
Declaration
Swift
var connectTimeoutInterval: TimeInterval? { get }