简体   繁体   中英

Capture bluetooth beacons from a specific device

I need to capture BLE beacons and inspect their content. Having failed to convince wireshark to do that, I discovered the plain bluetoothctl from package bluez does it:

[bluetooth]# scan on
Discovery started
[CHG] Controller CC:15:31:5F:73:4A Discovering: yes
[NEW] Device 49:DA:89:B3:9B:19 49-DA-89-B3-9B-19
[NEW] Device 20:C9:D0:47:DB:AA 20-C9-D0-47-DB-AA
[NEW] Device 60:72:21:DF:F9:A4 60-72-21-DF-F9-A4
[NEW] Device 52:CF:9F:A6:85:C9 52-CF-9F-A6-85-C9
[NEW] Device 66:A6:75:A7:2E:69 66-A6-75-A7-2E-69
[NEW] Device 6C:D9:CF:B3:9F:34 6C-D9-CF-B3-9F-34
[NEW] Device 68:B3:E4:9B:27:36 68-B3-E4-9B-27-36
[NEW] Device 7E:F6:07:0E:CC:9F 7E-F6-07-0E-CC-9F
[NEW] Device 56:AA:85:3D:4B:EB 56-AA-85-3D-4B-EB
[NEW] Device 4C:C9:5E:33:42:09 4C-C9-5E-33-42-09
[NEW] Device 7A:FC:C2:18:ED:9C 7A-FC-C2-18-ED-9C
[CHG] Device 4C:C9:5E:33:42:09 Class: 0x000c043c
[CHG] Device 4C:C9:5E:33:42:09 Icon: audio-card

My problem is that my environment is rather noisy thus following the beacons from a single device is difficult(and I would like to monitor in real time). How to filter the output by a UUID as if grep ing?

Bonus question: what is [CNG] ?

When a new device is discovered BlueZ indicates this with [NEW] . When a property of an already discovered device CHanGes then it uses [CHG] .

BlueZ allows discovery report to be filtered with SetDiscoveryFilter. More information at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt

In bluetoothctl this is accessed from commands under menu scan .

If you want to do this with code I would generally recommend using the API's provided by BlueZ and documented at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

I have posted a Python example before at: bluetootctl scan on parsing

The BlueZ D-Bus APIs can be accessed from any programming language that has D-Bus bindings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM