How to know the closest iBeacon

后端 未结 3 1616
無奈伤痛
無奈伤痛 2021-01-06 07:22

I have a code to know which beacon is the closest, but I have a problem when a beacon\'s accuracy is -1.00000, the the app takes the second one.

So there is a bucle

3条回答
  •  借酒劲吻你
    2021-01-06 08:22

    In addition to filtering out proximity values of -1, you also have to take into account cases where certain iBeacons periodically do not appear in a callback to didRangeBeacons: inRegion. This can happen due to radio interference, especially for battery powered beacons that do not transmit advertisements very frequently.

    To solve this, you need to keep your own list of recently seen beacons, and track any beacons that have been seen in the last few seconds. If one of the beacons has a proximity of -1, you can either not put it in the list, or re-use the last known non -1 proximity value if it does not exist.

    Another consideration that you need to take into account is that the proximity value will bounce around quite a bit. You may need to add some hysteresis logic to your algorithm so which beacon is the closest doesn't bounce back and forth every second. The specifics of how you want to do this depend on your use case.

提交回复
热议问题