Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Flow emitting every raw BLE characteristic notification received from the connected device as a defensive snapshot of the original byte array. This is an RX-only view of trafficFlow, sharing its payloads and bounded buffer. Treat bytes as read-only. Notification chunks are not necessarily complete protocol frames. The public type is now Flow rather than SharedFlow; ordinary collect usage is unchanged.

Link copied to clipboard

No replay; bounded, best-effort notifications, including repeated authentication status.

Link copied to clipboard

Null without a selected security-capable protocol; state survives collector changes.

Link copied to clipboard
val trafficFlow: SharedFlow<TrafficEvent>

RX notifications and TX writes accepted by Android, captured before decoding / ack waiting. No replay or history is retained without collectors. Subscribe before connecting to capture initialization. The shared buffer is bounded and drops oldest events for slow collectors; sequence gaps reveal missed events. Capture never suspends for collectors or performs I/O. Consumers must treat event bytes as read-only and perform storage on a background context.

Functions

Link copied to clipboard
@RequiresPermission(allOf = ["android.permission.BLUETOOTH_CONNECT", "android.permission.BLUETOOTH_SCAN"])
fun cleanup()
Link copied to clipboard
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun connect(device: EUCDevice)

Connect to a specific device

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun connectExternalDevice(device: BluetoothDevice, advertisedName: String?, rssi: Int)
Link copied to clipboard
fun createCommand(commandType: CommandType, value: Any = Unit): ByteArray
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun disconnect()

Disconnect from current device

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun forceProtocol(protocol: EUCProtocol): Boolean
Link copied to clipboard

Returns the latest BMS snapshot decoded by the active protocol, or null when the connected wheel does not expose BMS data.

Link copied to clipboard

Send a command to the connected device

Link copied to clipboard

Get currently connected device

Link copied to clipboard

Get current connection state

Link copied to clipboard

Latest diagnostic-log download snapshot from the active protocol (InMotion P6/V9).

Link copied to clipboard

Returns all registered protocols so the caller can inspect and choose one if needed.

Link copied to clipboard

Initialize the BLE Manager

Link copied to clipboard

Check if Bluetooth is enabled

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
open override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic)
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
@RequiresApi(value = 33)
open override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, value: ByteArray)
Link copied to clipboard
open fun onCharacteristicRead(gatt: BluetoothGatt?, characteristic: BluetoothGattCharacteristic?, status: Int)
open fun onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, value: ByteArray, status: Int)
Link copied to clipboard
open override fun onCharacteristicWrite(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int)
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
open override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int)
Link copied to clipboard
open fun onDescriptorRead(gatt: BluetoothGatt?, descriptor: BluetoothGattDescriptor?, status: Int)
open fun onDescriptorRead(gatt: BluetoothGatt, descriptor: BluetoothGattDescriptor, status: Int, value: ByteArray)
Link copied to clipboard
open fun onDescriptorWrite(gatt: BluetoothGatt?, descriptor: BluetoothGattDescriptor?, status: Int)
Link copied to clipboard
open override fun onMtuChanged(gatt: BluetoothGatt, mtu: Int, status: Int)
Link copied to clipboard
open fun onPhyRead(gatt: BluetoothGatt?, txPhy: Int, rxPhy: Int, status: Int)
Link copied to clipboard
open fun onPhyUpdate(gatt: BluetoothGatt?, txPhy: Int, rxPhy: Int, status: Int)
Link copied to clipboard
open fun onReadRemoteRssi(gatt: BluetoothGatt?, rssi: Int, status: Int)
Link copied to clipboard
open fun onReliableWriteCompleted(gatt: BluetoothGatt?, status: Int)
Link copied to clipboard
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
open override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int)
Link copied to clipboard

Register a protocol for device detection and data processing

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun selectProtocol(protocol: EUCProtocol): Boolean
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun sendCommand(commandType: CommandType, value: Any = Unit)
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun sendCommand(command: ByteArray, characteristicUuid: UUID)
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun sendCommand(commandId: String, value: CommandValue = CommandValue.None)
Link copied to clipboard
Link copied to clipboard

Callback registration methods.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun setMaxRetries(retries: Int)
Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
fun setProtocolSelectionMode(mode: ProtocolSelectionMode)
Link copied to clipboard
fun setScanTimeout(timeout: Long)
Link copied to clipboard
@RequiresApi(value = 23)
@RequiresPermission(value = "android.permission.BLUETOOTH_SCAN")
fun startScan()

Start scanning for EUC devices

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_SCAN")
fun stopScan()

Stop scanning for devices