How to set multiple proximity zones?


#1

Hi there, I am trying to set up a few beacons in different parts of the office to send Enter and Exit messages for each area - they do not overlap. I have tried setting up 3 zones as below but Can’t get any responses when walking by the beacons.

 RequirementsWizardFactory
            .createEstimoteRequirementsWizard()
            .fulfillRequirements(this,
                    // onRequirementsFulfilled
                    new Function0<Unit>() {
                        @Override
                        public Unit invoke() {
                            Log.d("app", "requirements fulfilled");
                            proximityObserver.startObserving(zone);
                            return null;
                        }
                    },
                    // onRequirementsMissing
                    new Function1<List<? extends Requirement>, Unit>() {
                        @Override
                        public Unit invoke(List<? extends Requirement> requirements) {
                            Log.e("app", "requirements missing: " + requirements);
                            return null;
                        }
                    },
                    // onError
                    new Function1<Throwable, Unit>() {
                        @Override
                        public Unit invoke(Throwable throwable) {
                            Log.e("app", "requirements error: " + throwable);
                            return null;
                        }
                    });
    RequirementsWizardFactory
            .createEstimoteRequirementsWizard()
            .fulfillRequirements(this,
                    // onRequirementsFulfilled
                    new Function0<Unit>() {
                        @Override
                        public Unit invoke() {
                            Log.d("app", "requirements fulfilled");
                            proximityObserver.startObserving(zone1);
                            return null;
                        }
                    },
                    // onRequirementsMissing
                    new Function1<List<? extends Requirement>, Unit>() {
                        @Override
                        public Unit invoke(List<? extends Requirement> requirements) {
                            Log.e("app", "requirements missing: " + requirements);
                            return null;
                        }
                    },
                    // onError
                    new Function1<Throwable, Unit>() {
                        @Override
                        public Unit invoke(Throwable throwable) {
                            Log.e("app", "requirements error: " + throwable);
                            return null;
                        }
                    });
    RequirementsWizardFactory
            .createEstimoteRequirementsWizard()
            .fulfillRequirements(this,
                    // onRequirementsFulfilled
                    new Function0<Unit>() {
                        @Override
                        public Unit invoke() {
                            Log.d("app", "requirements fulfilled");
                            proximityObserver.startObserving(zone2);
                            return null;
                        }
                    },
                    // onRequirementsMissing
                    new Function1<List<? extends Requirement>, Unit>() {
                        @Override
                        public Unit invoke(List<? extends Requirement> requirements) {
                            Log.e("app", "requirements missing: " + requirements);
                            return null;
                        }
                    },
                    // onError
                    new Function1<Throwable, Unit>() {
                        @Override
                        public Unit invoke(Throwable throwable) {
                            Log.e("app", "requirements error: " + throwable);
                            return null;
                        }
                    });
}

ProximityZone zone = new ProximityZoneBuilder()
        .forTag("Front Desk")
        .inCustomRange(3.5)
        .onEnter(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                String deskLocation = context.getAttachments().get("desk-location");
                Log.d("app", "Welcome to the " + deskLocation);
                return null;
            }
        })
        .onExit(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                Log.d("app", "Bye bye, come again!");
                return null;
            }
        })
        .build();

ProximityZone zone1 = new ProximityZoneBuilder()
        .forTag("Bistro")
        .inCustomRange(3)
        .onEnter(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                String deskLocation = context.getAttachments().get("desk-location");
                Log.d("app", "Welcome to the " + deskLocation + "! Hope you enjoy your coffee or meal");
                return null;
            }
        })
        .onExit(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                Log.d("app", "Bye bye, come again!");
                return null;
            }
        })
        .build();

ProximityZone zone2 = new ProximityZoneBuilder()
        .forTag("Aaron's Desk")
        .inNearRange()
        .onEnter(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                String deskLocation = context.getAttachments().get("desk-location");
                Log.d("app", "Welcome to " + deskLocation + "! You should get some candy while you are here...");
                return null;
            }
        })
        .onExit(new Function1<ProximityZoneContext, Unit>() {
            @Override
            public Unit invoke(ProximityZoneContext context) {
                Log.d("app", "Bye bye, come again!");
                return null;
            }
        })
        .build();

#2

Try this (;

proximityObserver.startObserving(zone1, zone2, zone3);