Search code examples
androidibeaconbluetooth-lowenergy

how to increase LeScanCallback frequency?


We want to develop ibeacon function on android 4.3. In order to improve accuracy, we increase advertising rate of the peripheral to 50Hz. But the "LeScanCallback" is only invoked 3 to 5 per second. However, "didDiscoverPeripheral" is called on iPhone can up to 100 per second. I tried to restart "startLeScan" every 500ms, 400ms, 300ms. The increase is limited. When I set the peripheral's advertising rate to 10Hz. The rate of "LeScanCallback" called is fall to 1 to 3 per second.

Is there any suggest? Will it be better If I write a JNI code to call the low level api directly like ble driver.


Solution

  • This may be a device-specific issue. I have done lots of similar tests on Nexus and Samsung devices with beacons transmitting at 20 Hz and typically see about 80 percent of their packets get detected on the Android device. (Meaning LeScanCallback is invoked 16 times per second.)

    Some devices (e.g. Nexus 4, Moto G) have chipsets that only return a single advertising packet per uniquely scanned bluetooth mac address until you stop and restart scanning.

    I doubt that lower-level code would help. Before taking such a step, I would try with a different device.