# acgam-t02p

> ACGAM T02P Treadmill BLE communication library

Latest version **0.0.4** (published 2023-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install acgam-t02p
pnpm add acgam-t02p
yarn add acgam-t02p
bun add acgam-t02p
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-03-22 |
| First published | 2023-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Wiktor Toporek |
| Maintainers | vviktor |
| Keywords | treadmill, bluetooth, acgam |

## Links

- npm: https://www.npmjs.com/package/acgam-t02p
- Repository: https://github.com/vViktorPL/acgam-t02p-node
- Homepage: https://github.com/vViktorPL/acgam-t02p-node#readme
- Issues: https://github.com/vViktorPL/acgam-t02p-node/issues
- npm.io page: https://npm.io/package/acgam-t02p

## Dependencies (1)

- [node-ble](https://npm.io/package/node-ble.md) ^1.9.0

## Recent versions

- 0.0.4 (latest) — 2023-03-22
- 0.0.3 — 2023-03-20
- 0.0.2 — 2023-02-12
- 0.0.1 — 2023-02-08

## README

# acgam-t02p

[ACGAM T02P Treadmill](https://www.acgam.com/collections/treadmill/products/acgam-2-in-1-folding-treadmill-with-remote-control-and-led-display-installation-free-under-desk-electric-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

```bash
npm i acgam-t02p
```

## Example usage

```typescript
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:

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

---
_Source: https://npm.io/package/acgam-t02p · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
