connect

abstract suspend fun connect(serial: String, privateKey: String): CmConnectResult

Attempts to establish a connection with a module using its serial number and a private key.

Calling discoverModules is not a prerequisite for connection.

If bluetooth connection is lost (out of range, bluetooth disabled, etc), will always attempt to reconnect, so no additional calls to connect are required.

If already connected to a module (same or different), first disconnects from the connected module and then starts a new connection.

Return

A CmConnectResult indicating the result of the connection attempt.

Parameters

serial

The serial number of the module to connect to. Can be obtained from discoverModules.

privateKey

The private key used for establishing a secure connection. Default key can be used defaultPrivateKey.

See also