[GSoC] Native bluetooth support - weekly report

Claudiu Olteanu olteanu.vasilica.claudiu at gmail.com
Mon Jun 1 10:14:41 PDT 2015


Hi there,

Sorry for the long post. Hope you can bear with me. :-)

Here are some thinks I managed to do after the first week and
the ones that gave me some troubles.

The first encountered problems were when I tried to turn on
my Bluetooth device :-). Apparently there was something wrong
with my driver and after a clean installation I also observed
that my Bluetooth device was blocked in order to save some
battery energy. A simple usage of rfkill tool made this problem
go away.

I created a Qt project where new issues started to appear. In
the beginning I couldn't get access to the local device with
two of the latest qt versions (5.5.0 alpha and 5.5.0 beta).
The backend bluez wasn't loaded correctly and I couldn't figure
out why since there were no warnings/errors. I decided to use
an older version 5.4.1 that was installed directly from the
repository and it was stable.

Using it I managed to play a little with my local device. The
API can be easily used to power on/off or to change the host
mode (connectable/discoverable/discoverable limited inquiry).
I also added an extra Bluetooth device using an adapter to
see if I can switch from one to another.

The next step was scanning for nearby devices. I was
interested to see if I can discover the dive computers (OSTC2
and OSTC sport) received for the project.

I didn't have any problems and I quickly obtained information about
each device. Then I thought that I should step forward and try to pair
and to connect the devices. With the OSTC2 it was easy to do this
since it doesn't require a PIN code for pairing.

On the OSTC sport you have to enter a specific PIN code if
you want to pair the devices. I looked over Qt documentation
but I couldn't find anything about it. Each time I tried
to pair my local device with the OSTC sport using the Qt API,
I received an *"org.bluez.Error.AuthenticationFailed"* error.
I decided to try to pair the devices from the CLI using
bluetoothctl tool and I observed that if I try to connect the
devices without creating an agent first, it fails with the same
error. If I create an agent first, then it prompts for a PIN code.

I posted a message on interest at qt-project.org related to my problem
and I found out the following things:
- the Bluez 5 port is not 100% complete. There are some reported
issues with the functions I tried to use for pairing [1]. Therefore
I have to use BlueZ 4.X version
- the API doesn't allow you to specify a PIN code [2]. It uses
one generated randomly.
- they started to implement an agent in order to fix these
problems but they don't know when they will finish it.

While I was waiting for the response I manually paired the
devices and I started to use the QT Bluetooth API to search
for services exposed. I saw that the OSTC sport device exposes
only one service (Serial Port) and I couldn't figure out how to connect
to it. After some failed attempts I sent an email to the support team
of heinrichsweikamp.com. They told me that both devices provide a
virtual COM port and the OSTC 2 also has some more services but
 they can be used only with Bluetooth 4 on iOS and Android. They also
advised me to update the firmware and they sent me a documentation
about its external interface and how I can communicate via the virtual
COM port. I did the firmware upgrade and I read its documentation.

The Qt Bluetooth API has some functionalities which can be used
to connect to remote devices through a RFCOMM channel using the
Serial Port Profile. I managed to connect to the OSTC 2 device.

On the OSTC sport model I receive an error
*"qt.bluetooth: No port, no PSM, and no UUID provided, unable to connect". *

I also tried to connect to it using the bluetoothctl tool and it
fails:
*"Attempting to connect to 00:12:6F:2A:0B:6E*
*Failed to connect: org.bluez.Error.NotAvailable" .*

The interesting part is that I managed to download some dives from
it using an Android application and also using Subsurface 4.4.2 on
Windows. On my Linux distribution I couldn't figure out what causes
this problem.

Now I don't know what to do. Should I downgrade my BlueZ version
to 4.X and try to see if all of these problems are fixed? Should I
ignore for the moment the problems related to OSTCs device?

Also I would like to know if each vendor has its specific protocol
to communicate with the device via the virtual COM port, or there
is a standard. Is there a part/module in the project which I can
reuse for the communication?

I believe that I could expose to the UI the scanning results, some
functionalities which can be used to control the local Bluetooth
device, to connect to the listed devices and to use the old
implementation for communication (for Windows and Linux).


Have a nice week,
Claudiu

[1] - https://bugreports.qt.io/browse/QTBUG-38401
[2] - https://bugreports.qt.io/browse/QTBUG-42740
[3] -
http://www.stollmann.de/de/software/bluetooth-bluetooth-low-energy/terminal-io-profile.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150601/823ba105/attachment.html>


More information about the subsurface mailing list