Connection

sealed interface Connection

Manages connections with Efento devices. The Connection interface allows you to establish and handle connections to Efento devices. Multiple instances of Connection can be used to connect to several devices simultaneously. However, it's important to note that only one Connection can be active per device at any given time.

Threading & serialization

Methods are main-safe. Methods on a single instance — connect, disconnect, and commands — are not safe to call concurrently; serialize per instance.

Operations suspend until the platform replies or the connection drops. Bound with withTimeout(...) { ... } in the caller if a deadline is needed. See pl.efento.mobile.bluetooth.EfentoBluetooth for the full contract.

Inheritors

Properties

Link copied to clipboard
abstract val isConnected: Boolean

Checks if the connection is initialized and established. Returns true if the connection is active, false otherwise.

Functions

Link copied to clipboard
abstract suspend fun connect()

Establishes and initializes a new connection. Safe to call when already connected — returns immediately without reconnecting.

Link copied to clipboard
abstract suspend fun disconnect()

Terminates the existing connection. Safe to call when already disconnected — returns immediately without throwing.