Bash - Bluetooth BLE connectivity using hcitools help (How to return rssi of unpaired device)

Hi,

I am trying to detect the rssi (signal strength) of a BLE device (primarily a Tile). A Tile is a BLE tag that you can attache to your keys etc so you don’t loose them. I am wanting to use it for a project at home as a proximity tag which I will eventually use with a Raspberry Pi 3b.

Anyway: I have managed to get the following info using thee bash bluetooth commands in terminal:

hcitool lescan

returns all ble bluetooth devices in range.

LE Scan...
E1:EF:0E:6D:37:C4 Tile
63:BB:D5:63:F8:10 (unknown)

The I run:

btmgmt find

Which gives the following results (only showing for MAC tile in this example): 

Discovery started
hci0 type 7 discovering on
hci0 dev_found: E1:EF:0E:6D:37:C4 type LE Random rssi -19 flags 0x0004AD flags 0x00

Take note of the -19 in the returned results above.

The MAC address is that of a Tile BLE device.
The -19 is the rssi signal. If I move the bluetooth Tile tag away from the Raspberry Pi it changes in value.

Distance tests - approximates

-19 =  close (5cm)

-69 = across the room (1.5m)

-74 = in another room (8m)

-87 = outside (10m)

You get the idea. Note that the Tile is not paired with my Raspberry Pi, but the Pi can detect it when using the btmgmt find command, which returns its signal strength in the above formatted output. It does also include data for all other Bluetooth devices in range as well but I have not shown that in my example.

Question is: Is there another method I can use to get the rssi without pairing. This output is not really user friendly and my bash or python scripting is very average to say the least.

The plan is that my dog will wear the BLE tag which will open a dog door when he is within an rssi range that is suitable possibly -28 (about 70cm) give or take.

Platform: raspberry Pi 3b

Linux (Raspberry version)

Bash

Python

For reference this is what I am talking about with the Tile device:

https://www.thetileapp.com/

Appreciate any help.

You should get what is needed by using 

  1. grep on the MAC address of the device you are searching

  2. use awk to extract the rssi value from the grep output

  3. Use the extracted value to perform a control action