如何设置BLE扫描间隔和Windows仅在Android中选择模式? [英] How to set BLE scan interval and windows no just choose mode in android?

查看:141
本文介绍了如何设置BLE扫描间隔和Windows仅在Android中选择模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android的新鲜人.我想在我的android设备中设置BLE扫描间隔和窗口,以便进行有关邻居发现的实验.我在Google上搜索答案,并且知道

I am a fresh man in android. I want to set BLE scan interval and windows in my android device in order to do a experiment about neighbour discovery. I search the answer on google and know that there are some definition in android's source code about BLE scan interval and windows as below

/**
 * Scan params corresponding to regular scan setting
 */
private static final int SCAN_MODE_LOW_POWER_WINDOW_MS = 500;
private static final int SCAN_MODE_LOW_POWER_INTERVAL_MS = 5000;
private static final int SCAN_MODE_BALANCED_WINDOW_MS = 2000;
private static final int SCAN_MODE_BALANCED_INTERVAL_MS = 5000;
private static final int SCAN_MODE_LOW_LATENCY_WINDOW_MS = 5000;
private static final int SCAN_MODE_LOW_LATENCY_INTERVAL_MS = 5000;

/**
 * Scan params corresponding to batch scan setting
 */
private static final int SCAN_MODE_BATCH_LOW_POWER_WINDOW_MS = 1500;
private static final int SCAN_MODE_BATCH_LOW_POWER_INTERVAL_MS = 150000;
private static final int SCAN_MODE_BATCH_BALANCED_WINDOW_MS = 1500;
private static final int SCAN_MODE_BATCH_BALANCED_INTERVAL_MS = 15000;
private static final int SCAN_MODE_BATCH_LOW_LATENCY_WINDOW_MS = 1500;
private static final int SCAN_MODE_BATCH_LOW_LATENCY_INTERVAL_MS = 5000;

如果我想更改值,是否意味着我应该编译android系统?有更好的方法吗?

If I want to change the values, does it mean that I should compile the android system? Is there a better way?

推荐答案

您可以自由控制扫描窗口的等效对象,并通过启动和停止扫描将自己置于较高级别的代码中.这正是开源 Android Beacon库所具有的等效可配置参数:

You are free to control the equivalent if scan window and interval yourself in higher-level code by starting and stopping scanning. This is exactly what the open source Android Beacon Library does with its equivalent configurable parameters:

 beaconManager.setForegroundScanPeriod(...);
 beaconManager.setForegroundBetweenScanPeriod(...);

这篇关于如何设置BLE扫描间隔和Windows仅在Android中选择模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆