AltBeacon / android-beacon-library

Allows Android apps to interact with BLE beacons
Apache License 2.0
2.84k stars 836 forks source link

didEnterRegion never gets called #997

Closed AdamMiltonBarker closed 4 years ago

AdamMiltonBarker commented 4 years ago

Expected behavior

iBeacon and Eddystone-UID should be detected and didEnterRegion should be called

Actual behavior

iBeacon and Eddystone-UID are hardly ever detected and didEnterRegion never called

Steps to reproduce this behavior

        beaconManager = BeaconManager.getInstanceForApplication(this);
        // To detect proprietary beacons, you must add a line like below corresponding to your beacon
        // type.  Do a web search for "setBeaconLayout" to get the proper expression.
        beaconManager.getBeaconParsers().add(new BeaconParser().
                setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
        beaconManager.setDebug(true);
        beaconManager.bind(this);
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: Processing pdu type FF: 02010205ffc40011770e094c4720434d32343630284243290000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 8
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: Ignoring pdu type 09
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02010205ffc40011770e094c4720434d32343630284243290000000000000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: Ignoring pdu type 01
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: Processing pdu type FF: 02010205ffc40011770e094c4720434d32343630284243290000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 8
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: Ignoring pdu type 09
09-01 10:05:09.228 9014-9204/com.laira.hias D/BeaconParser: This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 00 at offset 7.  The bytes I see are: 02010205ffc40011770e094c4720434d32343630284243290000000000000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.268 9014-9198/com.laira.hias D/ScanRecord: parseFromBytes
09-01 10:05:09.268 9014-9198/com.laira.hias D/ScanRecord: first manudata for manu ID
09-01 10:05:09.268 9014-9198/com.laira.hias D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=D4:9D:C0:51:19:67, mScanRecord=ScanRecord [mAdvertiseFlags=-1, mServiceUuids=null, mManufacturerSpecificData={117=[66, 4, 1, -128, 96, -44, -99, -64, 81, 25, 103, -42, -99, -64, 81, 25, 102, 1, 24, 0, 0, 0, 0, 0]}, mServiceData={}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-41, mTimestampNanos=280411448208982}
09-01 10:05:09.268 9014-9014/com.laira.hias D/CycledLeScannerForLollipop: got record
09-01 10:05:09.268 9014-9205/com.laira.hias D/BeaconParser: Processing pdu type FF: 1bff75004204018060d49dc0511967d69dc05119660118000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 27
09-01 10:05:09.268 9014-9205/com.laira.hias D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 1bff75004204018060d49dc0511967d69dc05119660118000000000000000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.268 9014-9205/com.laira.hias D/BeaconParser: Processing pdu type FF: 1bff75004204018060d49dc0511967d69dc05119660118000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 27
09-01 10:05:09.268 9014-9205/com.laira.hias D/BeaconParser: This is not a matching Beacon advertisement. Was expecting aa fe at offset 2 and 00 at offset 4.  The bytes I see are: 1bff75004204018060d49dc0511967d69dc05119660118000000000000000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.328 9014-9033/com.laira.hias D/ScanRecord: parseFromBytes
09-01 10:05:09.328 9014-9033/com.laira.hias D/BluetoothLeScanner: onScanResult() - ScanResult{mDevice=B8:27:EB:EA:F2:07, mScanRecord=ScanRecord [mAdvertiseFlags=6, mServiceUuids=[0000feaa-0000-1000-8000-00805f9b34fb], mManufacturerSpecificData={}, mServiceData={0000feaa-0000-1000-8000-00805f9b34fb=[0, -25, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6]}, mTxPowerLevel=-2147483648, mDeviceName=null], mRssi=-43, mTimestampNanos=280411511227781}
09-01 10:05:09.328 9014-9014/com.laira.hias D/CycledLeScannerForLollipop: got record
09-01 10:05:09.328 9014-9014/com.laira.hias D/CycledLeScannerForLollipop: with service uuid: 0000feaa-0000-1000-8000-00805f9b34fb
09-01 10:05:09.328 9014-9202/com.laira.hias D/BeaconParser: Ignoring pdu type 01
09-01 10:05:09.328 9014-9202/com.laira.hias D/BeaconParser: Ignoring pdu type 03
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: Processing pdu type 16: 0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 9, endIndex: 28
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: Ignoring pdu type 01
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: Ignoring pdu type 03
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: Processing pdu type 16: 0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 9, endIndex: 28
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: This is a recognized beacon advertisement -- 00 seen
09-01 10:05:09.338 9014-9202/com.laira.hias D/BeaconParser: Bytes are: 0201060303aafe1516aafe00e700010203040506070809010203040506000000000000000000000000000000000000000000000000000000000000000000
09-01 10:05:09.338 9014-9202/com.laira.hias D/ScanHelper: Beacon packet detected for: id1: 0x00010203040506070809 id2: 0x010203040506 with rssi -43

ScanHelper detects the device but cannot capture this in code.

Mobile device model and OS version

Samsung Galaxy Tab t280 / 5.1.1

Android Beacon Library version

implementation 'org.altbeacon:android-beacon-library:2+'

IMPORTANT: This forum is reserved for feature requests or reproducible bugs with the library itself. If you need help with using the library with your project, please open a new question on StackOverflow.com.

AdamMiltonBarker commented 4 years ago

I switched to the ranging code and it is now working. Distances are all over the place though the device is downstairs in the front room and it is ranging from 0.001 to 0.3 meters, anyway to make it more accurate for positioning ?

AdamMiltonBarker commented 4 years ago

I realized that bluetooth beacons isn't the way to go for positioning. As no one has responded this issue I guess it can be closed.