Beacon Not Detected by AltBeacon Library
shazleenn opened this issue · 0 comments
I am experiencing an issue where my Estimote beacon is not being detected by the AltBeacon library in my Android application. The beacon is visible in third-party apps like Mobile Beaconer and BeaconScope but not in my app.
Steps to Reproduce:
Configure the Estimote beacon with the following settings:
Namespace ID: edd1ebeac04e5defa017
Instance ID: f1e83900106d
Advertising Interval: 300 ms
Transmit Power: Weak (-12 dBm)
Add the AltBeacon library to the Android project:
gradle
implementation 'org.altbeacon:android-beacon-library:2.19.5'
the relevant code :
private void startBeaconDetection() {
beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.getBeaconParsers().clear();
beaconManager.getBeaconParsers().add(new BeaconParser().setBeaconLayout("s:0-1=feaa,m:2-2=00,p:3-3:-41,i:4-13,i:14-19"));
beaconManager.setForegroundScanPeriod(5000L); // Scan for 5 seconds
beaconManager.setForegroundBetweenScanPeriod(0L); // No interval between scans
beaconManager.setBackgroundScanPeriod(5000L); // Scan for 5 seconds
beaconManager.setBackgroundBetweenScanPeriod(0L); // No interval between scans
beaconManager.setRegionStatePersistenceEnabled(false);
beaconManager.bind(this);
}
@OverRide
public void onBeaconServiceConnect() {
beaconManager.addRangeNotifier(new RangeNotifier() {
@OverRide
public void didRangeBeaconsInRegion(Collection beacons, Region region) {
if (beacons.size() > 0) {
for (Beacon beacon : beacons) {
String namespace = beacon.getId1().toString();
String instance = beacon.getId2().toString();
String beaconInfo = "Beacon detected: Namespace = " + namespace + ", Instance = " + instance + ", RSSI = " + beacon.getRssi();
Log.d(TAG, beaconInfo);
runOnUiThread(() -> beaconTextView.setText(beaconInfo));
}
} else {
runOnUiThread(() -> beaconTextView.setText("Searching..."));
}
}
});
try {
Identifier namespaceId = Identifier.parse("edd1ebeac04e5defa017");
Identifier instanceId = Identifier.parse("f1e83900106d");
Region region = new Region("myRangingUniqueId", namespaceId, instanceId, null);
beaconManager.startRangingBeacons(region);
} catch (Exception e) {
Log.e(TAG, "Cannot start ranging", e);
}
}
logs:
2024-06-17 01:22:08.364 26990-26990 MainActivity com.example.ezklia D Ranging beacons in region: id1: null id2: null id3: null
2024-06-17 01:22:08.365 26990-26990 MainActivity com.example.ezklia D Beacons detected: 0
2024-06-17 01:22:08.369 26990-26990 MainActivity com.example.ezklia D No beacons detected
Environment:
Android Studio Version: 4.1
Android Device: Redmi Note 13 Pro 5G
AltBeacon Library Version: 2.19.2 (also tested with 2.18.1)
Beacon Firmware: Estimote OS 4.13.2
Additional Notes:
The beacon is visible in third-party applications like Mobile Beaconer and BeaconScope.
All necessary permissions have been granted, and Bluetooth is enabled on the device.
Any guidance or assistance to resolve this issue would be greatly appreciated.