Im trying to get the Major/Minor from a SecureRegion, but when it gets into onEnteredRegion
the List<Beacon> beacons
is empty
Any help will be appreciated.
Note: Beacon has the secure option set to true (secure=‘true’)
Note: I have also tried randomizing only major/minor and keep the UUID non-randomized but in this scenario it doesn’t event gets to the onEnteredRegion() listener
Note: If i disable the secure option in the beacon and Use Region instead of SecureRegion it works like a charm, but i need to enable the Secure UUID for my project
Note: If i enable the secure option in the beacon and Use Region instead of SecureRegion, it shows me the random Major/Minor generated by the Estimote Lib, i need the real values
I provide appId & appToken like this:
EstimoteSDK.initialize(this, "XXX", "XXX");
// Configure verbose debug logging.
EstimoteSDK.enableDebugLogging(true);
//this is just to check if estimote initialized correctly
MacAddress macAddress = MacAddress.fromString("D0:11:18:50:9C:17");
EstimoteCloud.getInstance().fetchBeaconDetails(macAddress, new CloudCallback<BeaconInfo>() {
@Override
public void success(BeaconInfo beaconInfo) {
Log.d(TAG, beaconInfo.toString());
//this works and yields all relevant information
//BeaconInfo{uuid='049494bf-9a50-42c7-9573-61c46496c5b2', major=1003, minor=8, macAddress='[D0:11:18:50:9C:17]', name='ice-2', color=Icy Marshmallow, batteryLifeExpectancyInDays=386.0, settings=BeaconInfoSettings{batteryLevel=100, hardware='D3.4', firmware='A3.2.0', broadcastingPower=LEVEL_8, advertisingIntervalMillis=318, basicPowerMode=true, smartPowerMode=true, conditionalBroadcasting=FLIP_TO_SLEEP, broadcastingScheme=ESTIMOTE_DEFAULT, isFirmwareUpToDate=true, eddystoneNamespace='null', eddystoneInstance='null', eddystoneUrl='null', secure='true'}}
}
@Override
public void failure(EstimoteServerException e) {
Log.d(TAG, e.toString());
}
});
Then i start Monitoring a SecureRegion:
private static final SecureRegion ALL_SECURE_ESTIMOTE_BEACONS = new SecureRegion("rid", null, null, null);
beaconManager = new BeaconManager(getApplicationContext());
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
Log.d(TAG, "serviceReady");
//beaconManager.startMonitoring(ALL_ESTIMOTE_BEACONS);
beaconManager.startMonitoring(ALL_SECURE_ESTIMOTE_BEACONS);
}
});
beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
Toast.makeText(BeaconsMonitoringService.this, "Se detecto un beacon!", Toast.LENGTH_LONG).show();
if (beacons.isEmpty()) {
// This is where the process enters and i get an empty list everytime
Log.d(TAG, "List of beacons is EMPTY.... WHY!?");
Log.d(TAG, "Region: " + region.toString());
return;
}
// Get Major and minor for that beacon
for(Beacon beacon : beacons){
minor = beacon.getMinor();
major = beacon.getMajor();
Log.d(TAG, "Major:" + major + " Minor:" + minor);
// Reset ListView Promos
gv = (GlobalVars) getApplication();
gv.setMajor(major);
gv.setMinor(minor);
}
if(minor != 0 && major != 0){
// Check if Internet present
if (!isOnline(context)) {
// Internet Connection is not present
makeText(context, "No posee conexion a internet!",
LENGTH_LONG).show();
// stop executing code by return
return;
}
// Get Merchant information
Integer[] params = {major, minor};
new AsyncGetMerchantFromBeacon().execute(params);
}
}
@Override
public void onExitedRegion(Region region) {
Log.d(TAG, "exited");
//Toast.makeText(BeaconsMonitoringService.this, "Salio del rango del beacon", Toast.LENGTH_LONG).show();
minor = 0;
major = 0;
ArrayList<HashMap<String, String>> listBeaconPromos = new ArrayList<HashMap<String, String>>();
gv = (GlobalVars) getApplication();
gv.setMajor(major);
gv.setMinor(minor);
gv.setIdMerchant("0");
gv.setListPromotionsFromBeacon(listBeaconPromos);
if(notiExit == 1){
makeNotification(context, "Gracias por su visita!", "Lo esperamos pronto");
}
}
});