一款macOS命令行工具,用于扫描、连接、配对和通信蓝牙低功耗外设,基于Swift和BLESwift构建。

Stars

116

7 天增长

+5

Fork 数

0

开放 Issue

0

开源协议

Apache-2.0

最近更新

2026-07-19

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它提供了完整的、可脚本化的BLE客户端,具备实时排序扫描、完整GATT树检查、YAML/JSON类型化负载编码以及L2CAP通道支持,同时实现了干净的stdout/stderr分离。

适合谁使用

  • 需要调试或自动化BLE交互的macOS开发者
  • 测试原型或验证规范的BLE硬件工程师
  • 从终端配置或监控智能设备的物联网爱好者
  • 管理macOS环境中BLE外设的系统管理员

典型使用场景

  • 快速扫描附近BLE设备并按信号强度排序识别
  • 读取和写入特征与描述符,包括流式通知
  • 检查外设的完整GATT服务/特征/描述符树
  • 通过shell脚本或管道自动化BLE设备配对和数据交换

项目优势

  • 实时扫描表格,按平滑RSSI排序并带有颜色编码,动态更新
  • 支持多种操作:扫描、连接、配对、检查、读取、写入、L2CAP通道
  • 负载文件支持YAML/JSON,包含类型化字段(u8–u64、i8–i64、hex、string、pad)及字节序控制
  • 输出规范:进度/错误信息到stderr,数据到stdout,便于通过管道传递给jq或重定向而不产生污染

使用前须知

  • 仅限macOS,未提及Linux或Windows支持
  • 配对需要触发CoreBluetooth的系统对话框(非完全编程化)
  • 需要手动为终端应用授予蓝牙权限

README 快速开始

ble — a BLE command-line tool

A macOS CLI for scanning, connecting to, and pairing with Bluetooth Low Energy peripherals, built on BLESwift and swift-argument-parser.

Install

Homebrew

brew install kylebrowning/tap/ble

Mint

mint install kylebrowning/BLESwiftCLI

From source

swift build -c release
cp .build/release/ble /usr/local/bin/

For development builds:

swift build
.build/debug/ble --help

Permissions: the first run prompts for Bluetooth access. Grant it to your terminal app (Terminal, iTerm, etc.) under System Settings → Privacy & Security → Bluetooth.

Commands

ble scan

ble scan                          # everything nearby, 10 s
ble scan -s 180D --timeout 0      # heart-rate devices, until Ctrl-C
ble scan --allow-duplicates       # live RSSI updates (+ / ~ / - markers)
ble scan --min-rssi -70           # only strong signals
ble scan --json                   # JSON lines, for scripting

On a terminal, ble scan shows a live table sorted by signal strength (closest first), updating in place as advertisements arrive — the sort key is lightly smoothed so the order tracks sustained changes instead of jittering. When piped, with --stream, or with --json, it prints one append-only line per sighting instead. Columns: name, RSSI colored by signal strength (green/yellow/red), the peripheral UUID (what you pass to connect/pair, dimmed), advertised services (standard ones labeled, e.g. 180F/Battery), and manufacturer data. Colors turn off automatically when stdout is piped, and respect NO_COLOR.

ble connect

ble connect 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
ble connect "Kyle's Sensor"       # name substring — resolves by scanning
ble connect mydevice -s 180D --reconnect

Resolves the peripheral (system cache first, then scanning), connects, prints the RSSI, and holds the link open — a BLE connection only lives as long as the process holding it. Lifecycle events stream to the console; Ctrl-C disconnects cleanly, and --reconnect re-establishes the link after unexpected drops.

ble pair

ble pair mydevice -s  -c 
ble pair mydevice -s  -c  --write 0x01

CoreBluetooth has no explicit pairing API. Pairing is triggered by accessing a char

项目描述

ble — a macOS command-line tool for Bluetooth LE: scan, connect, pair, read, write, inspect, and L2CAP, built on BLESwift

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Blaizzy
精选
Blaizzy GitHub avatar

nativ

Nativ is a native macOS app that lets you run AI models locally on Apple silicon, offering chat, model management, performance analytics, and an OpenAI/Anthropic-compatible API server.

AI 与机器学习AI 视觉与语音
985
uzairansaruzi
精选
uzairansaruzi GitHub avatar

hermex

Hermex is a native SwiftUI iPhone app that lets you control a self-hosted Hermes AI agent directly from your phone, with no subscriptions, tracking, or third-party relay.

AI 与机器学习大语言模型
941
simonw
精选
simonw GitHub avatar

speech-analyzer-cli

A macOS command-line tool that uses Apple's on-device speech APIs to transcribe prerecorded audio into plain text, JSON, JSONL, SRT, or WebVTT.

开发者工具CLI 与终端
20