android - 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;
解决方案
推荐阅读
- mysql - 为什么列中有值为 1 时仍选择值为 NULL 的行
- git - 使用 shell 脚本更改 *n* 次提交的 git 历史记录(提交日期)
- ruby-on-rails - Rails - 基于与 PHP 中的 uniqueid() 相同的微时间创建唯一 ID 的最佳方法是什么?
- vba - 子表单文本字段显示#Name?而不是来自 ADO 记录集的数据
- android - Butterknife+kotlin:请求增量注释处理,但由于以下处理器不是增量的,支持被禁用
- android - AlertDialog - 显示自定义类的软键盘不起作用
- java - AspectJ 方面是单例吗?
- javascript - 将数组映射到组件在反应中失败
- mongodb - 如果不在数据库中,如何插入许多
- dataframe - 合并 pyspark 数据框中的列