0

I order to test an iBeacon app for iOS, I have configured a RaspberryPi with four BLE usb dongles to simulate real iBeacons.

It happens that all iBeacons are detected but not simultaneously. The beacons array passed to locationManager:didRangeBeacons:inRegion: method contains no more than 2 iBeacons and it changes content almost at every invocation.

How should I interpret the documentation for locationManager:didRangeBeacons:inRegion: method?

beacons: An array of CLBeacon objects representing the beacons currently in range. You can use the information in these objects to determine the range of each beacon and its identifying information.

Discussion: The location manager calls this method whenever a beacon comes within range or goes out of range. The location manager also calls this method when the range of the beacon changes; for example, when the beacon gets closer.*

Seems to me that all beacons in range should be in the beacons array. If not, how the beacons that become out of range can be determined? Or may be this is a problem due to the fake beacons?


UPDATE

I added another BLE usb dongle and now the device detects three beacons every time. Seems to me that the device has no memory of the beacons detected in previous scanning windows. My understanding of this behaviour is illustrated in this picture.

At end the device detects all beacons probably because there is some random delay in the scanning period (as illustrated in the picture) and/or some other delay in beacon transmission.

1 Answers1

0

Understand that that method is invoked once per second for each region you are ranging. Each invocation will only include the beacons visible in that one second period in that same region. Note that the region object is passed in the method as well.

EDIT: Further investigation revealed that the questioner was using a Raspberry Pi iBeacon transmitter that is probably only sending out an advertisement every 1280ms, which will definitely cause the problem reported. The solution is to increase the advertising frequency so that at least one packet goes out every second (ideally at a rate of 10Hz or higher for the best distance estimates.)

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Hello David, all the beacons I have use the same UUID and major value but with different minor values, so I have only one region. The method is always invoked with a subset of active beacons, the subset changes at almost every invocation but at the end all beacons are detected at least once. – Jonathan Stephenson Jun 06 '14 at 13:54
  • Do you know how often your iBeacon devices are transmitting? I believe the standard is for the transmissions to go at 10Hz, so you should not be missing any transmissions in a ranging cycle unless your beacons are transmitting at a frequency of less than 1Hz. – davidgyoung Jun 06 '14 at 18:07
  • Good point David! I am using a configuration like the one in this [tutorial](https://learn.adafruit.com/pibeacon-ibeacon-with-a-raspberry-pi/overview). I found some info about how to change transmission frequency [here](http://stackoverflow.com/questions/21124993/is-there-a-way-to-increase-ble-advertisement-frequency-in-bluez). I will try and let you know. – Jonathan Stephenson Jun 07 '14 at 10:40
  • You can increase the advertising rate on Linux from the default 1Hz to 10Hz as described in my answer here: http://stackoverflow.com/questions/21124993/is-there-a-way-to-increase-ble-advertisement-frequency-in-bluez – davidgyoung Jun 07 '14 at 10:49
  • Thanks David for your help! I have dongles based on CSR8510. Seems that the script you proposed is not working with it. I continue to detect less beacons then the ones available (4 beacons instead of 6). – Jonathan Stephenson Jun 09 '14 at 15:24
  • Sorry the commands didn't work with your dongle. You might keep trying a different order of commands -- I do believe that changing the advertising frequency is standard BLE functionality according to the spec. If your BLE dongle is also advertising at the default 1280ms period, then it would cause exactly what you are seeing. – davidgyoung Jun 09 '14 at 15:32