0

I found the post on how to range all of the beacons and locate the closest one. I got that working nicely. But now I want to do the same for a group of multiple beacons. I am assuming that regions are the best way to do this with the AltBeacon library. I have no concerns for Apple/iBeacon compatibility.

I'm looking at building a simple home scaled zoning system, where there is a group of beacons for each room.

I'm working from the Reference app. I'm not a real dev, so my efforts are strongly based on examples. I have no clue about java structures. Figuring out where to place some code examples has been challenging for me.

As of now, I put some code into the didRangeBeaconsInRegion section, but it triggers for all of the regions I created (1 per room). I have no idea how to track state across multiple runs of that code section?

My guess is that if regions can't be used for this, then some type of location array along with a status "array" to track the state of every beacon and judge the location based on the top entries is the next best option?

TIA!

usernotdev
  • 117
  • 1
  • 7

1 Answers1

0

In a home application, most if not all beacons will typically be in range at all times. Regions probably won't help much because even if you organize your beacons into regions, your mobile device will report it is in all regions simultaneously.

What I would do is set the third beacon identifier (i.e. ID3 or "minor") for each beacon to be the same value for each room. (e.g. use 1 for kitchen, 2 for living room, etc.). Then use only a single region that matches all beacons.

In your ranging callback find out which beacon is closest by comparing the distance field of each beacon. (The lowest one is the closest.) Finally, look at the ID2 value of the closest beacon to figure out which room you are in.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Unfortunately, this doesn't really answer my question. While I understand the point about ranging a single beacon, it does not really give me any idea on handling multiple beacons - regardless of detecting them all. I will likely be lowering power usage of the beacons such that they cannot so easily overlap. But still being able to look at groups of beacons to ascertain the closest "group", seems very useful. Relying on a single beacon only increases the chance of a mislocation. – usernotdev Jan 14 '15 at 15:55
  • Understand that if you have multiple beacons transmitting, and you set up a single region that matches them all with `new Region("myGlobalRegion", null, null null)`, the `didRangeBeaconsInRegion` will include a list of every single visible beacon. – davidgyoung Jan 14 '15 at 16:12
  • Understood. I am able to do that now. But I want to improve the accuracy by using multiple beacons per room, which is what leads to my question. I need to know which beacons are associated with which room, so I was hoping to use the region UniqueID for this. But it sounds like you are talking me out of it (as if its not really possible), so I would just need to look at some other ideas on how to associate groups of beacons with a room. – usernotdev Jan 14 '15 at 16:29
  • OK, if you want to have multiple beacons per room, then you can switch to using ID2 (major) to identify the room, then use ID1 (minor) to be a sequential beacon identifier so you can tell them apart. – davidgyoung Jan 14 '15 at 17:23
  • I understand the major IDs, and that was part of my plan for the regions. I need a label like "room 2" to provide, not "2". So my idea back in my original question is how I thought about tracking that. Would that "array" setup code go into the BeaconReferenceApplication / OnCreate? – usernotdev Jan 14 '15 at 22:21
  • Obviously, I'm trying to avoid hardcoding things all around. Having an "array" would hopefully allow me to consume it anywhere else in the app I needed, was what I was thinking here. – usernotdev Jan 14 '15 at 22:43
  • You would need to create this lookup table someplace where it is accessible in the didRangeBeaconsInRegion callback. If you have that callback method in the BeaconReferenceApplication, you could declare it as a class variable there and initialize it in the onCreate method, yes. – davidgyoung Jan 14 '15 at 23:22