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;
  • does not send any write, lock, light or configuration commands.

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 odometer, 0.1 km matches app
0x0A 4 ride time, s matches app
0x0B 2 unknown (655 at 68 %; range in 0.1 km?) open
0x0C 4 trip, 0.1 km matches app
0x0F 1 traction battery, % plausible
0x11 1 unknown open
0x23 2 unknown open
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). This library deliberately does not implement it.

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.2.1

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.2.1
File Size Uploaded Provenance Actions
tenways_ble-0.2.1.tar.gz 164.3 kB With provenance Details for tenways_ble-0.2.1.tar.gz

Built distribution (wheel)

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

Total release size: 178.0 kB

Release files / tenways_ble-0.2.1.tar.gz

Download URL tenways_ble-0.2.1.tar.gz
Size 164.3 kB
Tags Source
SHA-256 checksum
How to use checksums
19d873fc7c0abf4b50ebf1da89208b53f1753dc4827f6dbe3b5e0144f933e4c0
BLAKE2b-256 checksum
How to use checksums
086b5336c3b8cb8f9bf55be3932535933ed55531f51bbd2a17665254a79d1dfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

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

Download URL tenways_ble-0.2.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ae60e227fc4fd2572b5b5ba0ec9567c097d53c80e6b60087842d305ffacb7d5
BLAKE2b-256 checksum
How to use checksums
db1fc8db0afbf4aad3d3e529e2bf1a776deef842d0ad0b7fdeea92d617fd1807
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Security for tenways-ble 0.2.1

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.2.1.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 Oct 18, 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