android - 使用 Android BLE(蓝牙低功耗)计算距离
问题描述
我尝试使用 BLE 获取两个移动设备之间的距离,我知道这是一项常见任务,我们可以使用RSSI
和txPower
找出距离。
txPower
但是我在 android BLE中获得价值时遇到了问题。它总是返回 127 (TX_POWER_NOT_PRESENT),虽然我已经添加了AdvertiseData
val data = AdvertiseData.Builder().setIncludeDeviceName(false).setIncludeTxPowerLevel(true)
.addServiceUuid(pUuid).build()
下面是用于获取的代码块txPower
private fun processScanResult(scanResult: ScanResult?) {
var txPower: Int? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
txPower = scanResult?.txPower
if (txPower == 127) {
txPower = null
}
}
}
有人对我的问题有建议吗?任何回应将不胜感激。
解决方案
推荐阅读
- reactjs - 将 Webpack 配置为构建文件所需的文件夹结构
- python - 如何从 ZipFile 流式传输?如何“即时”压缩?
- php - 如何解决 wordpress 中回复评论的问题?
- angular - “[]”类型中缺少 Angular7“长度”
- javascript - 考虑一个包含问号、数字、字母的字符串
- python - Networkx:如何更改相同边缘的颜色和大小?
- python - 给定一系列数字,构造所有单个值、对、三元组等
- javascript - 如何在Javascript中绘制具有相同渐变的每一行?
- maven - maven-jar-plugin 不包含 .gitignore 文件
- colors - 如何使用 scilab 和 xfpoly 将零件涂成红色