0

我制作了一个用于检测 iBeacons 的 Android 应用程序。它基于使用 Radius 网络中的 Ibeacon 库的“查找猴子”示例。

该应用程序一直运行良好,直到今天早上它开始只识别我的 1 个信标(我办公室里可能有 6 个)。

它循环的代码对于大多数使用过 iBeacons 的人来说都很熟悉:

void RangingBeaconsInRegion(object sender, RangeEventArgs e)
        {
            if (e.Beacons.Count > 0)
            {
                var beacon = e.Beacons.FirstOrDefault();

                var minor = beacon.Minor;

                Console.WriteLine ("Minor IS .... " + minor);


                switch((ProximityType)beacon.Proximity)
                {
                case ProximityType.Immediate:
                    Console.WriteLine ("Beacon FIRED with minor " + minor);
                    showCouponMessage();
                    break;
                case ProximityType.Near:
                    UpdateDisplay ("You're getting warmer (near)", Color.LawnGreen);

                    break;
                case ProximityType.Far:
                    UpdateDisplay("No Beacons here (far)!!", Color.Blue);
                    break;
                case ProximityType.Unknown:
                    UpdateDisplay("I'm not sure how close you are to the Beacon (unknown)", Color.Red);
                    break;
                }

当它停止工作时,我添加了 Console.Writeline 语句以尝试了解它正在拾取哪个信标以及为什么它没有看到任何其他信标。查看控制台窗口,实际上它似乎确实“看到”了其他信标的主要和次要 ID,但选择仅识别具有“2”次要的信标。

这是输出窗口的一部分:

[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 742 32001 accuracy: 1.440510248595126 proximity: 2
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 14640 7849 accuracy: 5.0375909818338265 proximity: 3
[Callback] attempting callback via intent: ComponentInfo{com.findthemonkey_android/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
[BluetoothAdapter] stopLeScan()
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=6
Thread started:  #15
Minor IS .... 2
Thread finished:  #15
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 14640 7849 accuracy: 2.629927091577368 proximity: 2
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 742 34001 accuracy: 0.6951160689284792 proximity: 2
[Callback] attempting callback via intent: ComponentInfo{com.findthemonkey_android/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
[BluetoothAdapter] stopLeScan()
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=6
Thread started:  #16
Minor IS .... 2
Thread finished:  #16
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 14640 7849 accuracy: 2.629927091577368 proximity: 2
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[Callback] attempting callback via intent: ComponentInfo{com.findthemonkey_android/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
[BluetoothAdapter] stopLeScan()
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=6
Thread started:  #17
Minor IS .... 2
Thread finished:  #17
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[Callback] attempting callback via intent: ComponentInfo{com.findthemonkey_android/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
[BluetoothAdapter] stopLeScan()
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=6
Thread started:  #18
Thread finished:  #18
Minor IS .... 2
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 14640 7849 accuracy: 5.447335444796175 proximity: 3
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :00000000-0000-0000-0000-000000000000 0 0 accuracy: -1.0 proximity: 0
[IBeaconService] iBeacon detected multiple times in scan cycle :f7826da6-4fa2-4e98-8024-bc5b71e0893e 742 32001 accuracy: 1.440510248595126 proximity: 2
[Callback] attempting callback via intent: ComponentInfo{com.findthemonkey_android/com.radiusnetworks.ibeacon.IBeaconIntentProcessor}
[BluetoothAdapter] stopLeScan()
[BluetoothAdapter] startLeScan(): null
[BluetoothAdapter] onClientRegistered() - status=0 clientIf=6
Thread started:  #19
Minor IS .... 2

如您所见,它确实“看到”了其他 Minor 的信标,但似乎只想识别我拥有的 Minor 为“2”的 1 个信标,并不断将其输出到控制台窗口。

有什么想法吗?这与Android蓝牙堆栈错误有关吗?我在 Nexus 4 上运行 Android 4.4.4,我认为该错误已在 4.4 中解决。

4

0 回答 0