Android 蓝牙 Altbeacon 校准

Android Bluetooth Altbeacon Calibration

伙计们 我正在使用 Altbeacon Android 库来做一些蓝牙应用程序进行演示。它提供了一个 getDistance() 方法,我可以用它来获取我的 phone 和上传了 Altbeacon 协议的外部蓝牙设备之间的距离。但是,由于设备不同,我认为距离可能会因较大的误差而变化(当我在 1 米远时得到 0.05 米,依此类推)。这让我认为,如果我们为 getDistance() 方法做一些校准工作将会很有用。有什么办法吗? (目前我不知道如何修改 getDistance 方法,也许@override 吧?不是很确定) 非常感谢。

我不知道库中有任何校准功能。但是,您可以通过实现自己的 DistanceCalculator.

来更改距离计算

默认距离计算器是ModelSpecificDistanceCalculator,它在BeaconServices onCreate方法中设置(检查this)。因此,只需创建您自己的 DistanceCalculator 版本并在创建 BeaconService 之后设置它就可以做您想要的;

// after beacon service is created
DistanceCalculator customCalculator = ...;
Beacon.setDistanceCalculator(customCalculator);

但是,您现在应该知道该设备也会导致变异;

Each model may have a different Bluetooth chipset and antenna, and therefore may receive a different signal level when in the same position relative to a beacon. In order to address this, the library uses a different formula for calculating distance for different Android device models. Because not all devices have custom formulas built into the library, the library will fall back to the default device calculation for the Nexus 5 if no matching formula is found.

有关距离计算的更多信息,请访问AltBeacon - Distance Calculations页面。此页面还解释了距离计算的工作原理以及您可以如何为增强设备变化库做出贡献。

顺便说一句,您也可以检查 CurveFittedDistanceCalculator,但这需要您提供设备特定系数(在 this page). For more info about this, check its source code 中解释。