Trigger an specific event for an specific beacon at specific distance

Hello,

I am trying to make an application that detects multiple beacons and that for each beacon triggers a specific event at a distance of less than two meters.

That is, when it detects a beacon from the list of beacons that is less than two meters away, if it is beacon 1 that triggers event 1, if it is beacon2 that triggers event2 and so on …

The problem is that my current code does not distinguish between beacons since the last beacon to be detected at less than two meters is the beacon that triggers the event.

If I am less than two meters from beacon 2 and beacon 1 is 6 meters away and the last beacon to be detected was 1, it will trigger the beacon 1 event setting the distance from beacon 2 despite being 10 meters away , which doesn’t make sense !!!

My problem is that my beacons all have the same UUID and I can only distinguish them by the MAC address, I don’t know if this is really the problem or that maybe I need to define a region for each beacon, so if I have 20 beacons, I need define 20 different regions. The problem is that I cannot do this since the regions are filtered by UUID and all my beacons have the same UUID.

I don’t really understand how the regions and their UUID work very well, since what really has UUIDs are my beacons, I’m busy.

This is my code:

   public void didDetermineStateForRegion(int i, Region region) {

            }
        });
        beaconManager.addRangeNotifier(new RangeNotifier() {
            @Override
            public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {

                for(Beacon oneBeacon : beacons){
                    d=oneBeacon.getDistance();

                    Log.d("OUTOFRANGE", " BEACONMAC:" + oneBeacon.getBluetoothAddress() + " distance: " + oneBeacon.getDistance() );

                    if (d<2.0){
                        d=oneBeacon.getDistance();

                        if(oneBeacon.getBluetoothAddress().equals("54:6C:0E:2B:C7:68")){//beacon 1
                            Log.d(TAG, " BEACON1 WITH MAC:" + oneBeacon.getBluetoothAddress() + "DETECTED!!" );

                        } else if(oneBeacon.getBluetoothAddress().equals("58:93:D8:DE:F3:63")){//beacon 2
                            Log.d(TAG, " BEACON2 WITH MAC:" + oneBeacon.getBluetoothAddress() + "DETECTED!!" );

                        }



                    }



//                    try {
//                        Thread.sleep(10000);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }


                }

            }
        });
        try {
            beaconManager.startMonitoringBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
        } catch (RemoteException e) {
            e.printStackTrace();
        }

I NEED HELP, AND I NEED TO UNDERSTAND HOW THE REGION WORKS WITH THAT UUID THAT IT REQUIRES.