1

I have an Android application which connects serially to my Raspberry Pi 3 over Bluetooth. Before development of my app, I tested the bluetooth on the pi with an application called Bluetooth Terminal. It worked perfectly. In order to "see" the data being sent over the serial channel, I would have to run:

$sudo rfcomm release 0
$sudo rfcomm bind hcio XX:XX:XX:XX:XX:XX 1
$sudo rfcomm listen XX:XX:XX:XX:XX:XX 0
Waiting for connection on channel 1
CTL^C to hang-up

Every time I disconnected the app, I would have to release the channel and then re-connect before I re-ran the Bluetooth Terminal app, and it work perfectly every time.

However, with my app that I have created, it says:

$sudo rfcomm release 0
$sudo rfcomm bind hcio XX:XX:XX:XX:XX:XX 1
$sudo rfcomm listen XX:XX:XX:XX:XX:XX 0
Waiting for connection on channel 1
Can't create RFCOMM TTY: Address already in use

I receive this error even after the release of the channel. I've tried:

$sudo rfcomm watch 0

Even that throws the same error.

1

I struggled with a similar issue, trying to get an Android phone to hold a connection to a PI 3 under Jessie. A combination of two tweaks moved me forward - after performing these and rebooting I could connect to the PI from the Bluetooth Terminal App on Android 6.

The words below are borrowed verbatim from the quoted sources and I am indebted to the authors.

================================

This is done by adding the option in /etc/systemd/system/bluetooth.target.wants/bluetooth.service: "ExecStart=/usr/lib/bluetooth/bluetoothd -C".

From <https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=125922>

================================

And:

=================================

Try creating a SP profile to the Pi. Edit the following file: sudo nano /etc/systemd/system/dbus-org.bluez.service

Find the following line and add a compatibility flag '-C' to the end: ExecStart=/usr/lib/bluetooth/bluetoothd -C

Additionally, add the following line after the above:

ExecStartPost=/usr/bin/sdptool add SP

Save and reboot. Try removing the device then repairing and trusting the device with bluetoothctl. Then connect to the device with terminal via:

sudo rfcomm watch hci0

From <Raspberry Pi 3 bluetooth pairing issue with tablet>

=======================================

  • For those of you who understand the dark and arcane world of Linux, you will observe that the two files I'm suggesting editing above ARE THE SAME FILE. Maybe someone else can explain the value of having file aliases. Also, the "add SP" in the second edit should almost certainly be a lower case "sp" (i.e. "add sp") where "sp" represents "serial profile". – Mike Pelton Mar 29 '17 at 9:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.