Unable to integrate bluetooth device using corebluetooth

I've been attempting to integrate the Contour Next glucose meter using corebluetooth.

I found this blog post http://www.cocoasteam.com/?p=566 and accompanying github repo which looked very promising and followed the same approach. I made some good progress and I'm now able to discover the device and sync new readings from it.

I'm now stuck though. I want to fetch the historical records from the device and while I'm able to issue the command and get a response indicating that the request was handled I'm not able to actually receive the results from the device. It seems that I need to receive indications from the device but the corebluetooth API has a limitation that prevents me from doing so:

If the specified characteristic’s configuration allows both notifications and indications, calling this method enables notifications only.

(from https://developer.apple.com/documentation/corebluetooth/cbperipheral/1518949-setnotifyvalue)

Unfortunately the Contour Next allows both notifications and indications for blood glucose measurements which means that I'm not able to request the indications.

I did consider that perhaps indications weren't necessary but looking at an android implementation it does appear that they are after all https://github.com/jamorham/xDrip-plus/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Services/BluetoothGlucoseMeter.java#L227

So it seems that if I want to to integrate the Contour Next I need to find an alternative to corebluetooth (it doesn't look like corebluetooth is open source). Does anyone know of an alternative library or perhaps some way to work around the issue with corebluetooth?

It seems that I need to receive indications from the device but the
corebluetooth API has a limitation that prevents me from doing so

As this is a question about Apple’s APIs rather than Swift itself — you’d have exactly the same problem if you were using Objective-C — it’s kinda off topic for Swift Forums. You could try posting it over on the Core OS > Bluetooth of DevForums but, IMO, this is enough of an edge case to warrant you opening a DTS tech support incident and talking to our Bluetooth specialist.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Hey @eskimo, I did try DevForums but after several days the question hasn't even been moderated to be displayed. AFAICT DevForums is a ghost town - having it is probably providing less value than not having it at all (at least then folks would be directed somewhere they can get help). Fortunately I had more luck on StackOverflow.

2 Likes