Native bluetooth communication

Jef Driesen jef at libdivecomputer.org
Wed May 7 00:16:54 PDT 2014


Hi,

The last few days, I received several questions related to the status of 
native bluetooth communication. In order to avoid having to repeat 
myself, let's give a small overview of the current status.

A while ago, I have been prototyping a native bluetooth communication 
backend for libdivecomputer. The goal is to be able to replace the 
serial emulation in the future. The main reason behind this effort is 
that the current situation, where we rely on serial emulation, is less 
than ideal. It requires some setup by the end-user, and last but not 
least it doesn't appear to work very well on linux!

I have arrived at a point where I have a functional implementation for 
windows and linux. With functional, I mean I'm able to connect to the 
dive computer and successfully download dives. What is still missing is 
device discovery, which means you have to figure out the bluetooth 
address of the device manually. Certainly not perfect yet, but it does 
work!

I have attached the patches with my prototype code. These patches 
include the bluetooth communication code, together with the necessary 
changes to integrate it into the Shearwater Predator/Petrel backend (the 
same could be done for the Heinrichs Weikamp Frog too).

The linux and windows implementations are very similar because they both 
provide a socket interface [1,2]. (I actually spend most of the time 
debugging a failure on Windows. In the end, the problem turned out to be 
caused by a bug in the mingw header files, and not my code. The bug was 
already fixed upstream [3], but not yet included in the packages I was 
using.)

I'm now looking at Mac OS X support, but this appears to be much harder 
than I expected. The developer documentation [4] isn't very helpful. It 
contains lots of information, but appears to lack the info I'm looking 
after (e.g. how to connect to a device, send/receive data, etc). The 
fact that I don't have any experience with Objective-C code or the Mac 
framework doesn't really help either. So if anyone can provide some 
assistance here, that would be great! Ideally, I would like to avoid 
using Objective-C code completely and use the C api of the Mac framework 
instead.

Of course help is not limited to the Mac OS X part only. If you have 
some knowledge about bluetooth in general, or have some experience with 
the Windows/Linux bluetooth api's, then any help in that area is 
appreciated too!

[1] http://people.csail.mit.edu/albert/bluez-intro/
[2] 
http://msdn.microsoft.com/en-us/library/windows/desktop/aa362932%28v=vs.85%29.aspx
[3] http://sourceforge.net/p/mingw-w64/code/6249/
[4] 
https://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/Bluetooth/BT_Intro/BT_Intro.html

Jef
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-a-native-bluetooth-communication-module.patch
Type: text/x-diff
Size: 10118 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0006.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Update-the-msvc-project-file.patch
Type: text/x-diff
Size: 1746 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0007.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Add-a-bluetooth-transport-type.patch
Type: text/x-diff
Size: 779 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0008.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-Use-bluetooth-communication-for-the-Shearwaters.patch
Type: text/x-diff
Size: 4668 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0009.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-WIP-Bluetooth-address-translation.patch
Type: text/x-diff
Size: 1498 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0010.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-WIP-Device-discovery.patch
Type: text/x-diff
Size: 2919 bytes
Desc: not available
URL: <http://libdivecomputer.org/pipermail/devel/attachments/20140507/6a1b7d82/attachment-0011.patch>


More information about the devel mailing list