hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Bluetooth RFCOMM - Jessie

Sat Nov 14, 2015 10:30 am

I found problems trying to solve the following task:
I want to establish a Bluetooth connection (serial protocol / rfcomm) between a Bluetooth app on an Android phone and a Raspberry Pi.
Everything works fine using Rasbian Wheezy. But Rasbian Jessie shows various issues.
I did:
sudo apt-get install bluetooth bluez bluez-tools bluez-firmware blueman

No problems to pair my smartphone with RPi (using Bluetooth Manager on the GUI)

I created an RFCOMM configuration file (/etc/bluetooth/rfcomm.conf)
# RFCOMM configuration file.
rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device (smartphone)
device XX:XX:XX:XX:XX:XX;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "SmartPhone";
}

In /etc/bluetooth/main.conf I added (after [General])
DisablePlugins = pnat

Because no /dev/rfcomm0 was created after reboot (different to Wheezy!) I did manual binding:

sudo rfcomm bind hci0 XX:XX:XX:XX:XX:XX 1
Now /dev/rfcomm0 was created

(Additionally I tried to add
/usr/bin/rfcomm bind all & or
/usr/bin/rfcomm bind yes
in /etc/rc.local but /dev/rfcomm0 is not created either at boot time)

Now I tried:
pi@raspberrypi ~ $ sudo hciconfig hci0 piscan
pi@raspberrypi ~ $ sudo sdptool add sp

Using Wheezy I got as a reply: Serial Port service registered
But there is no answer using Jessie!

pi@raspberrypi ~ $ sudo rfcomm listen XX:XX:XX:XX:XX:XX 1
Waiting for connection on channel 1

Now with Wheezy it was possible to connect from my smartphone (for instance) with an app called “Bluetooth Terminal”.
I got the answer:
Connection from XX:XX:XX:XX:XX:XX to /dev/rfcomm20
Press CTRL-C for hangup

But using Jessie I was unable to connect the device

I am thankful for every idea to solve this annoying problem!
Hans

greycat
Posts: 5
Joined: Tue Nov 17, 2015 9:28 am

Re: Bluetooth RFCOMM - Jessie

Tue Nov 17, 2015 9:35 am

Same problem as I have. Currently I use a workaround.

Edit the /etc/rc.local and add >rfcomm bind 0 XX:XX:XX:XX:XX:XX 1< before the >exit 0<

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Tue Nov 17, 2015 6:18 pm

Thank you,
your adwise avoids manual binding, but a connection from an external device (i.e. Smartphone) is still not possible!

pi@raspberrypi ~ $ sudo hciconfig hci0 piscan
pi@raspberrypi ~ $ sudo sdptool add sp NO REPLY!
pi@raspberrypi ~ $ sudo rfcomm listen XX:XX:XX:XX:XX:XX
Waiting for connection on channel 1 UNABLE TO CONNECT DEVICE

Hans

greycat
Posts: 5
Joined: Tue Nov 17, 2015 9:28 am

Re: Bluetooth RFCOMM - Jessie

Wed Nov 18, 2015 9:04 am

I have some other problems with Jessie release and go back to Wheezy. So I don't have a Jessi test system.

Please test if your raspberry find the device: hcitool scan
You should get an output like that:
pi@raspi ~ $ hcitool scan
Scanning ...
XX:XX:XX:XX:XX:XX blub
XX:XX:XX:XX:XX:XX 747PRO GPS

Your device should be in the list. If not it is bluetooth on your device is not visible or deactivated. If it is found I think there is a problem with pairing or trust. You could check it with the nex test.

The second test you should do is: bluetoothctl
pi@raspi ~ $bluetoothctl
[NEW] Controller XX:XX:XX:XX:XX:XX pi [default]
Then you get a prompt [bluetooth]#. On this prompt put in these commands:
[bluetooth]#power on
[bluetooth]#discoverable on
[bluetooth]#agent on
[bluetooth]#default-agent
[bluetooth]#pairable on

After that:
[bluetooth]# scan on
Output should be like:
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[NEW] Device XX:XX:XX:XX:XX:XX 747PRO GPS
[CHG] Device XX:XX:XX:XX:XX:XX LegacyPairing: yes

[bluetooth]# pair XX:XX:XX:XX:XX:XX
Attempting to pair with XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
[CHG] Device XX:XX:XX:XX:XX:XX Connected: no
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Request PIN code
[agent] Enter PIN code: "your pin"
[CHG] Device XX:XX:XX:XX:XX:XX Paired: yes
Pairing successful
[CHG] Device XX:XX:XX:XX:XX:XX Connected: no

[bluetooth]#trust XX:XX:XX:XX:XX:XX

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Wed Nov 18, 2015 11:09 am

Hi,
Thank you for your answer.
Pairing and trusting was already successful using the Bluetooth-Manager on the graphical screen.
But to make sure I repeated the whole procedure:

pi@raspberrypi ~ hcitool scan
Scanning ...
XX:XX:XX:XX:XX:XX Name_xxxxxx
pi@raspberrypi ~ $ bluetoothctl
[NEW] Controller YY:YY:YY:YY:YY:YY raspberrypi [default]
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# discoverable on
Changing discoverable on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# pairable on
Changing pairable on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller YY:YY:YY:YY:YY:3C Discovering: yes
[NEW] Device XX:XX:XX:XX:XX:XX Name_xxxxxx
[CHG] Device XX:XX:XX:XX:XX:XX UUIDs:
00001105-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
00001112-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
0000112d-0000-1000-8000-00805f9b34fb
0000112f-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
00001132-0000-1000-8000-00805f9b34fb
[CHG] Device XX:XX:XX:XX:XX:XX RSSI: -58
[CHG] Device XX:XX:XX:XX:XX:XX RSSI: -40
[bluetooth]# pair XX:XX:XX:XX:XX:XX
Attempting to pair with XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Connected: yes
Request confirmation
[agent] Confirm passkey 119058 (yes/no): yes
[CHG] Device XX:XX:XX:XX:XX:XX Modalias: bluetooth:v0075p0100d0200
[CHG] Device XX:XX:XX:XX:XX:XX UUIDs:
00001105-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
00001112-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
0000112d-0000-1000-8000-00805f9b34fb
0000112f-0000-1000-8000-00805f9b34fb
00001132-0000-1000-8000-00805f9b34fb
00001200-0000-1000-8000-00805f9b34fb
fbe4be12-374a-486b-a473-24e39408a24d
[CHG] Device XX:XX:XX:XX:XX:XX Paired: yes
Pairing successful
[CHG] Device XX:XX:XX:XX:XX:XX Connected: no
[bluetooth]# trust XX:XX:XX:XX:XX:XX
[CHG] Device XX:XX:XX:XX:XX:XX Trusted: yes
Changing XX:XX:XX:XX:XX:XX trust succeeded
[bluetooth]# quit
Agent unregistered
[DEL] Controller YY:YY:YY:YY:YY:YY raspberrypi [default]
pi@raspberrypi ~ $
pi@raspberrypi ~ $ sudo hciconfig hci0 piscan
pi@raspberrypi ~ $ sudo sdptool add sp
pi@raspberrypi ~ $ sudo rfcomm listen XX:XX:XX:XX:XX:XX
Waiting for connection on channel 1

The "only" but essential problem remains, it is not possible to establich a connection from the device XX:XX:XX:XX:XX:XX
As I reported, there is no problem using Wheezy!
Hans

greycat
Posts: 5
Joined: Tue Nov 17, 2015 9:28 am

Re: Bluetooth RFCOMM - Jessie

Wed Nov 18, 2015 5:52 pm

Hi,
that means your smartphone is found, is paired and is trusted but the connection can not established.
You could try to connect by
rfcomm connect 0 XX:XX:XX:XX:XX:XX

I suppose you will get a "Connection refused" or "Host down" ... but if not. Try
rfcomm connect 0 XX:XX:XX:XX:XX:XX &
sudo cat /dev/rfcomm0

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Wed Nov 18, 2015 10:35 pm

Hi,
I tried to connect and as expected it was not possible:

pi@raspberrypi ~ $ sudo rfcomm connect 0 XX:XX:XX:XX:XX:XX
Can't connect RFCOMM socket: Host is down
pi@raspberrypi ~ $

To make clear: I want to have RPi as a server, waiting to be connected by a client (smartphone)!
So, “rfcomm connect 0 XX:XX:XX:XX:XX:XX” cannot be the right approach!

I think it has to be done by “rfcomm listen ....” and I was not successful.
Obviously there is a bug in Jessie?!? But I don’t want to backtrack to Wheezy.
I spent a lot of time to find a solution (very inefficient!) and I am rather disappointed that the RPi Linux community has no suggestion.
Is there another forum I can ask for help?
Thank You!
Hans

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Sat Nov 28, 2015 1:02 am

Meanwhile I found a solution (there are some hints on several forum pages):
It is necessary to start bluetoothd with option "-C" or "--compat".
This is done by adding the option in /etc/systemd/system/bluetooth.target.wants/bluetooth.service:
"ExecStart=/usr/lib/bluetooth/bluetoothd -C".
Perhaps this instruction helps somebody having similar troubles with Jessie!
Hans

hdemel
Posts: 2
Joined: Sat Dec 26, 2015 9:17 pm

Re: Bluetooth RFCOMM - Jessie

Sat Dec 26, 2015 9:21 pm

Thanks for posting your solution! Unfortunately it didn't work for me, I don't know what they changed that broke rfcomm capability but I'm no longer able to communicate with my arduino through their HC-05 modules.

My current state is that when I try to run the command "sudo rfcomm bind all" I get a message stating that I'm: "Missing Dev parameters".

My rfcomm.conf file is appropriately configured, as is my pinches file. I can only assume this is due to the fact that blues-utils is no longer installable on Jessie. Very frustrating to see this question repeated so often online with no solution found or posted.

If I find a solution I will post back as this seems to be the thread that shows up at the top of my search list.

awesomo1337
Posts: 11
Joined: Mon Dec 14, 2015 8:08 pm

Re: Bluetooth RFCOMM - Jessie

Tue Dec 29, 2015 4:47 am

I am having the same issue with rfcomm. I have been trying to track down exactly what's causing it, but have been unsuccessful thus far. I am going back to Wheezy. I have spent far too much time messing with this.

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Thu Dec 31, 2015 2:44 pm

Perhaps I should mention that binding has to be done like:
sudo rfcomm bind 0 XX:XX:XX:XX:XX:XX
--> doing this installs /dev/rfcomm0
then:
sudo rfcomm hvi0 piscan
sudo sdptool add sp --> Serial Port Service registered
sudo rfcomm listen XX:XX:XX:XX:XX:XX 1 --> Waiting for connection on channel 1
--> Connection from XX:XX:XX:XX:XX:XX to dev/rfcomm20
--> Press CTRL-C for hangup

Best wishes for New Year 2016!
Hans

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Thu Dec 31, 2015 2:50 pm

I mispelt!
right: sudo hciconfig hci0 piscan

Hans

Cosmin
Posts: 22
Joined: Tue Dec 22, 2015 4:32 pm

Re: Bluetooth RFCOMM - Jessie

Mon Jan 04, 2016 8:33 pm

Hello Hans! I want to do the exact thing so I followed your steps. Now I want to ask you, if you would be so kind to answer, what do I do from there? I basically want to remote control my raspberry pi from my android phone. Please point me in the right direction.

hgstoehr
Posts: 12
Joined: Sat Jan 04, 2014 6:53 pm

Re: Bluetooth RFCOMM - Jessie

Wed Jan 06, 2016 4:16 pm

Hi Cosmin,
you are quite right!
My goal was/is to control a RPi remotly by an Android app. There is a nice example:
https://github.com/ericeche/AndroidArdu ... roidserial.
Instead of an Arduino with Bluetooth module data is sent to/from a RPi.
Hope you got the Information you expected!
Hans

Cosmin
Posts: 22
Joined: Tue Dec 22, 2015 4:32 pm

Re: Bluetooth RFCOMM - Jessie

Thu Jan 07, 2016 7:19 am

Thanks Hans! I will look into it as soon as I get home.

chuckh
Posts: 5
Joined: Sun Feb 15, 2015 7:19 pm

Re: Bluetooth RFCOMM - Jessie

Wed Jan 27, 2016 5:06 pm

I am trying to accomplish the same thing as the OP: talk to a Raspberry Pi from an Android phone serial application. In my case the Android app is https://play.google.com/store/apps/deta ... ller&hl=en This is my first effort at RPi Bluetooth and I am using the jessie version of raspian; uname -a reports
Linux raspberrypi 4.1.15+ #830 Tue Dec 15 16:58:28 GMT 2015 armv6l GNU/Linux

Here was a page I found useful: http://unix.stackexchange.com/questions ... t-on-linux

I am very close, but not quite there; see below.

After using

Code: Select all

sudo nano /etc/systemd/system/bluetooth.target.wants/bluetooth.service
to adjust the relevant line to read

Code: Select all

ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=sap --compat
and doing

Code: Select all

sudo systemctl daemon-reload
sudo service bluetooth restart
sudo service bluetooth status
● bluetooth.service - Bluetooth service
   Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled)
   Active: active (running) since Wed 2016-01-27 08:39:11 PST; 4min 11s ago
     Docs: man:bluetoothd(8)
 Main PID: 359 (bluetoothd)
   Status: "Running"
   CGroup: /system.slice/bluetooth.service
           └─359 /usr/lib/bluetooth/bluetoothd --noplugin=sap --compat

Jan 27 08:39:09 raspberrypi systemd[1]: Starting Bluetooth service...
Jan 27 08:39:10 raspberrypi bluetoothd[359]: Bluetooth daemon 5.23
Jan 27 08:39:11 raspberrypi bluetoothd[359]: Starting SDP server
Jan 27 08:39:11 raspberrypi bluetoothd[359]: Excluding (cli) sap
Jan 27 08:39:12 raspberrypi bluetoothd[359]: Bluetooth management interface 1.9 initialized
Jan 27 08:39:11 raspberrypi systemd[1]: Started Bluetooth service.
I found another step may be necessary. If you get this error

Code: Select all

sdptool browse local
Failed to connect to SDP server on FF:FF:FF:00:00:00: Permission denied
, do

Code: Select all

sudo chmod 777 /var/run/sdp
I use bluetoothctl to pair from the phone to the RPi. After pairing I use

Code: Select all

[bluetooth]# trust 14:89:FD:xx:xx:xx
Changing 14:89:FD:xx:xx:xx trust succeeded
[bluetooth]# show
Controller 00:1B:DC:xx:xx:xx
	Name: raspberrypi
	Alias: raspberrypi
	Class: 0x000000
	Powered: yes
	Discoverable: no
	Pairable: yes
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v1D6Bp0246d0517
	Discovering: no
[bluetooth]# info 14:89:FD:xx:xx:xx
Device 14:89:FD:xx:xx:xx
	Name: SPH-L710
	Alias: SPH-L710
	Class: 0x5a020c
	Icon: phone
	Paired: yes
	Trusted: yes
	Blocked: no
	Connected: no
	LegacyPairing: no
	UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
	UUID: OBEX Object Push          (00001105-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
	UUID: PANU                      (00001115-0000-1000-8000-00805f9b34fb)
	UUID: NAP                       (00001116-0000-1000-8000-00805f9b34fb)
	UUID: Handsfree Audio Gateway   (0000111f-0000-1000-8000-00805f9b34fb)
	UUID: Phonebook Access Server   (0000112f-0000-1000-8000-00805f9b34fb)
	UUID: Message Access Server     (00001132-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	Modalias: bluetooth:v0075p0100d0200
Choosing an arbitrary channel 22,

Code: Select all

sudo sdptool add --channel=22 SP
Serial Port service registered
sdptool browse local
Browsing FF:FF:FF:00:00:00 ...
Service RecHandle: 0x10000
Service Class ID List:
  "PnP Information" (0x1200)
Profile Descriptor List:
  "PnP Information" (0x1200)
    Version: 0x0103

[...]

Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10005
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 22
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Serial Port" (0x1101)
    Version: 0x0100
This will start the listener on /dev/rfcomm0, (I included the cat {} command so it will echo input to the console), and when I run the Android app it connects. We are almost there!

Code: Select all

sudo rfcomm watch 0 22 cat {}
Waiting for connection on channel 22
Connection from 14:89:FD:xx:xx:xx to /dev/rfcomm0
Press CTRL-C for hangup
*test*Disconnected
Waiting for connection on channel 22
Can't create RFCOMM TTY: Address already in use
Waiting for connection on channel 22
The above transcript shows success on the first connection: "*test*" is the data transmitted from the Android application. However there is still a flaw: after disconnecting (I stopped the Android app), I cannot reconnect: the disconnection did not clean up the /dev/rfcomm0 port.

Code: Select all

rfcomm -a
rfcomm0: 00:1B:DC:xx:xx:xx -> 14:89:FD:3xx:xx:xx channel 22 closed [reuse-dlc release-on-hup tty-attached]
This behavior is not completely consistent: occasionally I have seen the disconnect/reconnect cycle work ok.

This page https://communities.intel.com/thread/90 ... 0&tstart=0 (referring to the Intel Edison board, not RPi) reports that disconnecting with bluetoothctl is helpful because the "The Edison sometimes has issues if the connection is closed before the device is disconnected."

Any suggestions appreciated.

User avatar
Douglas6
Posts: 5221
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bluetooth RFCOMM - Jessie

Wed Jan 27, 2016 5:32 pm

I've successfully done very much the same thing, slightly differently, and had no problem reconnecting. One major difference was that I did not add the 'cat' command to rfcomm. Could you try it without?

chuckh
Posts: 5
Joined: Sun Feb 15, 2015 7:19 pm

Re: Bluetooth RFCOMM - Jessie

Sat Jan 30, 2016 4:44 pm

@Douglas6
That's an interesting test. I'd say I get roughly 80% failure rate with 'cat {}' in there, and about 10% failure rate without. A timing race maybe?

Another data point: the Android application seems to work perfectly when talking to an Ubuntu 14.04 desktop PC running bluez4. I transferred the same bluetooth USB dongle over so it is the same hardware there.

I have monitored debug output from bluetoothd and noticed that in bluez4 the phone disconnect is reported (via plugin/mgmtops.c). However in bluez5 there is no bluetoothd debug output when the phone disconnects -- regardless of whether rfcomm properly cleaned up or not.

Chuck

User avatar
Douglas6
Posts: 5221
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bluetooth RFCOMM - Jessie

Sat Jan 30, 2016 6:14 pm

My thinking was that 'cat' is holding on to the rfcomm channel a little too long. Can't explain the 10% failure rate, except to say that Bluetooth can be a little flakey. Is it better if you give it a minute or so to clean up, before reconnecting?

User avatar
Douglas6
Posts: 5221
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bluetooth RFCOMM - Jessie

Sun Jan 31, 2016 12:35 am

Just tried this again. Out of 50 attempts to reconnect as quickly as possible, 3 times it took 2 or 3 tries. I consider that pretty reasonable, and I'm unsure whether the Pi or the phone is to blame. Same Bluetooth app as you linked to.

chuckh
Posts: 5
Joined: Sun Feb 15, 2015 7:19 pm

Re: Bluetooth RFCOMM - Jessie

Thu Feb 04, 2016 7:45 am

No clarity on the occasional failure of rfcomm to close /dev/rfcomm0 when the remote device disconnects. Waiting for a long time (several minutes) after disconnecting does not seem to cause an automatic cleanup.

I was trying to work around this by using rfcomm listen inside a loop, instead of rfcomm watch. At the end of each pass through the loop (rfcomm listen exits after the disconnect) I would manually clean up the stale /dev/rfcomm0 device. However I can't figure out how to clean it up.

Code: Select all

sudo rfcomm release 0
returns silently, but the device still remains, and retrying the release gives an error:

Code: Select all

pi@raspberrypi:~ $ rfcomm -a
rfcomm0: 00:15:83:15:xx:xx -> 14:89:FD:3D:xx:xx channel 22 closed [reuse-dlc release-on-hup tty-attached]
pi@raspberrypi:~ $ sudo rfcomm release 0
Can't release device: Operation already in progress
I can remove the device node from the filesystem, but rfcomm0 still exists in rfcomm's mind:

Code: Select all

pi@raspberrypi:~ $ ls -l /dev/rfcomm0
crw-rw---- 1 root dialout 216, 0 Feb  3 21:38 /dev/rfcomm0
pi@raspberrypi:~ $ sudo rm /dev/rfcomm0
pi@raspberrypi:~ $ ls /dev/rf*
/dev/rfkill
pi@raspberrypi:~ $ sudo rfcomm listen 0 22
Waiting for connection on channel 22
Can't create RFCOMM TTY: Address already in use
I believe that the user-space bluez program rfcomm is calling the rfcomm kernel module and using ioctls to tell it to release the device. However the release does not succeed and I can't ever use rfcomm0 again (until reboot). This behavior seems to be different from what @douglas6 sees.

I suppose I could keep incrementing through rfcomm1, rfcomm2 ...

User avatar
Douglas6
Posts: 5221
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bluetooth RFCOMM - Jessie

Thu Feb 04, 2016 2:57 pm

I always have used the default channel 1. Not sure how that could make a difference. Maybe it's down to the dongle or the phone; I'm out of ideas.

chuckh
Posts: 5
Joined: Sun Feb 15, 2015 7:19 pm

Re: Bluetooth RFCOMM - Jessie

Thu Feb 04, 2016 4:32 pm

I was thinking I might be able to see some useful information in debugfs, although I am not very familiar with it:

Code: Select all

pi@raspberrypi:~ $ sudo ls -l /sys/kernel/debug/bluetooth
total 0
drwxr-xr-x 3 root root 0 Feb  3 23:25 hci0
-r--r--r-- 1 root root 0 Jan 30 09:17 l2cap
-rw-r--r-- 1 root root 0 Jan 30 09:17 l2cap_le_default_mps
-rw-r--r-- 1 root root 0 Jan 30 09:17 l2cap_le_max_credits
-r--r--r-- 1 root root 0 Feb  3 21:37 rfcomm
-r--r--r-- 1 root root 0 Feb  3 21:37 rfcomm_dlc
-r--r--r-- 1 root root 0 Jan 30 09:17 sco
As you can see, the relevant filenames exist, but are zero size.

Is there another step I have to do in order to make the bluetooth kernel modules write debug data?

Chuck

User avatar
Douglas6
Posts: 5221
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, USA

Re: Bluetooth RFCOMM - Jessie

Thu Feb 04, 2016 4:51 pm

For debugging, I've typically used hcidump

Code: Select all

sudo apt-get install bluez-hcidump
That will give you HCI events sent and received, not sure if that helps.

[EDIT: you've added the -d debug flag to the bluetoothd startup? ]

wurstsalat0815
Posts: 2
Joined: Sat Jun 25, 2016 2:07 pm

Re: Bluetooth RFCOMM - Jessie

Sat Jun 25, 2016 2:18 pm

Hi,

I am also having an issue when trying to connect a Bluetooth device with an Rapsi3. In My case a GPS dongle.

I also created an RFCOMM configuration file (/etc/bluetooth/rfcomm.conf)
# RFCOMM configuration file.
rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device (smartphone)
device XX:XX:XX:XX:XX:XX;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "GPS";
}

But the device /dev/rfcomm0 is not being created after reboot even though I followed Hans tipp to set the Bluetooth deamon to compatibility mode by adding the option in /etc/systemd/system/bluetooth.target.wants/bluetooth.service:
"ExecStart=/usr/lib/bluetooth/bluetoothd -C".

The manual binding using sudo rfcomm bind hci0 XX:XX:XX:XX:XX:XX 1 works fine.

Do I need an entry in /etc/rc.local to create the device at boot time?

Thanks in advance for help.
Wurstsalat

Return to “Troubleshooting”