shva
shva

Reputation: 539

How to understand Bluetooth LE callbacks

I am getting started with BLE development. I am trying to dig into the source code of a SensorTag Android app. But my small brain is having some difficulties in understanding the callbacks conceptually. According to the the callback explained by Wikipedia, it is a routine called within another routine upon some trigger. I would like to know how callbacks are applied in the context of BLE. For example, why reading and writing a characteristics on BLE server need callbacks? Thanks!

Upvotes: 0

Views: 1405

Answers (1)

Tim Tisdall
Tim Tisdall

Reputation: 10392

They need callbacks because all of BLE is asynchronous. So, you can request to read an attribute, some X other events can occur, and then the data you requested shows up. Unless you want your program to freeze until it gets the data you requested, you have to postpone processing the result with a callback.

Upvotes: 1

Related Questions