0
votes

I am trying a simple test right now.

Device 1:

Acts as beacon with UUID: XXX-XXX-XXX
Major: 1000
Minor: 1234

self.peripheralData = [MyRegion peripheralDataWithMeasuredPower:nil];
[self.peripheralManager startAdvertising:self.peripheralData];

Device 2:

Acts as listener for region with UUID: XXX-XXX-XXX

locationManager startMonitoringForRegion:_region

Device 2 does not detect Device 1. It only detects Device 1 if I program to listen to the region to have major:1000 and minor: 1234.

Does this sound right?

Let's say i have 100 phones acting as beacon with same uuid and identifier but different major and minor values. And I have 50 phones acting as listeners for the specific uuid and idenfitifer... Can I find all beacons with that uuid and read their major and minor values?

What am I doing wrong?

4
Could you post the code that creates the regions on both devices?jonahb
Sure. It's just created using initwithuuid major and minorLegolas

4 Answers

1
votes

When you initialize your region, use

region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:identifierString];

instead of something like

region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:[major integerValue] minor:[minor integerValue] identifier:identifierString];

By not specifying the major and minor values, all beacons with the matching UUID should be detected. It works for me.

1
votes

I think the key to your problem lies in this comment:

Sure. It's just created using initwithuuid major and minor – Legolas yesterday

There are 3 different calls to create a beacon region:

initWithProximityUUID:identifier:

,

initWithProximityUUID:major:identifier:

and

initWithProximityUUID:major:minor:identifier:

If you want to detect beacons with any UUID, you need to use the first form that does not specify the major or minor value.

Then you need to also call startRangingBeaconsInRegion: and look at the beacon objects that are returned in the ranging calls.

DidEnterRegion calls only include major or minor values if they are part of the region.

The ranging callbacks include all the beacons that are detected, including their major and minor values, distance and proximity, etc.

0
votes

To eliminate a problem in your code, try doing the exact same thing with my free Locate for iBeacon app in the app store. Try making one or both sides of the transmitter/detector be this app vs. your custom app.

If it does not work with Locate for iBeacon on both sides, then something is wrong with one of your devices. If it does work with Locate for iBeacon on one side, please post your code for the side that is having trouble.

0
votes

Which delegate methods are you using for the Location Manager? Sometimes DidEnter is not called if you're already in the region i.e. you turn on the transmitting beacon before starting the one that's doing the monitoring. If that's the case monitor for state changes instead and you should be good.

Also, I highly recommend using David's Locate iBeacon app. It will really speed up your development process. Thanks D!