Bluetooth 2 Logo

Improving an SDK With Core Bluetooth – Conclusion

This entry is part 7 of 7 in the series Improving an SDK With Core Bluetooth

This was a relatively short exercise, compared to the first series, and we made all of the changes inside the SDK-src directory.

Here is our ending Repo tag.

IMPORTANT ERRATA

After the fact, I needed to make one change to the SDK.

The changes were made to the two error enums, here, and here.

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:

  1. 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.
  2. 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.
  3. The App is Pathetic
    Yeah…It’s just enough to show that the SDK works. We can do better.
  4. 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…