Skip to main content
Glama
dncore

efferent-ble-simulator

by dncore

Efferent 通过真实无线电(Linux BlueZ)模拟蓝牙低功耗(BLE)外设设备:FTMS 智能骑行台骑行功率计速度/踏频传感器心率监测器。它暴露了一个 MCP 服务器(stdio 或 HTTP),使 AI 代理——以及内置的 Web 仪表盘——能够像控制真实骑行台一样启动、配置和监控模拟。


功能特性

  • 4 种设备类型,通过真实 BLE 无线电广播:FTMS 智能骑行台(0x1826)、骑行功率(0x1818)、速度/踏频(0x1816)、心率(0x180D)

  • 完整的 FTMS 控制点支持:请求控制 / 启动 / 停止 / 重置 / 设置目标功率 / 设置阻力 / 设置室内骑行模拟参数

  • 动态模拟:拟人化的功率/踏频漂移 + 基于物理的速度模型(体重、坡度、Crr、CdA),5 种骑行场景,包括脚本化的 ride_script

  • 热参数更新:运行时更改参数——已连接的手机保持链路,并在下一次通知时收到新值(无需重新配对)

  • 命名配置预设:保存 / 加载 / 重命名 / 删除最多 20 个命名配置,MCP 与仪表盘共享

  • 17 个 MCP 工具供代理使用:控制、配置、配置预设、交互规则、会话、日志、实时设备状态、版本

  • Web 仪表盘(React + shadcn/ui):状态、表单、一键骑行模板、交互规则、会话/配置管理、实时日志侧面板

  • Docker Compose 一键部署(MCP + 仪表盘 + 通过 HTTP 提供的 Skill 文件),带健康检查的长期运行

  • 版本化:MCP serverInfo.version + ble_get_version 让代理检测更新


Related MCP server: pyBTMCP

运行环境

要求

详情

操作系统

仅限 Linux — 模拟器通过 D-Bus 驱动宿主机的 BlueZ

BlueZ

≥ 5.87(5.86 存在广播注册缺陷)

硬件

需要 支持 BLE 的适配器(内置或 USB 适配器)才能实际广播

D-Bus 策略

/etc/dbus-1/system.d/ble-simulator.conf(由 npm run setup 安装)— 非 root 用户注册 GATT 所必需

Docker

mcp 容器挂载宿主机 D-Bus 套接字;BLE 无线电始终保留在宿主机上

不支持

原生 macOS / Windows(需要不同的 BLE 协议栈);没有 BLE 适配器时 MCP 服务可运行但不发送任何数据

架构

┌──────────────┐   MCP protocol    ┌───────────────────────────┐
│ AI Agent /   │ ◄───────────────► │ MCP Server (HTTP :3300)   │
│ MCP Client   │  stdio / :3300    │ Web Dashboard (:3330)     │
│ (Claude,     │                   └────────────┬──────────────┘
│  Codex, pi)  │                                │ BlueZ D-Bus (system bus)
└──────────────┘                                ▼
                                     ┌───────────────────────────┐
                                     │ Host Linux BlueZ          │
                                     │ bluetoothd + BLE adapter  │
                                     │ (D-Bus policy, ≥ 5.87)    │
                                     └────────────┬──────────────┘
                                                  │ HCI / radio
                                                  ▼
                                     ┌───────────────────────────┐
                                     │ BLE advertisement + GATT  │
                                     │ FTMS / Power / CSC / HR   │
                                     └────────────┬──────────────┘
                                                  │
                                     ┌────────────▼──────────────┐
                                     │ Phone / Cycling App       │
                                     │ (Zwift, Garmin, Strava...)│
                                     └───────────────────────────┘

设备类型

类型

BLE 服务

特征

FTMS 智能骑行台

0x1826

FM 特征、室内骑行数据(通知)、控制点(写入/指示)、状态、阻力/功率范围

骑行功率

0x1818

功率/踏频测量、车轮与曲柄数据

速度/踏频(CSC)

0x1816

车轮与曲柄转数计数器

心率

0x180D

心率测量、身体传感器位置、电池


快速开始

前置条件

  • 装有 BlueZ ≥ 5.87(bluetoothd)且带 BLE 适配器的 Linux

    BlueZ 5.86 存在广播注册缺陷;在具有严格 MGMT 校验的内核上,每次 RegisterAdvertisement 都会失败。请先升级:sudo pacman -S bluez && sudo systemctl restart bluetooth(Arch)/ sudo apt install bluez(Debian)。

  • Node.js ≥ 18

1. 原生安装

npm install
npm run setup     # sudo — installs D-Bus policy, enables bluetoothd, verifies GATT
npm run build
npm run start:http   # HTTP mode on :3300 (or npm start for stdio)

npm run setup 会写入 /etc/dbus-1/system.d/ble-simulator.conf — 非 root 用户注册 GATT 必需(没有它设备可以广播但无法被连接)。

2. Docker Compose(服务器推荐)

bash scripts/docker-up.sh     # host prep (sudo, once) + build + start

URL

用途

http://<host>:3300/mcp

MCP 端点

http://<host>:3330/

Web 仪表盘

http://<host>:3330/skill/SKILL.md

操作技能(供代理使用)

http://<host>:3330/help

仪表盘帮助页面

零编译构建(better-sqlite3 预编译二进制);受限网络请使用镜像源:

NPM_REGISTRY=https://registry.npmmirror.com \
BETTER_SQLITE3_BINARY_HOST_MIRROR=https://registry.npmmirror.com/-/binary/better-sqlite3 \
bash scripts/docker-up.sh

管理:bash scripts/docker-up.sh status|logs|down


MCP 工具(17 个)

工具

用途

ble_start / ble_stop / ble_restart

启动 / 停止 / 重启模拟

ble_status

控制器状态 + 当前配置 + 实时设备状态(阶段/功率/踏频/心率)

ble_configure

更新配置 — 若正在运行且设备类型相同则原地热更新

ble_get_config

当前/最新配置(JSON 格式,用于表单回填)

ble_save_config

将当前参数保存为命名预设(最多 20 个

ble_list_configs / ble_get_config_detail

列出 / 查看已保存的预设

ble_rename_config / ble_delete_config

重命名 / 删除预设

ble_set_interaction / ble_clear_interactions

自定义 BLE 写入响应规则

ble_list_sessions / ble_get_session

会话历史 / 详情

ble_get_logs

持久化通信日志(连接/写入/通知/错误)

ble_get_version

MCP + Skill 版本、变更日志、Skill URL(用于更新检测)

示例

{
  "method": "tools/call",
  "params": {
    "name": "ble_start",
    "arguments": {
      "deviceType": "ftms",
      "ftms": { "simulation": { "enabled": true, "scenario": { "type": "ride_script" } } }
    }
  }
}

动态模拟

通过 FTMS / CyclingPower / CSC 上的 simulation 启用:

"simulation": {
  "enabled": true,
  "riderWeightKg": 75, "bikeWeightKg": 8, "crr": 0.004, "cdA": 0.35,
  "fatigueFactor": 0.0005, "cadenceCoupling": "proportional", "microPauseProbability": 0.008,
  "autoStart": true,
  "scenario": { "type": "ride_script" }
}

参数

默认值

描述

enabled

false

总开关

riderWeightKg / bikeWeightKg

75 / 8

速度物理模型(骑手+自行车质量)

crr / cdA

0.004 / 0.35

滚动阻力 / 迎风面积

fatigueFactor

0

每分钟功率衰减(0 = 无)

cadenceCoupling

proportional

proportional / inverse / independent

microPauseProbability

0.005

每次滴答的滑行暂停概率

autoStart

false(ride_script 默认开启)

无需应用发送 Start 即可开始骑行

scenario

freeride

骑行场景(见下文)

场景

  • steady — 仅自然微波动

  • freeride(默认)— 基础功率每 60–180 秒漂移 ±20%

  • intervals — 高/低功率交替

  • warmup_main_cooldown — 热身 → 主训练 → 放松

  • ride_script — 脚本化骑行:一系列骑行动作序列(start / cruise / climb / sprint / coast / stop),每个动作都有目标功率、坡度以及可选的踏频;自动启动,通过 repeat: true 循环,stop 将功率/踏频/速度归零。省略 phases 则使用内置默认脚本。


热更新与稳定序列号

  • 热更新:运行中调用 ble_configure 且设备类型相同,参数会原地生效——已连接的手机保持链路,并在下一次通知时收到更新值。更改设备类型仍会重启(新序列号强制重新发现)。

  • 稳定序列号SIM_SERIAL_STABLE=1 使同类型会话的序列号保持稳定(SIM001-FTMS),手机在停止/启动后无需忘记设备即可重新连接。


环境变量

变量

默认值

描述

MCP_TRANSPORT

stdio

stdiohttp

MCP_PORT / MCP_HOST

3300 / 0.0.0.0

HTTP 监听地址

SIM_DEVICE_PREFIX

OPEN_RIDE

广播名称前缀

SIM_INSTANCE_ID_MODE

设备名称的实例 ID 模式

SIM_SERIAL_STABLE

未设置

1 = 同类型会话使用稳定序列号

SKILL_PUBLIC_URL

/skill/SKILL.md

公开的 Skill URL(由 ble_get_version 返回)


源码结构

src/
├── index.ts             # entry, lifecycle
├── mcp-server.ts        # 17 MCP tool definitions & handlers
├── ble-controller.ts    # BlueZ D-Bus lifecycle, advertisement, hot-update
├── database.ts          # SQLite layer (sessions / saved_configs / logs)
├── config.ts            # config merge & defaults
├── version.ts           # version single-source
├── simulator.ts         # HeartRate / Battery simulators
├── cycling-simulator.ts # power/cadence simulators + physics + ride_script engine
└── devices/             # heart-rate / cycling-power / csc / ftms GATT devices

BLE 外设访问通过宿主机 BlueZ D-Bus 进行(容器挂载宿主机 D-Bus 套接字)。设计记录见 docs/design/*.md


许可证

MIT © BLE Simulator Contributors

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Bluetooth Low Energy (BLE) MCP server that allows AI agents to scan, connect to and communicated with BLE devices, as well as simulate BLE perhipherals.
    15
    BSD 2-Clause "Simplified"
  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A BLE fitness device simulator that enables AI agents to control simulated heart rate monitors, treadmills, and cycling trainers via the Model Context Protocol. It integrates ESP32 firmware, an MQTT broker, and a FastAPI backend for comprehensive device management and real-time interaction.
  • A
    license
    A
    quality
    C
    maintenance
    A stateful Bluetooth Low Energy (BLE) MCP server that enables AI agents to scan, connect, read/write characteristics, and subscribe to notifications on BLE devices.
    35
    17
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Exposes Garmin Connect data and workout management to AI agents, supporting tools, resources, and prompts for health data, workout creation, and coaching workflows.
    1

View all related MCP servers

Related MCP Connectors

  • Multi-tenant Telegram gateway for AI agents — HTTP+stdio, 8 tools, MTProto User API

  • Run, build, and validate firmware on virtual hardware from your AI agent. Hardware knowledge corpus.

  • Build, validate, and deploy multi-agent AI solutions from any AI environment.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dncore/efferent-ble-simulator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server