Distance to a Bluetooth device can be measured using RSSI value. The following script will help you locate nearby unique BLE devices within a selected range.
This script scans for nearby unique Bluetooth devices within the given range using a well-known RSSI to distance formula.