A macOS command-line tool for scanning, connecting, pairing, and communicating with Bluetooth Low Energy peripherals, built on Swift and BLESwift.

Stars

113

7-day growth

No data

Forks

0

Open issues

0

License

Apache-2.0

Last updated

2026-07-19

Why it is worth attention

It provides a complete, scriptable BLE client with live sorted scanning, full GATT tree inspection, typed payload encoding from YAML/JSON, and L2CAP channel support, all with clean stdout/stderr separation.

Who it is for

  • macOS developers who need to debug or automate BLE interactions
  • BLE hardware engineers testing prototypes or verifying specifications
  • IoT hobbyists configuring or monitoring smart devices from a terminal
  • System administrators managing BLE peripherals in macOS environments

Use cases

  • Quickly scan for nearby BLE devices and identify them by signal strength
  • Read and write characteristics and descriptors, including streaming notifications
  • Inspect the full GATT service/characteristic/descriptor tree of a peripheral
  • Automate BLE device pairing and data exchange via shell scripts or pipes

Strengths

  • Live scanning table sorted by smoothed RSSI with color coding, updating in real time
  • Supports multiple operations: scan, connect, pair, inspect, read, write, L2CAP channels
  • Payload files in YAML/JSON with typed fields (u8–u64, i8–i64, hex, string, pad) and endianness control
  • Output conventions: progress/stderr, data/stdout, enabling piping into jq or redirection without pollution

Considerations

  • macOS only; no Linux or Windows support mentioned
  • Pairing requires triggering CoreBluetooth's system dialog (not fully programmatic)
  • Requires granting Bluetooth permission to the terminal app manually

README quick start

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

Description

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

Related repositories

Similar projects matched by category, topics, and programming language.

Blaizzy
Featured
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 & Machine LearningDesktop Apps
853
uzairansaruzi
Featured
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 & Machine LearningMobile
839
simonw
Featured
simonw GitHub avatar

speech-analyzer-cli

A macOS CLI tool that transcribes prerecorded audio using Apple's on-device speech APIs and outputs plain text, JSON, JSONL, SRT, or WebVTT.

Developer Tools
16