Detect the detection order of beacons?

74 Views Asked by At

I have 2 beacons. Is there possible to see in what order my app have detected the beacons??

I’m trying to detect if someone is entering/exit in a space based on the order in which beacons are detected. If this is not possible, do you know how can I do that?

1

There are 1 best solutions below

0
davidgyoung On

When using beacon monitoring APIs (e.g. you get a didEnterRegion callback), you typically don't know which beacon triggered the entry and whether a second beacon entered again. To get this information you need to use beacon ranging APIs.

When using beacon ranging APIs (e.g. you get a didRangeBeaconsInRegion callback), the callbacks will be made in a ~1 second frequency. If you record a timestamp the very first time you get a callback for a particular beacon and then associate it with the beacon identifier, you can later tell which which beacon identifier was detected first.

If two beacons appear simultaneously within the same callback, then you need a more accurate timestamp than you can get by just looking at the time the callback was made. If you are using the Android Beacon Library version 2.17+, you can get this kind of timestamp by calling beacon.getFirstCycleDetectionTimestamp(). That method returns the number of milliseconds since 1970 that the first beacon packet was detected that led to the ranging callback.