首页 > 解决方案 > Android AltBeacon 库中 BLE 背景扫描的间隔限制?

问题描述

我一直在使用 Android AltBeacon 库。我注意到一个奇怪的行为,设备随机停止扫描,间隔时间为 5 秒或 10 秒。我有两个设备 A 和 B 彼此相邻,这些设备都使用 AltBeacon 库以 iBeacon 格式进行广告和扫描。

/**
 * The default duration in milliseconds of the Bluetooth scan cycle
 */
public static final long DEFAULT_FOREGROUND_SCAN_PERIOD = 1100;
/**
 * The default duration in milliseconds spent not scanning between each Bluetooth scan cycle
 */
public static final long DEFAULT_FOREGROUND_BETWEEN_SCAN_PERIOD = 0;
/**
 * The default duration in milliseconds of the Bluetooth scan cycle when no ranging/monitoring clients are in the foreground
 */
public static final long DEFAULT_BACKGROUND_SCAN_PERIOD = 10000;
/**
 * The default duration in milliseconds spent not scanning between each Bluetooth scan cycle when no ranging/monitoring clients are in the foreground
 */
public static final long DEFAULT_BACKGROUND_BETWEEN_SCAN_PERIOD = 5 * 60 * 1000;

这些是我在创建扫描仪时使用的参数。

因此,我很好奇为什么它会在不同的时间间隔内停止检测。我认为这与广告端无关,因为我让 LocateBeacon 应用程序在第三台设备上运行只是为了检查广告是否在其他两个设备中停止。

所以这个问题是由于 Android 操作系统的限制或与 AltBeacon 库相关的原因。我究竟应该如何解决这个问题?由于这个问题,我得到了不必要didExitRegion(..)的回调,这会弄乱用例。

广告设备:OPPO安卓版本:v8.1.0 PPS:2.2

扫描设备:一加安卓版本:v10

编辑

以下是我为我的 tx 功率和 tx 模式设置的值:

private int mAdvertiseMode = AdvertiseSettings.ADVERTISE_MODE_BALANCED;
private int mAdvertiseTxPowerLevel = AdvertiseSettings.ADVERTISE_TX_POWER_LOW;

标签: androidbluetoothbluetooth-lowenergyaltbeaconscanning

解决方案


推荐阅读