簡體   English   中英

iBeacon同時掃描(Android應用程序)

[英]iBeacon scanning simultaneously (Android apps)

我正在開發幾個使用掃描設備ibeacons的應用程序。 每個應用程序都有不同的掃描頻率。 我的問題是同時掃描多個應用程序是否有問題。 堆疊藍牙設備的訪問協議是什么?

另外,我有一個在后台運行的服務,該服務執行定期掃描,並且在我測試過的所有設備中,該應用程序均正常運行,但其中一個新的Moto X除外。該應用程序被阻止並且不執行掃描。 有任何想法嗎??

提前非常感謝您!!

Android信標庫允許多個應用程序同時掃描信標,而不會互相干擾。 之所以可以這樣做是因為Android BLE掃描API會跟蹤正在執行掃描的應用程序。 如果應用程序A和B都開始掃描,並且應用程序B停止掃描,則操作系統將繼續掃描並將結果發送到應用程序A。

為了證明這一點,我在運行Android 4.4.3的Moto G上安裝了BeaconReferenceApplication的兩個不同副本。 對應用程序包名稱進行了稍微修改,以允許同時安裝,並且默認掃描速率在應用程序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");

當我同時在后台運行這兩個應用程序時,即使停止運行前應用程序B僅連續5秒鍾成功檢測到信標,應用程序A仍連續10秒鍾成功檢測到了信標。 應用程序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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM