2014-10-07 107 views
0

我正在开发几个利用扫描设备ibeacons的应用程序。每个应用程序都有不同的扫描频率。我的问题是,是否可以有一个问题是多个应用程序同时扫描。堆叠蓝牙设备的访问协议是什么?iBeacon同时扫描(Android应用程序)

此外,我有一个服务运行在后台执行定期扫描,并且在我测试过的所有设备中,应用程序都能正常工作,除了新的Moto X之外,应用程序被阻止并且不执行扫描。有任何想法吗??

非常感谢你提前!

回答

4

Android Beacon Library允许多个应用程序同时扫描信标而不会相互干扰。这是可行的,因为Android BLE扫描API会跟踪哪些应用正在进行扫描。如果应用程序A和B都开始扫描,并且应用程序B停止其扫描,则操作系统继续扫描并将结果发送到应用程序A.

为了证明这一点,我在Moto G上安装了两个不同的BeaconReferenceApplication副本运行Android 4.4.3。应用程序包名称稍作修改以允许同时安装,并且默认扫描速率在应用程序A上设置为开/关5秒,在应用程序B上设置为10秒。应用程序自定义如下所示:

应用程序A

long scanPeriod = 10000l; 
long betweenScanPeriod = 10000l; 
mBeaconManager.setBackgroundBetweenScanPeriod(scanPeriod); 
mBeaconManager.setBackgroundScanPeriod(betweenScanPeriod); 
Log.d(TAG, "Looking for beacon with minor 12345, with a scan on/off cycle of "+scanPeriod+"/"+betweenScanPeriod+" milliseconds"); 

应用B

long scanPeriod = 5000l; 
long betweenScanPeriod = 5000l; 
mBeaconManager.setBackgroundBetweenScanPeriod(scanPeriod); 
mBeaconManager.setBackgroundScanPeriod(betweenScanPeriod); 
Log.d(TAG, "Looking for beacon with minor 12345, with a scan on/off cycle of "+scanPeriod+"/"+betweenScanPeriod+" milliseconds"); 

当我同时运行在后台这两个应用程序,应用程序A成功地检测到信标直10秒,即使应用程序B只成功在停止前5秒钟检测到信标。应用程序B停止扫描不会影响应用程序A.您可以在下面的日志输出中查看结果。 (注意,应用程序A具有进程ID 15841,而应用程序B具有进程ID 15910)。虽然这些测试是在Moto G上进行的,但我怀疑它们在Moto X上会有任何不同的结果,因为Moto X只是具有更高端硬件的相同设备的一个版本。因此,我怀疑您看到的问题可能是特定于应用程序的问题。另外需要注意的是,Moto X和Moto G都存在蓝牙和WiFi无法同时正常工作的硬件问题。如果您在扫描信标的同时使用WiFi,如果阻止检测,请不要感到惊讶。

10-07 13:29:05.949 D/BeaconReferenceApplication(15841): Looking for beacon with minor 12345, with a scan on/off cycle of 10000/10000 milliseconds 
10-07 13:29:09.071 D/BeaconReferenceApplication(15910): Looking for beacon with minor 12345, with a scan on/off cycle of 5000/5000 milliseconds 
... 
10-07 13:29:15.582 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:16.119 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:16.738 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:16.942 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.072 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.250 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.372 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.375 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.660 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:17.660 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.075 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.080 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.289 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.297 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.501 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.513 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.820 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:18.822 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.035 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.040 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.438 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.441 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.540 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.542 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.643 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:19.644 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:20.699 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:20.910 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.125 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.239 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.344 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.462 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.751 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:21.969 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:22.170 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:23.016 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:23.129 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:23.340 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:23.444 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:23.654 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:24.180 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:24.818 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:25.012 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:25.113 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:25.245 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:25.424 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:25.527 D/BeaconService(15841): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
10-07 13:29:26.353 D/BeaconService(15910): beacon detected :id1: e2c56db5-dffb-48d2-b060-d0f5a71096e0 id2: 1 id3: 12345 
+1

非常棒的回复!谢谢!! :) – 2014-10-08 07:12:46

相关问题