Skip to content

michaelroper/web-ble-ftms

Repository files navigation

FTMS Fitness Tracker

A web-based fitness tracker that connects to indoor bikes and treadmills via Web BLE (Bluetooth Low Energy) and the FTMS (Fitness Machine Status Service) protocol.

Features

  • BLE Device Scanning: Scan for nearby FTMS-compatible fitness devices
  • Real-time Data: Display live metrics (cadence, speed, power, resistance, heart rate, etc.)
  • Customizable Dashboard: Drag and arrange data metrics into a grid layout
  • Persistent Configuration: Grid layout saved to localStorage
  • Mobile Optimized: Designed for smartphone use during workouts

Tech Stack

  • Svelte: Lightweight reactive UI framework
  • Vite: Fast build tool
  • Web BLE API: Browser Bluetooth connectivity
  • FTMS Protocol: Fitness machine standard

Getting Started

Installation

npm install

Development

npm run dev

Then open http://localhost:5173 in your browser (or access from your phone on the local network).

Production Build

npm run build
npm run preview

How It Works

BLE Connection

  1. User taps "Start Scanning"
  2. Browser requests Bluetooth device selection (native OS dialog)
  3. App filters for devices with FTMS service (UUID: 0x181a)
  4. Selected device connects and starts streaming data

Data Parsing

  • Indoor Bikes: Parse IndoorBikeData characteristic (0x2ad2)
    • Speed, Cadence, Power, Resistance, Heart Rate
  • Treadmills: Parse TreadmillData characteristic (0x2acd)
    • Speed, Cadence, Inclination, Heart Rate

Dashboard Customization

  • Tap the ⚙️ icon to edit grid blocks
  • Select a data field from the available fields list
  • Choose block size (half-width or full-width)
  • Layout persists automatically

Browser Support

  • ✅ Chrome/Edge (Android)
  • ✅ Safari (iOS 14.5+)
  • ✅ Samsung Internet
  • ❌ Firefox (limited BLE support)

FTMS Characteristics

Supported UUIDs:

  • Service: 0x181a - Fitness Machine Status Service
  • Indoor Bike: 0x2ad2 - Indoor Bike Data
  • Treadmill: 0x2acd - Treadmill Data

Project Structure

src/
├── lib/
│   ├── ftms.js           # BLE connection & FTMS parsing
│   ├── store.js          # Svelte stores for state management
│   ├── Scanner.svelte    # Device discovery screen
│   ├── Dashboard.svelte  # Main workout display
│   ├── GridBlock.svelte  # Individual data tile
│   └── GridEditor.svelte # Grid customization modal
├── App.svelte            # Main app component
├── main.js               # Entry point
└── app.css               # Global styles

Known Limitations

  • Web BLE is only available on HTTPS (or localhost)
  • Some fitness devices may not fully implement FTMS spec
  • Pairing required on first connection (device must be discoverable)

Future Enhancements

  • Workout history and analytics
  • Session save/export
  • Interval timer integration
  • Audio feedback and notifications
  • Dark mode
  • Device management (disconnect, forget)

About

Playing around with AI coding and Web BLE APIs to connect to devices like spin bikes.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors