This was a relatively short exercise, compared to the first series, and we made all of the changes inside the
After the fact, I needed to make one change to the SDK.
The deal was that the protocol requirement had to declare the two
localizedDescription computed properties as
public, because they were actually being ignored.
Here’s what we learned:
- (LINK) We learned that the Peripheral manages all the state for the Services and Characteristics.
- (LINK) We learned that the Central does not automatically “mirror” the Peripheral. We always need to ask the Peripheral to keep us up to date.
- (LINK) We learned to capitalize on the SDK’s loose coupling to make a major behavioral change without touching any app code.
- (LINK) We learned that it is impractical (and inefficient) to use “ephemeral” connections. We should make a connection, and keep it.
- (LINK) We learned to use the reporting API in the Core Bluetooth Peripheral to acknowledge receipt of a question from the Central, and to wait for the acknowledgement from the Peripheral before assuming the send was successful.
- (LINK) We learned that Core Bluetooth doesn’t really have a timeout, and how to add our own.
- (LINK) We learned that when a Peripheral is “missing” (no longer reachable), we will get a
CBPeripheralDelegate.peripheral(_:, didModifyServices:)call, and we can use that to report a missing Peripheral (bit of a kludge).
- We learned to look for places to capture and report errors (no link).
This leaves us with the following TODO list:
- The iOS app doesn’t clean up after itself very well.
The Mac app closes all resource connections when it quits, but the iOS app can “hold the connection open.” That’s really something that would require work on the apps, as well as the SDK.
- We’re Not Sure Who’s Asking the Question.
It would be nice to have a label on the Peripheral screen that showed who was asking the question.
- The App is Pathetic
Yeah…It’s just enough to show that the SDK works. We can do better.
- We could explore Bluetooth “Classic” (BR/EDR) with this project.
We’re using BLE for this, and it’s really the perfect type of task for BLE, but this would also be something that could be done with Bluetooth “Classic.”
These require modification of the apps, themselves, and maybe some fairly fundamental SDK changes. This was a “low-hanging fruit” exercise. I’ll make the assumption that I’m starting to chip away at the “This barely scratches the surface of Core Bluetooth” TODO…