In order to read the raw RSSI values, we use a utility called Hcidump, which monitors the Bluetooth HCI data. Using hcidump commands, we can read the raw RSSI values when an inquiry response message is received. To obtain RSSI values for every response packet we first set the inquiry mode to Inquiry With RSSI.In order to read raw RSSI values we run the hcidump tool and then use the appropriate HCI functions to start periodic inquiry.
I don't know how to use hcidump to obatain only RSSI raw data or maybe how to start a periodic inquiry. I see all the opcions but I am not able.
I make hcidump --raw to obtain raw data, and try to parse this data to obtain the rssi, but I dont know wich hex is the rssi info.
This is what I obtain
04 2F FF 01 AC A2 65 92 88 EC 01 00 0C 02 5A 2D 1F D2 08 09
4E 65 78 75 73 20 36 17 03 05 11 0A 11 0C 11 0E 11 12 11 15
11 16 11 1F 11 2F 11 00 12 32 11 01 05 01 07 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Now I need to know which is the RSSI value.
We can figure this out by inspecting the source code behind the
hcidump
tool. It is a part of BlueZ, the official Linux Bluetooth stack. You can download the BlueZ source code here, to follow along. If you open up the source code and step intolib/
folder, you can findhci.h
, which has the struct definitons for BlueZ's HCI functions. Otherwise, you can look in your Linux system's header files. The path should be something like:/usr/include/bluetooth/hci.h
. In this header file, you will find all the struct definitions for BlueZ's HCI functionality. Specifically, you can find the struct defintion forinquiry_info_with_rssi
. The header file is a few thousand lines long so you would be better served searching the header file instead of trying to look through it. From looking at this struct and the#define
below, you can see the struct size is 14 bytes. The rssi value is the last member of the struct and only 1 byte, so it should be the 14th byte you count.An interesting note is that
__attribute__ ((packed))
is a compiler preprocessor directing it not to pad the structure, so the size of 14 bytes is guranteed.you can try using
sudo hcidump [-a]
this will get you the name and RSSI value of all the nearby bluetooth devices.you can check out what you can do with hcidump here.