waitForConnection

suspend fun waitForConnection(deviceId: String? = "", deviceName: String? = "")

This function waits for the watch to connect to the phone. When connected, it returns and emmits a ConnectionSetupComplete event, which can inform other parts of the app that the connection has taken place.

Parameters

deviceId

Optional parameter containing a the Bluetooth ID of a watch which was previously connected. Providing this parameter will speed up connection. Its value can be saved in local storage for future use, and can be obtained after connection by calling getDeviceId(). Here is an example:

private suspend fun waitForConnectionCached() {
var cachedDeviceAddress: String? =
LocalDataStorage.get("cached device", null, this@MainActivity)
api().waitForConnection(cachedDeviceAddress)
LocalDataStorage.put("cached device", api().getDeviceId(), this@MainActivity)
}