Linux Bluetooth Low Energy Device Scanner
While working with those horrible battery management system BLE interfaces, I wanted to probe my various BLE devices and see what services and characteristics they have. I suspect there is a way to do it with the standard-ish bluetooth tools, but they also looked overcomplicated and apparently they also hate humans.
So I did what any civilized program would do, I "wrote" my own in a programming language I do not know. The AIs assured me that Rust's zbus interface was the friendliest API to work with. I've never written Rust, or used D-bus, but why let that stop me.
So I sat down with Claude and told him my wishes for a bluetooth low energy scanning program, and after a false start and a bunch of refinement, and then some locating of catastrophic bugs and maybe getting rid of them I now have the BLE scanner of my dreams.
I still don't know Rust, I kind of meant to learn it, but I haven't really read any of the code. I made it move some things around and structure things a little different, but Claude didn't need me for my coding skills.
Anyway, you too can have blescan. There is a Raspberry Pi Debian package in the release prebuilt, or you can build it yourself.
With no arguments it lists the devices it sees advertising. With a MAC as an argument it maps out the services and characteristics of the device.
$ 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)
$ 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
There's a man page if you want to know more.