首页 > 解决方案 > 我如何在 android 设备上获得 TxPower 蓝牙 LE

问题描述

我真的被这个问题困住了,我想做的是使用这个函数计算两个设备之间的距离:

protected static double calculateAccuracy(int txPower, double rssi) {
        if (rssi == 0) {
            return -1.0; // if we cannot determine accuracy, return -1.
        }

        double ratio = rssi*1.0/txPower;
        if (ratio < 1.0) {
            return Math.pow(ratio,10);
        }
        else {
            double accuracy =  (0.89976)*Math.pow(ratio,7.7095) + 0.111;
            return accuracy;
        }
    }

但我不知道如何获得设备的 TxPower 值,请帮忙;

标签: androidbluetoothbluetooth-lowenergy

解决方案


推荐阅读