Shearwater Petrel Bluetooth sync

424 views
Skip to first unread message

Linus Malmgren

unread,
Jan 8, 2015, 3:53:27 PM1/8/15
to subsurfac...@googlegroups.com
Hi!
I'm having trouble synchronizing logs from my Shearwater Petrel with subsurface (4.3-1~utopic) on my PC running Ubuntu 14.10. First of I'm paring using Ubuntu bluetooth gui and Shearwaters bluetooth dongle. PIN 0000. Second of I'm using "sudo rfcomm bind 0" with this in my /etc/bluetooth/rfcomm.conf (fake device adress):

rfcomm0 {
bind no;
device 00:11:22:33:44:55;
channel 1;
comment "Shearwater Petrel";
}

And last of I'm trying to sync log in subsurface using /dev/rfcomm0. But there is an error dialog showing in subsurface and this is shown in the output:

[1.586049] ERROR: Failed to receive the response packet. [in shearwater_common.c:314 (shearwater_common_transfer)]
[1.586100] ERROR: Failed to read the serial number. [in shearwater_petrel.c:169 (shearwater_petrel_device_foreach)]
[1.586161] ERROR: In/ut-fel (5) [in serial_posix.c:655 (serial_write)]
[1.586175] ERROR: Failed to send the request packet. [in shearwater_common.c:297 (shearwater_common_transfer)]
[1.586189] ERROR: In/ut-fel (5) [in serial_posix.c:202 (serial_close)]

My Petrel has been upgraded using another PC to the latest firmware.

Any thoughts on what I am doing wrong?

Anton Lundin

unread,
Jan 8, 2015, 5:49:11 PM1/8/15
to subsurfac...@googlegroups.com
I had some wierd problems with bluetooth on this MacBookPro8,2 using the internal bluetooth chip.
I found a old bluetooth dongle in a drawer, and it worked way better.

I also found that using rfcomm connect was way nicer than using bind.
connect establishes the connection right away, and leaves it open,
not waiting for someone to open the device and then connects.


//Anton

Linus Malmgren

unread,
Jan 9, 2015, 2:50:14 AM1/9/15
to subsurfac...@googlegroups.com
First I was using built in bluetooth in my computer. I couldn't even pair with the petrel. I'll try to find another dongle later on but this is done with Shearwater dongle:

linus@guppy:~$ sudo rfcomm release 0
linus@guppy:~$ sudo rfcomm 
linus@guppy:~$ sudo rfcomm connect 0
Can't connect RFCOMM socket: Connection refused

Anton Lundin

unread,
Jan 9, 2015, 9:20:58 AM1/9/15
to subsurfac...@googlegroups.com
Was the Petrel still in bluetooth mode?

I don't know if it exits bluetooth mode on disconnect, but it might.

Are you sure channel 1 is the right one?

I usually never bother figuring out which channel to use, and i never use the config file either, i just:
rfcomm connect /dev/rfcomm0 10:00:E8:C4:BE:C4

Remember, to use the right -i [hciX|bdaddr] if you have multiple bt-adapters in your computer.


//Anton

Linus Malmgren

unread,
Jan 9, 2015, 11:08:49 AM1/9/15
to subsurfac...@googlegroups.com
Yes, Petrel is still i bluetooth mode. When it's not all get this:

Can't connect RFCOMM socket: Host is down

No, I don't know what channel to use. I found channel 1 when randomly searching the internet. I Just tried to leave channel unspecified but there is no change in end results: Connections refused. Channel 1 seems to be default (channel line comment out from /etc/bluetooth/rfcomm.conf):

linus@guppy:~$ sudo rfcomm bind /dev/rfcomm0 00:13:43:0C:52:0A
linus@guppy:~$ sudo rfcomm
rfcomm0: 00:13:43:0C:52:0A channel 1 clean

I disabled PC built-in bluetooth in bios to avoid problems. Just the Shearwaters bluetooth in my system.

Unfortunate my older bluetooth dongle don't seem to work at all :-(

Do I need to clear bluetooth pairing in the Petrel?

/Linus

Linus Malmgren

unread,
Mar 3, 2015, 2:09:14 PM3/3/15
to subsurfac...@googlegroups.com
With the help of blueman and maybe the upgrade to 4.4.1 I managed to sync my logs. It's not at all a smooth process but I'm happy that it's finaly working :-D

/Linus

Benjamin Fogel

unread,
Mar 29, 2015, 1:01:48 PM3/29/15
to subsurfac...@googlegroups.com
What exactly did you do to solve this?

Linus Malmgren

unread,
Mar 30, 2015, 2:19:46 AM3/30/15
to subsurfac...@googlegroups.com
I started using Subsurface PPA-ubuntu-thing instead of Ubuntus own subsurface package. Also I tried blueman to setup the connection.

One thing I notice when I have preformed a couple of log downloads is that first try always seem to do a time out. The is some red text on the dive computer with a 30 sec auto close. I have to reset the connection and then it works.

/Linus

Benjamin Fogel

unread,
Mar 30, 2015, 11:51:55 AM3/30/15
to subsurfac...@googlegroups.com
I'm on Fedora 21. I am stuck a bit further back - I can't seem to pair the Petrel with the computer :(
It appears to connect for a few seconds and then disconnects.
If I try to connect from the command line, I get a message saying "Can't connect RFCOMM socket: Connection refused"

Jef Driesen

unread,
Mar 30, 2015, 1:00:45 PM3/30/15
to subsurfac...@googlegroups.com
On 30-03-15 17:51, Benjamin Fogel wrote:
> I'm on Fedora 21. I am stuck a bit further back - I can't seem to pair the
> Petrel with the computer :(
> It appears to connect for a few seconds and then disconnects.
> If I try to connect from the command line, I get a message saying "Can't connect
> RFCOMM socket: Connection refused"

I suspect the problem is the bluetooth serial port emulation. Can you try my
prototype using native bluetooth communication. You can download it here:

http://www.libdivecomputer.org/builds/experimental/linux/universal-bluetooth

with some instructions here:

http://trac.libdivecomputer.org/ticket/12

If this works for you, then it's indeed the serial port emulation that's not
working. You're not the only one with this problem. I'm having issues as well,
but with to native bluetooth it works fine.

Jef

Benjamin Fogel

unread,
Mar 30, 2015, 2:11:45 PM3/30/15
to subsurfac...@googlegroups.com, j...@libdivecomputer.org
It appears that the problem is a bit more murky than I thought.

This is the output from the terminal:
./universal-bluetooth -v -l petrel.log -d petrel.xml -b petrel 00:13:43:0C:56:29
DATETIME 2015-03-30T18:09:50Z (1427738990)
VERSION 0.5.0-devel (d2eacc5c01d3ddaf01fb3e9899e209309e531914)
Opening the device (Shearwater Petrel, 00:13:43:0C:56:29).
INFO: Open: name=00:13:43:0C:56:29
ERROR: No such file or directory (2) [in ../../source/src/serial_posix.c:159 (serial_open)]
ERROR: Failed to open the serial port. [in ../../source/src/shearwater_common.c:46 (shearwater_common_open)]
../../source/examples/universal.c:681: Error opening device.
Result: Input/output error

I suspect that the fact that the computer won't give a stable connection with the Petrel is the root cause of this all.

Jef Driesen

unread,
Mar 31, 2015, 3:53:11 AM3/31/15
to subsurfac...@googlegroups.com, Benjamin Fogel
On 2015-03-30 20:11, Benjamin Fogel wrote:
> It appears that the problem is a bit more murky than I thought.
>
> This is the output from the terminal:
> ./universal-bluetooth -v -l petrel.log -d petrel.xml -b petrel
> 00:13:43:0C:56:29
> DATETIME 2015-03-30T18:09:50Z (1427738990)
> VERSION 0.5.0-devel (d2eacc5c01d3ddaf01fb3e9899e209309e531914)
> Opening the device (Shearwater Petrel, 00:13:43:0C:56:29).
> INFO: Open: name=00:13:43:0C:56:29
> ERROR: No such file or directory (2) [in
> ../../source/src/serial_posix.c:159 (serial_open)]
> ERROR: Failed to open the serial port. [in
> ../../source/src/shearwater_common.c:46 (shearwater_common_open)]
> ../../source/examples/universal.c:681: Error opening device.
> Result: Input/output error
>
> I suspect that the fact that the computer won't give a stable
> connection
> with the Petrel is the root cause of this all.

It looks like I uploaded a wrong version. One without the bluetooth
support enabled. Oops.

Try one of these (32 or 64 bit):

http://libdivecomputer.org/builds/experimental/linux/universal-bluetooth32
http://libdivecomputer.org/builds/experimental/linux/universal-bluetooth64

Jef

Benjamin

unread,
Mar 31, 2015, 4:33:24 AM3/31/15
to Jef Driesen, subsurfac...@googlegroups.com

Thank you. I'll try when I get back home from work.

Benjamin

Benjamin Fogel

unread,
Mar 31, 2015, 10:46:50 AM3/31/15
to subsurfac...@googlegroups.com, nys...@gmail.com, j...@libdivecomputer.org

The new output is this:
./universal-bluetooth64 -v -l petrel.log -d petrel.xml -b petrel 00:13:43:0C:56:29
DATETIME 2015-03-31T14:44:21Z (1427813061)
VERSION 0.5.0-devel (850e2d9c0d6b40f0f484cfb44b533014c0a07001)

Opening the device (Shearwater Petrel, 00:13:43:0C:56:29).
INFO: Connect: address=00:13:43:0C:56:29, port=1
ERROR: Connection refused (111) [in ../../source/src/bluetooth.c:320 (bluetooth_socket_connect)]
ERROR: Failed to connect. [in ../../source/src/shearwater_common.c:53 (shearwater_common_open)]
../../source/examples/universal.c:763: Error opening device.
Result: Input/output error

I'm running the latest firmware, and in Windows 7 it does connect to the Petrel.
Should the fact that it's the Petrel 2 make any difference? AFAIK the only difference is the compass, but I could be wrong.

Benjamin

Linus Malmgren

unread,
Apr 25, 2015, 12:45:24 PM4/25/15
to subsurfac...@googlegroups.com, j...@libdivecomputer.org, nys...@gmail.com
So I upgraded to Ubuntu 15.04 and it all stopped working :-(

I also tried Jef's universal-bluetooth and this is the result:
[0.000043] DATETIME 2015-04-25T16:36:07Z (1429979767)
[0.000104] VERSION 0.5.0-devel (850e2d9c0d6b40f0f484cfb44b533014c0a07001)
[0.000131] Opening the device (Shearwater Petrel, 00:13:43:0C:52:0A).
[0.000161] INFO: Connect: address=00:13:43:0C:52:0A, port=1
[4.331435] ERROR: Connection refused (111) [in ../../source/src/bluetooth.c:320 (bluetooth_socket_connect)]
[4.331472] ERROR: Failed to connect. [in ../../source/src/shearwater_common.c:53 (shearwater_common_open)]
[4.331504] ../../source/examples/universal.c:763: Error opening device.
[4.331523] Result: Input/output error

Is there any other ideas for a solution to this problem?
/Linus

Jef Driesen

unread,
Apr 28, 2015, 3:53:12 AM4/28/15
to subsurfac...@googlegroups.com, nys...@gmail.com, Linus Malmgren
On 2015-04-25 18:45, Linus Malmgren wrote:
> So I upgraded to Ubuntu 15.04 and it all stopped working :-(
>
> I also tried Jef's universal-bluetooth and this is the result:
> [0.000043] DATETIME 2015-04-25T16:36:07Z (1429979767)
> [0.000104] VERSION 0.5.0-devel
> (850e2d9c0d6b40f0f484cfb44b533014c0a07001)
> [0.000131] Opening the device (Shearwater Petrel, 00:13:43:0C:52:0A).
> [0.000161] INFO: Connect: address=00:13:43:0C:52:0A, port=1
> [4.331435] ERROR: Connection refused (111) [in
> ../../source/src/bluetooth.c:320 (bluetooth_socket_connect)]
> [4.331472] ERROR: Failed to connect. [in
> ../../source/src/shearwater_common.c:53 (shearwater_common_open)]
> [4.331504] ../../source/examples/universal.c:763: Error opening device.
> [4.331523] Result: Input/output error
>
> Is there any other ideas for a solution to this problem?

I don't know for sure, but possible reason might be:

* Bluetooth device not paired correctly. The native bluetooth prototype
does not setup the pairing automatically. This has to be done
separately.

* If you previously used the serial port emulation, then the bluetooth
stack might still be setup for the serial port emulation. I've no idea
whether that might interfere with the native bluetooth communication or
not. Maybe you can't use both at the same time?

* For native bluetooth, the port number (or channel number as it's
sometimes called) is hardcoded as 1. Maybe the port number is different
in some cases? (You'll need to recompile libdivecomputer to change
this.)

Jef

Benjamin

unread,
Apr 28, 2015, 6:15:42 AM4/28/15
to Jef Driesen, subsurfac...@googlegroups.com, Linus Malmgren

How can one "reset"  the bluetooth stack? Or should this be done automatically between system resets?

Jef Driesen

unread,
Apr 28, 2015, 6:54:04 AM4/28/15
to subsurfac...@googlegroups.com, Linus Malmgren
On 2015-04-28 12:15, Benjamin wrote:
> How can one "reset" the bluetooth stack? Or should this be done
> automatically between system resets?

I think it depends on how you configure it. If you run rfcomm manually:

rfcomm bind /dev/rfcomm0 <MAC>

then it won't persist across reboots. But if you configure it with a
/etc/bluetooth/rfcomm.conf file, then it will survive a reboot (because
that's the point of using a config file).

Jef

mark lee

unread,
Apr 28, 2015, 4:37:14 PM4/28/15
to subsurfac...@googlegroups.com, j...@libdivecomputer.org, nys...@gmail.com
The Petrel 2 has a Bluetooth LE compatible chip as well a new compass.  While it is compatible with Bluetooth 2.1, it's also compatible with BTLE. If the Bluetooth hardware that you're using is capable of BTLE, that may be part of the problem.  The dongles that Shearwater supplies do not have BTLE.

Mark (Shearwater Software Developer)

Benjamin

unread,
Apr 28, 2015, 11:33:14 PM4/28/15
to mark lee, subsurfac...@googlegroups.com, Jef Driesen

I'll look around for a dongle that does support LE... I've been trying with the dongle that came with my Petrel 2. It works using Shearwater Desktop in Windows on the same laptop, just not in Linux. The internal Bluetooth doesn't work with the Petrel 2 at all in Windows  (Samsung and their Bluetooth garbage...), so I tend to keep it disabled both there and in Linux.

Benjamin

Reply all
Reply to author
Forward
0 new messages