Skip to main content

tenways-ble

Small experimental Python library and CLI for local BLE access to TENWAYS e-bikes.

Read-only by design:

  • discovers nearby TENWAYS BLE devices;
  • decodes the proprietary King Meter frame protocol (CRC-16/MODBUS, TLV fields) used by the TENWAYS Longtail Duo;
  • reads live telemetry: traction battery, odometer, trip, max/average speed, ride time;
  • reads firmware and serial number;
  • reads the standard Bluetooth Battery Level characteristic (0x2A19), which is not the traction battery;
  • sends no write, lock, light or configuration commands, except the optional, explicit clock sync set_clock() (see below).

The protocol was reconstructed from an Android HCI capture of the official TENWAYS app; all test vectors are the original captured frames. Live operation against the bike is still being validated.

Library usage

import asyncio
from tenways_ble import TenwaysBike

async def main():
    async with TenwaysBike("E8:88:6C:31:B3:0D") as bike:
        status = await bike.read_status()
        print(status.battery_percent, status.odometer_km)

asyncio.run(main())

TenwaysBike also accepts an already connected BleakClient (for example from bleak-retry-connector in Home Assistant). It then only speaks the protocol and leaves the connection to the caller.

The sans-I/O protocol module tenways_ble.protocol builds and parses frames without any Bluetooth dependency.

Devices

Device Advertised name Notes
Longtail Duo drive Longtail Duo King Meter service, telemetry source. Standard battery reads ~1 %, not the traction battery.
Separate BLE device Tenways-ble-XXXXXX HID service, standard battery 100 %, also exposes the King Meter service. Function unconfirmed (remote/control unit?).

Known GATT layout

Standard battery service:

  • Service: 0000180f-0000-1000-8000-00805f9b34fb
  • Battery Level: 00002a19-0000-1000-8000-00805f9b34fb (READ, NOTIFY)

King Meter service (43480001-… contains KING METER in ASCII):

  • Service: 43480001-f001-4b49-4e47-204d45544552
  • Write: 43480002-f001-4b49-4e47-204d45544552 (WRITE WITHOUT RESPONSE)
  • Notify: 43480003-f001-4b49-4e47-204d45544552 (NOTIFY)
  • Read: 43480004-f001-4b49-4e47-204d45544552 (READ, no useful content observed)

King Meter protocol

[TYPE] [00] [LEN] [CMD] [PAYLOAD…] [CRC_HI] [CRC_LO] [45]
Element Meaning
TYPE 0x62 read, 0x63 write
00 constant header byte
LEN length of CMD + PAYLOAD; frame length is LEN + 6
CRC CRC-16/MODBUS (0xA001 reflected, init 0xFFFF) over TYPE…PAYLOAD, high byte first
45 end marker

A read request lists field keys; the reply returns [key][size][value] entries, big endian. Replies (54 bytes for status) exceed the default 20-byte notification payload and are reassembled.

Status request (CMD 0x0B), as sent by the app: 62 00 0c 0b 06 07 08 09 11 0a 0b 0c 0f 23 4f 84 91 45

Key Size Meaning Status
0x06 2 current speed, 0.1 km/h plausible, 0 while parked
0x07 2 max speed, 0.1 km/h matches app
0x08 2 average speed, 0.1 km/h matches app
0x09 4 trip distance, 0.1 km (tripDistance in the app) equals 0x0C in the capture; scale fits 9.5 h × 12.6 km/h
0x0A 4 ride time, s matches app
0x0B 2 remaining range (remainingRange in the app), km probable; a low byte ≥ 0x80 (655 at assist level 0) counts as none follows assist level, 60–43 km for levels 1–5 at 68 %
0x0C 4 odometer, 0.1 km (totalRange in the app, shown as odo) equals 0x09 in the capture
0x0F 1 traction battery, % plausible
0x11 1 light, 0 = off (lightControl in the app) seen in Home Assistant
0x23 2 power (power in the app, values above 3000 ignored), probably motor W 0 while parked, unconfirmed riding
0x4F 1 unknown open

Device info request (CMD 0x04, keys 04 05 4f 70): key 0x04 holds three version bytes (2.20.16 observed; the app shows 1.4.0 elsewhere, so this may be another component), key 0x70 the ASCII serial number.

The app also writes a clock sync (TYPE 0x63, CMD 0x01, key 0x3C, value: flags 0x02, year−2000, month, day, hour, minute, second). TenwaysBike.set_clock() sends the same frame; it is the only write this library implements, it is never sent on its own, and it is not yet confirmed on a bike: the frame is checked against the capture byte for byte, but whether the bike takes it as local time, what the flags byte means and what the acknowledgement looks like is open. The bike has no time zone or daylight saving, so it needs setting again after each change.

Install for development

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
pip install -e '.[dev]'

On Linux, BlueZ and a working Bluetooth adapter are required.

CLI

Scan for likely TENWAYS devices:

tenways scan

Read live telemetry (traction battery, odometer, …):

tenways status E8:88:6C:31:B3:0D

Read firmware and serial number:

tenways device-info E8:88:6C:31:B3:0D

Read the standard BLE battery percentage (not the traction battery):

tenways battery E8:88:6C:31:B3:0D

Show basic GATT information and battery level:

tenways info E8:88:6C:31:B3:0D

Subscribe to the proprietary notification characteristic:

tenways listen E8:88:6C:31:B3:0D

Stop with Ctrl+C.

Optional HCI trace on Linux

For traffic generated by this library/CLI on the same Linux Bluetooth controller, BlueZ btmon is useful:

sudo btmon -i hci0 -w tenways.btsnoop

Then run the CLI in another shell. The resulting tenways.btsnoop file can be inspected with Wireshark.

This does not passively capture a BLE connection between an Android phone and the bicycle. For the original TENWAYS app, use Android HCI snoop logging or a dedicated BLE sniffer.

Safety

tenways-ble 0.1.0 never writes arbitrary data to the proprietary TENWAYS write characteristic. Reverse engineering should start from observed traffic rather than guessed commands.

License

MIT

Never publish a raw phone HCI log; it contains traffic and identifiers of other devices.

Releasing

Releases are published to PyPI by GitHub Actions via trusted publishing when a v* tag is pushed. The tag must match __version__.

Acknowledgements / Credits

Based on and inspired by stein155/cgo600-bridge, which provided valuable groundwork for understanding the proprietary TENWAYS telemetry protocol and its integration with Home Assistant.

Many thanks to the original author and contributors.

The Longtail Duo implementation was developed using independently captured Bluetooth HCI traffic from the official TENWAYS app. It uses the King Meter BLE transport rather than the Nordic UART Service used by the CGO600 bridge.

Metadata

Release files for tenways-ble 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tenways-ble 0.4.0
File Size Uploaded Provenance Actions
tenways_ble-0.4.0.tar.gz 169.6 kB With provenance Details for tenways_ble-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tenways-ble 0.4.0
File Interpreter ABI Platform Actions
tenways_ble-0.4.0-py3-none-any.whl Python 3 none any Details for tenways_ble-0.4.0-py3-none-any.whl

Total release size: 185.6 kB

Release files / tenways_ble-0.4.0.tar.gz

Download URL tenways_ble-0.4.0.tar.gz
Size 169.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ce05be17b95e5f9000c2c235451b2b710cc420a3a79b8a224842c7f2380a953a
BLAKE2b-256 checksum
How to use checksums
ee335550f45d822e2eb3e6ef044ae002574c6a68e5b33b7a32751d45f95ccf13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Release files / tenways_ble-0.4.0-py3-none-any.whl

Download URL tenways_ble-0.4.0-py3-none-any.whl
Size 16.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d64b8e6e2f1f010e2e0f26aa58259e88114f050ba2916ade814ac8b9ccebd7d
BLAKE2b-256 checksum
How to use checksums
2ddd4ad6f20948d6973230bc85dc5ad872020976932378dd9b2e3578a60ce672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

Security for tenways-ble 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tenways_ble-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page