android - 基于 RSSI 估计信标接近/距离 - 蓝牙 LE

标签 android bluetooth bluetooth-lowenergy android-bluetooth rssi

我有一个简单的 iOS 应用程序,它使用“立即”、“接近”等表达方式显示它检测到的蓝牙 LE 信标的接近度,我需要在 Android 上编写类似的东西。

我已按照 Android developer 上的教程进行操作我可以列出检测到的设备,现在想估计距离/接近度——这就是问题所在。根据this SO thread这只是一些数学计算。但是,他们要求我提供 txPower 值。

根据this tutorial by Dave Smith (并与此 Bluetooth SIG statement 进行交叉引用),信标设备应将其广播为 0x0A 类型的“AD 结构”。所以我要做的是解析 AD 结构并寻找与类型匹配的有效负载。

问题:我有 4 个信标 - 2 个估计和 2 个应用。 estimotes 根本不广播 txPower,而 appflares 将其广播为 0。

这里有什么我遗漏的吗? iOS 应用程序似乎可以毫无问题地处理这一切,但使用 iOS SDK 它会在幕后完成,所以我不确定如何产生完全相同或相似的行为。有没有其他方法可以解决我的问题?

如果您想查看我用来解析 AD 结构的代码,它取自上述 Dave Smith 的 github,可以在 here 上找到。 .我对该类所做的唯一更改是添加以下方法:

public byte[] getData() {

    return mData;
}

这就是我处理来自扫描的回调的方式:

// Prepare the callback for BLE device scan
this.leScanCallback = new BluetoothAdapter.LeScanCallback() {

    @Override
    public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) {

        if (!deviceList.contains(device)) {

            MyService.this.deviceList.add(device);
            Log.e("Test", "Device: " + device.getName());

            List<AdRecord> adRecords = AdRecord.parseScanRecord(scanRecord);

            for (AdRecord adRecord : adRecords) {

                if (adRecord.getType() == AdRecord.TYPE_TRANSMITPOWER) {

                    Log.e("Test", "size of payload: " + adRecord.getData().length);
                    Log.e("Test", "payload: " + Byte.toString(adRecord.getData()[0]));
                }
            }
        }
    }
};

而我在控制台中看到的是:

04-01 11:33:35.864: E/Test(15061): Device: estimote
04-01 11:33:36.304: E/Test(15061): Device: estimote
04-01 11:33:36.475: E/Test(15061): Device: n86
04-01 11:33:36.475: E/Test(15061): size of payload: 1
04-01 11:33:36.475: E/Test(15061): payload: 0
04-01 11:33:36.525: E/Test(15061): Device: f79
04-01 11:33:36.525: E/Test(15061): size of payload: 1
04-01 11:33:36.525: E/Test(15061): payload: 0

最佳答案

@davidgyoung 提到的 txPower 由公式给出:

RSSI = -10 n log d + A

在哪里

  • d = 距离
  • A = txPower
  • n = 信号传播常数
  • RSSI = dBm

在自由空间 n = 2,但它会根据局部几何形状而有所不同——例如,一堵墙会将 RSSI 减少 ~3dBm 并且会相应地影响 n

如果您想要尽可能高的准确度,可能值得为您的特定系统通过实验确定这些值。

引用:见论文Evaluation of the Reliability of RSSI for Indoor Localization由钱东和 Waltenegus Dargie 对推导和校准进行了更详细的解释。

关于android - 基于 RSSI 估计信标接近/距离 - 蓝牙 LE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22784516/

相关文章:

java - Android ICS 和 Jelly Bean 有什么区别?

java - 在if条件中使用分号的目的是什么?

android - 动画对象离开屏幕并保持在那里

android - 使用蓝牙低功耗(BLE)时如何获得广告停止事件?

android - API 21 中弃用了 startLeScan

android - Google Play 更新版本 apk 上传失败

安卓 : Bluetooth device return unknown character like "?"

ios - 在IOS app中获取并显示外设蓝牙RSSI信号强度

windows-7 - Wiimote 的 Windows HID 设备驱动程序安装。我们可以改进它吗?

bluetooth - 如何解码 FreeTec PX-1737-919 蓝牙 4.0 温度传感器的蓝牙 LE 封装/框架/信标?