android - 我如何在 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 值,请帮忙;
解决方案
推荐阅读
- r - R SQLDF 两个时间戳之间的天数差异?
- python - 如何在 django 中从父模型访问子模型数据
- android-studio - 我如何将颤振项目迁移到 androidx:任务“:app:preDebugBuild”的执行失败。> Android 依赖 'androidx.versionedparcelable
- javascript - 是否可以将此代码缩短为一行?
- java - 将选项卡作为注释参数传递:“属性值必须是常量”
- python - 通过 Python 在 q-lang 查询中转义字符
- mysql - 如何处理时区差异
- python-requests - 应要求使用证书时如何解决以下错误?
- java - 如何在java中使用匿名类中的方法
- android - Firebase 存储:UploadTask:找不到要上传的文件