5

How do you retrieve the advertising payload for a Bluetooth LE emitter in Linux?

Specifically, I've configured Arduinos and Raspberry Pis using hcitool to act as iBeacons.

What I'm looking for is a command to print out what the current advertising payload is for the device.

Matthias Braun
  • 32,039
  • 22
  • 142
  • 171
Samrung
  • 53
  • 1
  • 1
  • 3
  • I tried looking in the BLE spec and couldn't find anything. Multiple programs can send HCI commands to a bluetooth dongle at once, so it'd be nice to be able to read the current settings from a dongle. – Tim Tisdall Mar 24 '14 at 13:10

3 Answers3

5

At Radius Networks, we put together a set of scripts that parse the iBeacon identifiers out of BLE advertisement detected on Linux. You can find a description of this here.

If you simply want to see the raw advertisement bytes, you can start scanning on Linux with:

sudo hcitool lescan --duplicates &

And then see the results with:

sudo hcidump --raw 

More details are in the answer linked above.

Community
  • 1
  • 1
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • David, appreciate the answer, but sorry I wasn't clear. I was looking for a way to get the payload from the device I'm logged into. I know once I've configured a device using hcitool it will print out the payload. What I'm looking for is a similar command to read the current configuration. I imagine it's a hcitool cmd but haven't had any luck finding the right parameters. – Samrung Mar 22 '14 at 19:34
  • Understood. I'm not sure that the bluetooth spec allows reading this out, and BlueZ may not keep a copy. If this is not accessible, you could save it off in a variable (environment or otherwise) whenever you set the advertising parameters. – davidgyoung Mar 22 '14 at 20:59
  • Thanks - I was trying to find a way to confirm the payload data directly in case it was modified by some other means. I think I'll use a version of your script that also includes MAC addresses set up on another device to confirm the payload data. If no one else chimes in, I'll mark this as the correct answer. Odd that the spec has a write command but not an equivalent read? – Samrung Mar 23 '14 at 20:58
0

Since libpcap-1.0+ now supports Bluetooth capture you can use Wireshark/tshark/tcpdump to capture and display Bluetooth packets - both BTLE and other packet types.

To capture the LE packets with Wireshark you will still need to tell the Bluetooth interface to query for LE packets, as mentioned in the previous answer:

sudo hcitool lescan --duplicates &

In addition if you want the adapter to do a periodic query for Bluetooth devices, which are in discoverable mode, you can run (though these queries won't pick up BTLE emissions):

sudo hcitool spinq
Pierz
  • 7,064
  • 52
  • 59
0
sudo hcitool lescan --duplicates &
sudo hcitool spinq

Both commands runs an infinite loop how to run a finite loop and get the data

Nagama Inamdar
  • 2,851
  • 22
  • 39
  • 48