Altbeacon android 设备屏幕关闭很长时间后,信标库无法正常工作

Altbeacon android beacon library not working after device has screen off for a substantial time

Android 信标库版本:2.16.2

以下设备出现问题:Samsung 8.1、Samsung 8.0、Samsung 7.1.1

我遇到的问题是 Altbeacon 库在 30、40、50 秒内一直到 1000 秒都没有检测到信标。这似乎只发生在屏幕关闭时。

Android-清单

    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

这是我创建的 beaconManager,它位于一个持续运行的前台服务中。

private fun createBeaconMgr() {
        BeaconManager.setDebug(true)
        beaconManager = BeaconManager.getInstanceForApplication(this)

        if (!beaconManager.scheduledScanJobsEnabled)
        {
            beaconManager.setEnableScheduledScanJobs(true)

        }
        beaconManager.beaconParsers.apply {
            add(BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT))
            add(BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_URL_LAYOUT))
            add(BeaconParser().setBeaconLayout(BeaconParser.EDDYSTONE_TLM_LAYOUT))
        }



        beaconManager.bind(this)

    }

这是我的 beaconServiceConnect,还有其他覆盖。

    override fun onBeaconServiceConnect() {
        if (beaconManager.rangingNotifiers.isNotEmpty() && beaconManager.monitoringNotifiers.isNotEmpty()) {
            return
        }

        //TODO: Dynamically build identifiers and regions

        beaconManager.foregroundScanPeriod = 1100
        beaconManager.foregroundBetweenScanPeriod = 0

        beaconManager.updateScanPeriods()

        try {
            //Start looking for Beacons
            beaconManager.startMonitoringBeaconsInRegion(beacon1Region)
            beaconManager.startMonitoringBeaconsInRegion(beacon2Region)
            beaconManager.startMonitoringBeaconsInRegion(beacon3Region)
            //Start range finding beacons
            beaconManager.startRangingBeaconsInRegion(beacon1Region)
            beaconManager.startRangingBeaconsInRegion(beacon2Region)
            beaconManager.startRangingBeaconsInRegion(beacon3Region)
        } catch (e: Exception) {
            Log.e(TAG, e.message!!)
        }

        beaconManager.addRangeNotifier(this)
        beaconManager.addMonitorNotifier(this)
    }

    override fun didEnterRegion(region: Region) {
        //possibly temporarily added. Issues occured before this, and this was a solution we tried
        beaconManager.startRangingBeaconsInRegion(beacon1Region)
        beaconManager.startRangingBeaconsInRegion(beacon2Region)
        beaconManager.startRangingBeaconsInRegion(beacon3Region)
    }

    override fun didExitRegion(region: Region) {
        Log.d(TAG, "Did exit")
    }

    override fun didDetermineStateForRegion(state: Int, region: Region) {
        Log.d(TAG, "did determine")
    }

    override fun didRangeBeaconsInRegion(beacons: Collection<Beacon>, region: Region) {

        val dateRead = Date() //this is logged to our database

        //business logic below
}

下面是一个 logcat 的特定时间,它没有检测到信标,即使我把一个信标放在平板电脑上(它在大约 26 秒内没有检测到)。根据要求,我可以提供更多日志。

Processing pdu type FF: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000 with startIndex: 26, endIndex: 31

[ 09-17 15:15:10.924  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.925  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.925  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.925  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.925  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.926  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:10.928 24172:24461 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.928 24172:24461 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.923 24172: 3828 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:10.929 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:10.943  2565: 3188 D/libgps   ]
OnGpsExtensionMessage: message_id(1), data(0x7b0b2038), size(3336)


[ 09-17 15:15:10.944  2565: 3188 D/libgps   ]
proxy__gnss_sv_status_cb: called. num_svs(2)

[ 09-17 15:15:10.944  2565: 3188 D/GnssLocationProvider_ex ]
SV Count : 2(0) / TOP5(v) : 27 17  / TOP5(u) : 

[ 09-17 15:15:10.957  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.958  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.958  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.958  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.958  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.958  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.958  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:10.959 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.959 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.959 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:10.968  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.968  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.969  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.969  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.969  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.969  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.971  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:10.972 24172:24184 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.972 24172:24184 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.972 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.989  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.990  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:10.991 24172:24461 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:10.991 24172:24461 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:10.991 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:10.992 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 30

[ 09-17 15:15:10.992 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 2 and 10 at offset 4.  The bytes I see are: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:10.992 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 30

[ 09-17 15:15:10.992 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.019  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.025  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.029  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.030 24172:24172 D/CycledLeScanner ]
Waiting to stop scan cycle for another 100 milliseconds

[ 09-17 15:15:11.035  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.035  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.036  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.036  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.036  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.036  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.044 24172: 3826 D/BeaconParser ]
Processing pdu type FF: 1bff75004204018060c048e6fa643dc248e6fa643c016f000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 27

[ 09-17 15:15:11.045 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 26 and 10 at offset 28.  The bytes I see are: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 08

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 07

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000 with startIndex: 26, endIndex: 31

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 08

[ 09-17 15:15:11.046 24172: 3827 D/BeaconParser ]
Ignoring pdu type 07

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000 with startIndex: 26, endIndex: 31

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 26 and 00 at offset 28.  The bytes I see are: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
Ignoring pdu type 08

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
Ignoring pdu type 07

[ 09-17 15:15:11.047 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000 with startIndex: 26, endIndex: 31

[ 09-17 15:15:11.048 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 26 and 20 at offset 28.  The bytes I see are: 0201060208001107757ed3e418284a0c8362c229c3a6da7207ff88c6267c6901000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.048 24172: 3829 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.048 24172: 3829 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.048 24172: 3829 D/BeaconParser ]
Processing pdu type FF: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29

[ 09-17 15:15:11.049 24172: 3829 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: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.049 24172: 3829 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.049 24172: 3829 D/BeaconParser ]
Processing pdu type FF: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29

[ 09-17 15:15:11.049 24172: 3829 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 20 at offset 7.  The bytes I see are: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.056  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.057  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.057  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.057  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.057  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.057  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.061  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:11.061  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:11.061  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:11.062 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.062 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.063 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 30

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.063  2565:24988 D/LocationManagerService ]
getProviders()=[gps]

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.063  2565:24988 D/LocationManagerService ]
getBestProvider(Criteria[power=NO_REQ acc=HIGH], true)=gps

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.063  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.063 24172: 3830 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: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.064  2943: 4306 D/BtGatt.ContextMap ]
sendClientScanResult for app id 6

[ 09-17 15:15:11.065 20589:20612 D/DriverLocationManager ]
getBestProvider: gps

[ 09-17 15:15:11.066  2565: 3565 D/LocationManagerService ]
getLastLocation: Request[ACCURACY_FINE gps requested=0 fastest=0 num=1]

[ 09-17 15:15:11.045 24172: 3828 D/BeaconParser ]
Processing pdu type FF: 0201060aff4c0010050b1cf8e6ef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.066 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000 with startIndex: 2, endIndex: 30

[ 09-17 15:15:11.067 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 2 and 20 at offset 4.  The bytes I see are: 1eff060001092002d94a4a4a79d87c0805372dedc5569f4b9b9bdd4f4fcbdf00000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.067 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.067 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14

[ 09-17 15:15:11.067 24172: 3830 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.067 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.067 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.067 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.067 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 10 at offset 7.  The bytes I see are: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.067 20589:20612 I/com.changedName.android.obuservices.ScreenBlockService ]
Speed:0

[ 09-17 15:15:11.067 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.067 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14

[ 09-17 15:15:11.067 20589:20612 I/com.changedName.android.obuservices.ScreenBlockService ]
check driving status: false0

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 10 at offset 7.  The bytes I see are: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.068 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.068 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.068 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.068 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:11.068 24172: 3827 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: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.068 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.069 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:11.069 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.069 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.069 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 14

[ 09-17 15:15:11.069 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.069 24172: 3830 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: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.069 24172: 3830 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.069 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 20 at offset 7.  The bytes I see are: 02011b0bff4c00090603000a010ae10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.069 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.069 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.069 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.069 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.070 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c0010051a1cbc5298000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.070 24172:24185 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.070 24172: 3830 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 20 at offset 7.  The bytes I see are: 02011a0aff4c001005131c09b535000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.070 24172:24185 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.070 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. Was expecting aa fe at offset 5 and 10 at offset 7.  The bytes I see are: 02011a0aff4c0010051a1cbc5298000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.070 24172: 3830 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.070 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.070 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c0010051a1cbc5298000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.071 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:11.071 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:11.071 24172: 3827 D/BeaconParser ]
This is not a matching Beacon advertisement. (Was expecting be ac.  The bytes I see are: 02011a0aff4c0010051a1cbc5298000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

[ 09-17 15:15:11.071 24172:24172 D/CycledLeScannerForLollipop ]
with service uuid: 00001122-0000-1000-8000-00805f9b34fb

[ 09-17 15:15:11.071 24172: 3827 D/BeaconParser ]
Ignoring pdu type 01

[ 09-17 15:15:11.071 24172:24172 D/CycledLeScannerForLollipop ]
got record

[ 09-17 15:15:11.071  2943: 3063 D/ScanRecord ]
parseFromBytes

[ 09-17 15:15:11.071  2943: 3063 D/ScanRecord ]
first manudata for manu ID

[ 09-17 15:15:11.071 24172: 3830 D/BeaconParser ]
Processing pdu type FF: 02011a1aff4c000c0e007082d2b06a4412c1d208efdf4a10050b1c24d3bd0000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 29

[ 09-17 15:15:11.071  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.071 24172: 3827 D/BeaconParser ]
Processing pdu type FF: 02011a0aff4c0010051a1cbc5298000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 with startIndex: 5, endIndex: 13

[ 09-17 15:15:11.071  2943: 3063 D/ScanRecord ]
Not a Multi Manu data

[ 09-17 15:15:11.071  2943: 3063 D/ScanRecord ]
parseFromBytes

有什么想法吗?

Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=null, mUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=118, mManufacturerData=BE AC, mManufacturerDataMask=FF FF]

[ 09-17 17:34:43.831  7169: 7392 D/ScanFilterUtils ]
making scan filter for service: 0000FEAA-0000-1000-8000-00805f9b34fb 0000feaa-0000-1000-8000-00805f9b34fb

[ 09-17 17:34:43.831  7169: 7392 D/ScanFilterUtils ]
making scan filter with service mask: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF ffffffff-ffff-ffff-ffff-ffffffffffff

[ 09-17 17:34:43.831  7169: 7392 D/ScanFilterUtils ]
Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=0000feaa-0000-1000-8000-00805f9b34fb, mUuidMask=ffffffff-ffff-ffff-ffff-ffffffffffff, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=ffffffff, mManufacturerData=null, mManufacturerDataMask=null]

[ 09-17 17:34:43.832  7169: 7392 D/ScanFilterUtils ]
making scan filter for service: 0000FEAA-0000-1000-8000-00805f9b34fb 0000feaa-0000-1000-8000-00805f9b34fb

[ 09-17 17:34:43.832  7169: 7392 D/ScanFilterUtils ]
making scan filter with service mask: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF ffffffff-ffff-ffff-ffff-ffffffffffff

[ 09-17 17:34:43.832  7169: 7392 D/ScanFilterUtils ]
Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=0000feaa-0000-1000-8000-00805f9b34fb, mUuidMask=ffffffff-ffff-ffff-ffff-ffffffffffff, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=ffffffff, mManufacturerData=null, mManufacturerDataMask=null]

[ 09-17 17:34:43.833  7169: 7392 D/ScanFilterUtils ]
making scan filter for service: 0000FEAA-0000-1000-8000-00805f9b34fb 0000feaa-0000-1000-8000-00805f9b34fb

[ 09-17 17:34:43.833  7169: 7392 D/ScanFilterUtils ]
making scan filter with service mask: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF ffffffff-ffff-ffff-ffff-ffffffffffff

[ 09-17 17:34:43.833  7169: 7392 D/ScanFilterUtils ]
Set up a scan filter: BluetoothLeScanFilter [mDeviceName=null, mDeviceAddress=null, mUuid=0000feaa-0000-1000-8000-00805f9b34fb, mUuidMask=ffffffff-ffff-ffff-ffff-ffffffffffff, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=ffffffff, mManufacturerData=null, mManufacturerDataMask=null]

当屏幕关闭时,Android 8.1+ 的三星设备要求使用非空 BLE 扫描过滤器,否则无法检测到 BLE 数据包。 Android Beacon 库知道这一点,因此它会为您激活的每个 BeaconParser 设置扫描过滤器,以便

出于某种原因,您问题中显示的这些 ScanFilters 似乎与您期望的数据包不匹配,尽管它们看起来不错。为什么?一种可能的答案是,您的设备有 运行 个 ScanFilters——每个都需要蓝牙芯片上的一个插槽,并且可供 all 个应用程序使用的插槽数量有限你的phone。如果是这种情况,您可以尝试以下操作:

  1. 清除默认信标解析器(用于 AltBeacon),因为您没有将它与 BeaconParser().clear()
  2. 一起使用
  3. 尝试仅添加 ONE 信标解析器(而不是显示的三个)并测试是否在屏幕关闭时仅检测到该信标类型。
  4. 如果 (1) 和 (2) 没有帮助,请重新启动您的 phone 并重试。这可能会清除卡住的信标解析器。
  5. 如果上述 none 有帮助,请尝试卸载您认为可能进行蓝牙信标扫描的其他应用程序并占用蓝牙芯片上有限数量的 ScanFilter 插槽,然后重新启动并重试。

自 AndroidN 起,30 分钟或更长时间的扫描在后台被阻止。在使用 Android 信标库时,您可以通过将其添加到 AndroidManifest.xml:

来强制执行变通方法
<service android:name="org.altbeacon.beacon.service.BeaconService"
             tools:node="replace">
        <meta-data android:name="longScanForcingEnabled" android:value="true"/>
</service>

事实证明,由于我的 2 向身份验证方法,一些日志没有进入 API,但没有日志显示,因为它处于 TLS 级别。

查询设备上的数据库发现了 350 万条日志,因此 android 信标库没有问题