0
\$\begingroup\$

Latency of BLE GATT Read Value Operation

Assume that a peripheral and central BLE devices have a connection established. Central is running a GATT service with a particular characteristic. Peripheral has searched for and found the service and characteristic, and it has all handles ready at hand.

What is the latency (in the peripheral) between issuing a read request for the characteristic and receiving value of the characteristic? I realize there is some back and forth between the peripheral and central, and thus the latency is not constant. What are the typical, min, and max latency values? Assume that the peripheral and central have no other BLE activity competing for resources.

In my experiments (using Laird BL654 dongle), I am getting circa 200ms delay but I do not know if this is the best/typical/worst case.

PS: I am talking about regular environment e.g. someone's house. It can, of course, take forever if there is a lot of traffic, bad connection etc.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ IIRC the basic period of communication in a connection is not fixed but something the device (and possibly also host) can specify - a lower rate would make things less responsive, but save battery. \$\endgroup\$ Sep 18, 2020 at 15:51
  • 1
    \$\begingroup\$ A "maximum" would be hard to define if there's a retry mechanism, which for a radio scheme on an unreserved channel there basically has to be. In effect, the only "maximum" would be the time after which the connection is declared broken. \$\endgroup\$ Sep 18, 2020 at 16:05
  • \$\begingroup\$ @ChrisStratton Sounds right. The max is perhaps the connection timeout. I am afraid there is no real simple answer. There must be at least one round trip -- peripheral/client sending a read request and central/server responding to it with a value. Time it takes for the round trip is not constant/fixed. In my case, it happens to be ~200ms but I cannot say much more about it. \$\endgroup\$ Sep 18, 2020 at 19:24

1 Answer 1

2
\$\begingroup\$

The BLE central and peripheral exchange data at regular connection intervals. The connection interval is controlled by the central device. Although the peripheral can request the intervals it prefers, it's up to the central to decide, as it may be managing multiple peripheral connections at once.

If the central is a smartphone, you're limited to what the smartphone/OS allows. Android can go as fast as 7.5 mSec, while iOS prefers nothing faster than 20 mSec. If you're writing the firmware for the central (e.g., your Laird BL654 dongle) and the peripheral, then you can go faster but you're eventually limited by the length of the BLE transmission (2 - 3 mSec). You might get down to a 5 mSec connection interval if no other activities interfere.

Even knowing the connection interval, your latency will vary. It's like catching a bus that runs at regular intervals. If you get lucky and a request occurs right before a connection interval, you step right on the bus, and get back the result in that same connection, with latency ~3 mSec. If, instead you just barely "miss the bus", you have to wait for the next one, so latency would be 3 mSec plus the full connection interval. On average, you'll see about 1/2 the connection interval for latency.

Also, you talked about the peripheral requesting data from the central. Usually it's the other way around. If the request really is originating from the peripheral, I think you'll always have to wait for the next connection to get the result from the central. So average latency would be 1.5x the connection interval in this configuration.

Hope this helps you!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.