I'm trying to read the CTS characteristic from a BLE server (an iOS device) and part of the requirement from Apple is that the server and client be paired and bonded before the CTS information is available.
What I'm trying to establish is the chain of events that will occur in terms of pair/bonding, connection, discovery and then reading of the server CTS information, so that I can ensure that my code knows when the CTS info is available. The two scenarios are (obviously)
- Client and server not known to each other, so that pairing/bonding needs to occur first before the CTS info can be read
- Client and server have previously paired and bonded, and so do not need to go through this process first before the CTS can be read
I've based my code on the cts_peripheral example, but in this one, a button press is used to trigger the CTS read. In my code, I want to set a flag to indicate that the CTS is available so that I can read the characteristic info, but what I'm seeing is:
- connection and discovery will occur regardless of whether the devices are paired/bonded.
- pairing/bonding seems to occur as the last process in the chain of events
So I can't see clearly see where in the chain of events the CTS info is actually available in these two scenarios. If I set my flag after pairing/bonding has been completed, then it works OK in the first scenario. But the callback for pairing/bonding doesn't get called in the second scenario, so I then need to set my flag somewhere in the GATT discovery call backs. But these seem to get called prior to the pairing/bonding occurring, so this means I attempt to read the CTS info prior to pairing/bonding and the process fails.
Can anyone help me get a clearer path forward here?
Cheers,
Mike