android find distance of any ble device
<p>I have to calculate the distance of any ble device (not just beacon). I am using the BluetoothLeGatt sample app provided on the devloper android site this is the link <a href="http://developer.android.com/downloads/samples/BluetoothLeGatt.zip" rel="nofollow noreferrer">http://developer.android.com/downloads/samples/BluetoothLeGatt.zip</a>. I am printing the log in this method </p>

<pre><code>// Device scan callback.
private BluetoothAdapter.LeScanCallback mLeScanCallback =
        new BluetoothAdapter.LeScanCallback() {

    @Override
    public void onLeScan(final BluetoothDevice device, int rssi, final byte[] scanRecord) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                mLeDeviceListAdapter.addDevice(device);
                mLeDeviceListAdapter.notifyDataSetChanged();

                Log.e("scanrecord", Arrays.toString(scanRecord));
            }
        });
    }
};
</code></pre>

<p>this is my log </p>

<pre><code>05-05 13:58:35.811 8034-8051/com.example.android.bluetoothlegatt D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=08:7C:BE:49:7D:9E, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000fee8-0000-1000-8000-00805f9b34fb, 0000fff0-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=Safety15HA006634], mRssi=-80, mTimestampNanos=2601215802991397}
05-05 13:58:35.816 8034-8034/com.example.android.bluetoothlegatt E/scanrecord: [2, 1, 6, 17, 8, 83, 97, 102, 101, 116, 121, 49, 53, 72, 65, 48, 48, 54, 54, 51, 52, 5, 3, -24, -2, -16, -1, 5, 18, 6, 0, -128, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]. 
</code></pre>

<p>On searching I found the formula to calculate the distance on this link <a href="https://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing/20434019#20434019">Understanding ibeacon distancing</a> . My problem is how to get the transmission power from the <code>scanRecord</code>. Also what is the <code>mTxPowerLevel</code> and how can I get it as this is logged from the android ble classes.</p>