{"id":26412974,"url":"https://github.com/tangnpc/ble-osc-heartrate","last_synced_at":"2025-03-17T22:53:35.777Z","repository":{"id":262518533,"uuid":"887499184","full_name":"TangNPC/ble-osc-heartrate","owner":"TangNPC","description":"一个 Python 项目，用于通过 Bluetooth Low Energy (BLE) 扫描心率传感器数据，并通过 Open Sound Control (OSC) 协议将心率信息实时发送到 VRChat 客户端。支持自动连接符合条件的 BLE 设备，提取心率数据并进行处理，支持动态更新 VRChat 中的心率参数。","archived":false,"fork":false,"pushed_at":"2024-11-15T07:30:11.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T20:16:13.355Z","etag":null,"topics":["ble","bluetooth","heart-rate","osc","python","vrchat"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TangNPC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-12T20:54:18.000Z","updated_at":"2025-01-30T13:41:29.000Z","dependencies_parsed_at":"2025-03-17T20:16:41.633Z","dependency_job_id":"e82dfae3-d778-4d6f-81bb-09a3dc44e077","html_url":"https://github.com/TangNPC/ble-osc-heartrate","commit_stats":null,"previous_names":["heytang233/ble-osc-heartrate","tangnpc/ble-osc-heartrate"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangNPC%2Fble-osc-heartrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangNPC%2Fble-osc-heartrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangNPC%2Fble-osc-heartrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TangNPC%2Fble-osc-heartrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TangNPC","download_url":"https://codeload.github.com/TangNPC/ble-osc-heartrate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244123620,"owners_count":20401627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ble","bluetooth","heart-rate","osc","python","vrchat"],"created_at":"2025-03-17T22:53:34.951Z","updated_at":"2025-03-17T22:53:35.768Z","avatar_url":"https://github.com/TangNPC.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VRChat 心率显示\n\n这是一个结合了 **Bluetooth Low Energy (BLE)** 扫描和 **OSC** 消息发送的 Python 项目。它可以扫描附近的 BLE 设备，提取心率数据，并通过 **Open Sound Control (OSC)** 协议将心率数据发送到 **VRChat** 客户端，实现实时显示和控制。\n\n## 功能\n\n- 扫描并连接到符合特定 **公司 ID** 的 BLE 设备。\n- 提取 BLE 广告数据中的心率值。\n- 将心率数据通过 **OSC** 协议发送到 VRChat。\n- 支持实时心率更新。\n\n## 环境要求\n\n- Python 3.x\n- 以下 Python 库：\n  - **`bleak`**: 用于 BLE 设备扫描\n  - **`python-osc`**: 用于 OSC 消息发送\n\n## 安装依赖\n\n你可以通过以下命令安装项目的所有依赖：\n\n~~~bash\npip install -r requirements.txt\n~~~\n\n或者直接安装依赖：\n\n~~~bash\npip install bleak python-osc\n~~~\n\n## 使用方法\n1. **在类似**`zepp lite`软件中打开心率广播和蓝牙广播，然后在手环上启动一个运动，手环设备就会主动广播数据\n   \n\n3. **连接到 BLE 设备**  \n   启动程序后，它会自动扫描附近的 BLE 设备，并提取符合条件的设备数据（例如带有特定公司 ID 的设备）。程序会检查心率数据，并将其发送到 VRChat 客户端。\n\n4. **启动程序**  \n   使用以下命令启动程序：\n   \n   ~~~bash\n   python main.py\n   ~~~\n   \n   程序会持续扫描 BLE 设备并将心率数据发送到 VRChat。\n\n3. **停止扫描**  \n   在命令行按 `Ctrl+C` 停止程序。\n\n## 配置\n\n* **VRChat 客户端的 IP 地址和端口** ：  \n  默认情况下，程序将数据发送到本地的 VRChat 客户端。你可以修改 `VRCHAT_IP` 和 `VRCHAT_PORT` 变量来适配你的环境。\n  \n  ~~~python\n  VRCHAT_IP = \"127.0.0.1\"  # VRChat 客户端的 IP 地址\n  VRCHAT_PORT = 9000       # VRChat 默认的 OSC 端口\n  ~~~\n  \n* **BLE 设备过滤条件** ：  \n  `TARGET_COMPANY_ID` 用于过滤蓝牙设备，仅当设备的公司 ID 与此值匹配时，程序才会提取其数据。\n\n  ~~~python\n  TARGET_COMPANY_ID = 0x0157  # 设置要扫描的公司 ID\n  ~~~\n\n## 代码结构\n\n* `main.py`：主程序文件，包含 BLE 扫描和 OSC 消息发送逻辑。\n* `requirements.txt`：包含所有依赖库的文件。\n\n## 注意事项\n\n* 在使用该程序之前，确保你已在 VRChat 中启用了接收 OSC 消息的功能，并正确配置了 VRChat 客户端的 OSC 服务器地址和端口。\n* 该程序通过蓝牙扫描心率数据，需要你确保扫描到符合条件的设备（如带有心率传感器的设备）。\n\n## 常见问题\n\n1. **程序无法识别设备**  \n   请确保 BLE 设备在扫描范围内，并且设备的公司 ID 与 `TARGET_COMPANY_ID` 设置一致。\n\n2. **无法连接到 VRChat**  \n   请确认 VRChat 客户端正在运行，并且已经配置了正确的 OSC 接收设置。\n\n3. **心率值显示异常**  \n   检查蓝牙设备发送的广告数据，确保正确提取了心率信息。可以通过打印日志来调试。\n\n## 许可证\n\n本项目使用 **MIT** 许可证，详情请参见 [LICENSE](LICENSE) 文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangnpc%2Fble-osc-heartrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftangnpc%2Fble-osc-heartrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftangnpc%2Fble-osc-heartrate/lists"}