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 to establish a secure connection. It should be a case-insensitive hex string, up to 20 bytes (40 hex characters) long. If a custom key is not configured for the module, you may use the defaultPrivateKey.

See also