THIS IS NOT STRAIGHTFORWARD –NOT EVEN A LITTLE
One thing that we’ll learn about Core Bluetooth (which can also apply to other types of asynchronous communication), is that nothing is really direct or straightforward.
That means that we can’t just ask a CBCentralManager
instance for its CBPeripherals
. We need to ask the manager to discover the Peripherals, and, possibly, build up its own list; which we can then query.
The same goes for Services. We can’t just ask a CBPeripheral
object for its CBService
instances. We have to ask it to discover its Services.
After that, each Service needs to discover its Characteristics. That said, just to add insult to injury, we don’t ask the Service to discover its Characteristics; we ask the Peripheral to do so, on behalf of the Service.
Once the Characteristics have been discovered, then we can finally aggregate the Peripheral device.
We did just enough on the Peripheral side to give the Central something to find.
The Central, however, has its work cut out for it…
Read more