Linux Bluetooth l2ping with signal strength (no connection?)

For any Linux BlueZ / BT experts here:

I’m looking for a way to ping known BT devices (known BDADDR), and if they are within range, I would like to know the approximate signal strength.

I know that I can start l2ping first and then establish a connection with the device and finally check the quality of rssi or links if the connection works without pairing in the first place.

However, what I'm looking for is a way to get signal strength without first connecting to the device. It would be perfect to measure the signal level from the l2ping response packet, but I do not know if this information is available at all and is transmitted along the stack.

+5
source share
3 answers

You can get RSSI while scanning a request without connecting to devices. Here is an example using pybluez. You can also do the same directly from C using Bluez on Linux.

inquiry-with-rssi.py

+5
source

I use this code with my iPhone 7 and Raspberry Pi and it works great.

#!/bin/bash

sudo hcitool cc AA:BB:CC:DD:EE:FF 2> /dev/null

while true
do
    bt=$(hcitool rssi AA:BB:CC:DD:EE:FF 2> /dev/null)
    if [ "$bt" == "" ]; then
        sudo hcitool cc AA:BB:CC:DD:EE:FF  2> /dev/null
        bt=$(hcitool rssi AA:BB:CC:DD:EE:FF 2> /dev/null)
    fi

    echo "$bt"
done
+2
source

, - .

RSSI . , , . RSSI. RSSI BlueZ hcitool rssi <MAC:ADDRESS>. l2ping hcitool rssi . : [https://github.com/edoardesd/myBluez] : 44 bytes from XX:XX:XX:XX:XX:XX id 8 time 8.23ms with RSSI -9

+1
source

All Articles