Experimental Android BLE library for electric unicycles — work in progress
FR | EN
Bluetooth Low Energy library for Electric Unicycles (EUC), providing an Android client API and manufacturer-specific protocol implementations.
GroupId:
io.github.tritbool
ArtifactId:euc-ble-library
Modules:euc-ble-protocols+euc-ble-session+euc-ble-core(KMP),euc-ble-android(Android connector)
Upcoming version:1.0.0
Work in progress. The upcoming 1.0.0 release is not a stability guarantee. Protocol support is incomplete; some features may be broken, vary by wheel or firmware, or change as the project evolves. Verify behavior on the exact device and firmware you plan to use. Unit tests and captured traffic do not replace physical-device testing.
The project provides:
EucBleClient, with built-in protocol registration.Flow and callback APIs for telemetry and connection events.Captured-frame tests are partial and do not imply complete model, firmware, or command coverage.
TuxWheel is the first client app built with this library. It is available as a pre-release, with publication on F-Droid planned.
Multi‑vendor support
KingSong, Gotway/Begode, InMotion, Ninebot (standard + Z‑series), Leaperkim/Veteran, Nosfet.
Simple client API
Single entrypoint EucBleClient with ConnectionCallback, DataCallback, and ErrorCallback on the app side.
Separated BLE transport
BleTransport is the stack boundary; Android’s BLEManager supplies its GATT implementation.
Other platforms need their own connector and platform-specific orchestration.
Rich data model
EUCData exposes speed, voltage, current, temperature, battery level, distance, power, charging state, ride time, and more.
Sessions decide when; protocols decode and encode; the connector performs BLE I/O.
Adding iOS: a proposed euc-ble-ios would provide a client API, platform-specific orchestration
and a CoreBluetooth BleTransport. It could reuse the KMP core’s session drivers, protocols and
policies, which already target iOS.
Gold annotations show extension points, not implemented support.
See the architecture overview for details and diagram sources.
EucBleClient callbacks are invoked from background contexts, never guaranteed to run on the main thread – it’s up to you to switch to Dispatchers.Main for UI work.Flow<EUCData> for decoded telemetry.Flow<ByteArray> (rawFrameFlow) for raw frames (useful for logging / debugging).client.getBMSData() returns the latest BMS snapshot (cell voltages, temperatures, pack
voltage/current and charging status) of wheels exposing a smart BMS, or null otherwise. It is a
pull API: poll it as often as needed, the app decides what to do with it (display, logging, …).Example usage on the app side:
val client = EucBleClient(context)
client.setConnectionCallback(object : ConnectionCallback() {
override fun onDeviceDiscovered(device: EUCDevice) {
client.connect(device)
}
})
client.setDataCallback(object : DataCallback {
override fun onDataReceived(data: EUCData) {
// process telemetry on an appropriate dispatcher
}
})
client.setErrorCallback(object : ErrorCallback {
override fun onError(error: BLEException) {
// fine-grained error handling
}
})
client.initialize()
client.startScan()
protocols, models, and frames.HTML coverage reports are published under:
/test-coverage/full/ – global view./test-coverage/focused/ – protocols / models / frames only.(See the “Test coverage reports” section below.)
Tests include real BLE captures and constructed unit-test cases:
RAWWHEELLOG) for each brand.Additional tests cover selected command/polling contracts, frame reassembly, and emission frequency. They do not guarantee that all telemetry fields or commands behave consistently across protocols.
To make coverage visible:
These reports are copied into the generated site and published via GitHub Pages:
dependencies {
implementation("io.github.tritbool:euc-ble-library:1.0.0")
}
The dependency will be usable from Maven Central once version 1.0.0 has been published.
Android BLE requires:
BLUETOOTH_SCAN / BLUETOOTH_CONNECT permissions (and sometimes location).The library exposes structured errors via BLEException and ErrorCallback to handle these cases.
Home (this page):
https://tritbool.github.io/euc_ble_library/
Kotlin API reference (Dokka):
https://tritbool.github.io/euc_ble_library/api/
The Pages workflow publishes the generated Dokka reference after main-branch quality checks complete or when run manually against a completed main-branch quality run.
Issues, PRs, and additional WheelLog captures (new wheels, new firmwares, tricky edge cases) are all welcome.
Repository: https://github.com/Tritbool/euc_ble_library.