ACGAM T02P Treadmill BLE communication library for Node.js.
It can be easily used for instance on Raspberry Pi 4 with Raspbian OS to grab live stats from your treadmill.
npm i acgam-t02p
import { BluetoothDeviceAddress, TreadmillConnection, TreadmillStatus } from 'acgam-t02p';
const DEVICE_ADDRESS = 'FF:FF:FF:FF:FF:FF'; // TODO: Change with your real device address
(async () => {
const connection = await TreadmillConnection.forAddress(
BluetoothDeviceAddress.fromString(DEVICE_ADDRESS)
);
connection.addStatusNotificationEventListener(handleNotification);
})();
function handleNotification(status: TreadmillStatus) {
console.log(status);
}
This is main class that enables you to maintain a connection and communication with treadmill device.
Helper value object that stores valid bluetooth device address.
It's data structure that will come into your treadmill status notification listener:
type TreadmillStatus
= { status: 'STANDBY' }
| { status: 'STOPPED' }
| { status: 'WAKING_UP' }
| { status: 'PRESTART' }
| { status: 'STARTING'; countdown: number }
| {
status: 'RUNNING' | 'STOPPING';
elapsedSeconds: number;
distanceInMeters: number;
speed: {
currentKmh: number;
targetKmh: number;
};
};
Example status data with its interpretation:
JSON | Interpretation |
---|---|
{ "status": "STOPPED" } |
Treadmill is stopped |
{ "status": "STARTING", "countdown": 5 } |
Treadmill is going to start and it's 5 seconds until start. |
{ "status": "RUNNING", "elapsedSeconds": 330, "distanceInMeters": 1500, "speed": { "currentKmh": 11.5, "targetKmh": 8 } } |
Treadmill is running. Elapsed time: 5 minutes 30 seconds. Distance: 1.5km. Current speed 11.5 km/h and it's slowly descending to target 8 km/h. |