Scan for nearby BLE (Bluetooth Low Energy) devices and explore their GATT profiles from the command line.
- Linux with BlueZ 5.x (
bluetoothdrunning) - A Bluetooth adapter (
hciconfigshows it up and running) - Rust toolchain
make
The first build downloads dependencies and compiles them, which may take several minutes on slower hardware such as a Raspberry Pi 4. Subsequent builds are much faster.
sudo make install
Installs the binary to /usr/local/bin/blescan and the man page to /usr/local/share/man/man1/blescan.1.gz.
To build a .deb package (requires dpkg-deb, standard on Debian/Ubuntu/Raspberry Pi OS):
make deb
This produces blescan_1.0.0_arm64.deb (architecture is detected automatically). Install it with:
sudo dpkg -i blescan_1.0.0_arm64.deb
Scan for nearby BLE devices:
$ blescan
Scanning for BLE devices... (5s)
Found 2 device(s):
AA:BB:CC:DD:EE:FF - My Sensor (-72 dBm)
11:22:33:44:55:66 - Unknown (-85 dBm)
To explore a device's GATT profile:
blescan <address>
Enumerate a device's GATT profile:
$ blescan AA:BB:CC:DD:EE:FF
Connecting to AA:BB:CC:DD:EE:FF...
Waiting for GATT services...
GATT profile for AA:BB:CC:DD:EE:FF:
Service: 0x1800 - Generic Access
Characteristic: 0x2A00 - Device Name [read]
Value: "My Sensor"
Characteristic: 0x2A01 - Appearance [read]
Value: 00 00
Service: 0x180A - Device Information
Characteristic: 0x2A29 - Manufacturer Name String [read]
Value: "ACME Corp"
Characteristic: 0x2A26 - Firmware Revision String [read]
Value: "1.2.3"
Service: 0x180F - Battery Service
Characteristic: 0x2A19 - Battery Level [read, notify]
Value: 64
By default blescan needs root to access Bluetooth. To run without sudo, add yourself to the bluetooth group and re-login:
sudo adduser $USER bluetooth
- Raspberry Pi 4 (Raspberry Pi OS, arm64)
- BlueZ 5.82