Writing an SDK With Core Bluetooth – 09 – Protocols

This entry is part 12 of 24 in the series Writing an SDK With Core Bluetooth

FIRST DRAFT OF THE PROTOCOLS FOR THE SDK

I have taken the liberty of creating a Swift file that will define the SDK.

I have removed the [extensive] comments, in order to simplify the visual impact. The original file will contain the comments.

Here is the tag for this step. We can consider this our “starting point.” At this point, all four apps are complete, and use a “dummy” mocked version of the SDK (no actual Bluetooth going on). We also have the first full draft of the SDK ready.

Read more

Writing an SDK With Core Bluetooth

This entry is part 1 of 24 in the series Writing an SDK With Core Bluetooth

INTRODUCTION

In the next series of posts, I will walk through designing and implementing a very simple SDK (Software Development Kit), using Apple’s Core Bluetooth API.

Core Bluetooth is Apple’s method for interacting with Bluetooth devices; in particular, with devices that use Bluetooth Low Energy (BLE).

In the latest versions of Apple’s operating systems, Core Bluetooth will also support “Bluetooth Classic.”

SUPPORTED ON ALL APPLE DEVICES

Every Apple device, including Macs, Watches, iPhones, iPads, iPods, and TVs, will support our code, if we use Core Bluetooth.

It’s possible that the new support for Bluetooth Classic in Core Bluetooth will allow us to also use “classic” Bluetooth on our devices.

In this initial series, I’ll just cover BLE, but I also want to explore BT Classic, using Core Bluetooth, in future series.

Read more

Writing an SDK With Core Bluetooth – 08 – The Object Model

This entry is part 11 of 24 in the series Writing an SDK With Core Bluetooth

MODELING THE SYSTEM

When I write SDKs, they tend to take the form of “object models.” That is, they provide a set of instances to the user, simulating/emulating the lower-level system (in the past, these have been class instances, which are objects, but these days, Swift can provide a number of choices. I’ll still call them “objects,” but they could be structs or enums).

Read more

Writing an SDK With Core Bluetooth – 07 – Properties

This entry is part 10 of 24 in the series Writing an SDK With Core Bluetooth

WHAT DOES THE USER NEED?

One of the biggest issues that I have with many SDKs, is that they slavishly model the system they are representing. This is often not the most optimal way to present functionality to the user.

Bluetooth is a highly flexible system. It is used by millions of devices that each may have a very different dynamic from other devices, and Bluetooth needs to serve them all, so it is rather complex and flexible. Core Bluetooth does a relatively good job of simplifying the standard, but it is still fairly byzantine.

I like to start with the user; ask them what they want, and then make the SDK an interpreter between them and the interface. Hide that Bluetooth complexity, and boil it down to the basics for the user.

Read more

Writing an SDK With Core Bluetooth – 06 – One Lump, Or Two?

This entry is part 9 of 24 in the series Writing an SDK With Core Bluetooth

RUBBER, MEET ROAD. ROAD, MEET RUBBER

Now, it’s time for us to make some fundamental decisions about the SDK we’ll be designing.

STATE-HEAVY VS. STATE-LITE

For example, the app will have two distinct states: Peripheral and Central. Should these be reflected as a single API, with a set state, or should we actually provide two APIs, with the app loading the appropriate one for the state?

Read more

Writing an SDK With Core Bluetooth – 05 – What’s Happening?

This entry is part 8 of 24 in the series Writing an SDK With Core Bluetooth

MAPPING OUT THE INTERACTION

At this point, we should review the behavior of the apps, determine what we think will be going on between the devices (in Bluetooth), and decide the structure of our exposed API.

We should start by mapping out a transaction diagram of messages and data.

Read more

Writing an SDK With Core Bluetooth – 04 – Let’s SDK!

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

THIS REFLECTS MY PERSONAL PHILOSOPHY

I just wanted to make it clear that the approach, and the resulting structure that we will develop, is based upon my own personal experience and viewpoint. There are definitely other ways to do this; some, a bit simpler.

But I have been writing SDKs since the 1980s, and I think that my point of view “has legs,” so to speak.

Read more