Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 beacons can be scanned via direct android BLE API, but could not be called in beaconManager.addMonitorNotifier #1219

Closed
shaojun opened this issue Jan 23, 2025 · 2 comments

Comments

@shaojun
Copy link

shaojun commented Jan 23, 2025

I have 2 beacons nearby, and the manufacturer indicates their UUID are:

beacon uuid: fda50693-a4e2-4fb1-afcf-c6eb07647825

by using the direct Android API, I can constantly(every seconds) see the beacon mac and scanRecord via:

ScanCallback leScanCallback =
    new ScanCallback() {
        @Override
        public void onScanResult(int callbackType, ScanResult result) {
            super.onScanResult(callbackType, result);
            // scanned result data bytes sample:onScanResult-> deviceName: R24110120, rssi: -52, 
            // deviceMacAddress: 52:0A:24:11:00:78, 
            //scanRecord: 0201061aff4c000215fda50693a4e24fb1afcfc6eb0764782500010002d80a0952323431313031323011160318520a24110078000100020603e864000000
        }
};
var bluetoothLeScanner = BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner();
var bluetoothLeScanner = BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner();
            ScanSettings settings = new ScanSettings.Builder().build();
            ScanFilter scanFilter = new ScanFilter.Builder().build();
            ArrayList<ScanFilter> scanFilters = new ArrayList<>();
            scanFilters.add(scanFilter);
            bluetoothLeScanner.startScan(scanFilters, settings, leScanCallback);

while if I choose the library for scanning:

beaconManager = BeaconManager.getInstanceForApplication(this);
// To detect proprietary beacons, you must add a line like below corresponding to yo
// type.  Do a web search for "setBeaconLayout" to get the proper expression.
beaconManager.getBeaconParsers().add(new BeaconParser().
        setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
beaconManager.addMonitorNotifier(new MonitorNotifier() {
    @Override
    public void didEnterRegion(Region region) {
        var regionLogStr = String.format("didEnterRegion: %s", region.toString());
        Log.i(TAG, "onScanResult - I just saw an beacon for the first time! - " + re
    }
    @Override
    public void didExitRegion(Region region) {
        Log.i(TAG, "onScanResult - I no longer see an beacon");
    }
    @Override
    public void didDetermineStateForRegion(int state, Region region) {
        var regionLogStr = String.format("didDetermineStateForRegion: %s, mac: %s", region.toString(), region.getBluetoothAddress());
        Log.i(TAG, "onScanResult - I have just switched from seeing/not seeing beacons: " + state + " - " + regionLogStr);
    }
});
beaconManager.startMonitoring(new Region("myMonitoringUniqueId", null, null, null));

I could never have any of that callback: didEnterRegion hit, only the didDetermineStateForRegion get called when app just started with logging:

onScanResult - I have just switched from seeing/not seeing beacons: 0 - didDetermineStateForRegion: id1: null id2: null id3: null, mac: null

what could be wrong here?

@davidgyoung
Copy link
Member

@shaojun please post support questions to StackOverflow.com. You can include your details above, but please also post why how you know the beacons are actually transmitting. You may wish to try the BeaconScope app from the Google Play store to confirm the beacons are transmitting, and what format they are using.

Again, please post a followup to Stackoverflow.com

@shaojun
Copy link
Author

shaojun commented Jan 26, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants