0.0.4 • Published 1 year ago

acgam-t02p v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

acgam-t02p

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.

Installation

npm i acgam-t02p

Example usage

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);
}

API

TreadmillConnection

This is main class that enables you to maintain a connection and communication with treadmill device.

BluetoothDeviceAddress

Helper value object that stores valid bluetooth device address.

TreadmillStatus

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:

JSONInterpretation
{ "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.
0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago