Search code examples
macosbluetoothosx-elcapitanlatencybluetooth-lowenergy

Bluetooth Low Energy Lag / Latency on OS X 10.11 El Capitan


I've been developing a Mac OS X application that sends commands continuously over Bluetooth Low Energy to a hardware device. Under Yosemite, the app worked well, with a measured roundtrip latency of 7-12 ms for a command transmission. The command is sent to a custom BLE service in a steady interval of minimum 2 seconds and maximum 0.2 seconds.

Now, I haven't been developing in the last months (the app isn't live yet), then upgraded to El Capitan, and now the same app has a latency of 500-1500 ms, which renders the whole thing absolutely unusable. I am assuming the upgrade to El Capitan is the cause, but I cannot know for sure.

What I checked:

  • I tested on multiple MacBook Pros running El Capitan, and the latency is always that bad.
  • The commands have a high latency regardless of the service they're sent to (e.g., the device information service), and it varies a lot with every message sent.
  • It doesn't matter if I'm using our own application, a third party application named "LightBlue" to send hex strings, or Apple's own "Bluetooth Explorer" Developer Tools (can be downloaded in Developer Resources).

Can anyone hint me to what could cause this, or maybe just tell me that in their environment it all works fine? To reproduce, connect to any Bluetooth Low Energy capable device with your Mac, and send a hex string of data to it. You'd have to log it somehow or turn on an LED or so, to see if there is significant latency.

Any help is greatly appreciated!


Solution

  • In the end Apple DTS helped me solve the problem. They hinted me at the "preferred connection parameters" that were set incorrectly in my firmware.

    On earlier versions of Yosemite, those values had no effect (same as on iOS), but since some OS update they are read on Yosemite and El Capitan. Not setting the parameters at all solved the problem.

    In my case, the values were set by default:

    Connection interval: minimum 7.5ms, maximum 50ms

    Slave latency: 0ms

    Connection supervision timeout: 10000

    These values somehow caused the high latency. Here's a screenshot of the settings I had to untick inside the Cypress PSoC Creator 3.3 (I'm using a PSoC 4 BLE).

    enter image description here