Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have noticed similar behavior as well. Something is not right. I was using "rfcomm connect ..." to establish a connection to a bluetooth device, and I would say roughly a third of the time it either did not work or said the device was still in use after closing the connection.
To work around this I edited the file /etc/bluetooth/rfcomm and added an entry for my device using something like this
Code:
rfcomm0 {
#Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device XX:XX:XX:XX:XX:XX;
# RFCOMM channel for the connection
channel 1;
# Description of the connection
comment "Name of Device";
}
Of course you should alter the rfcomm number if you don't want to call it rfcomm0, and specify the proper channel if necessary (otherwise try 1). Now to initialize the connection
Code:
sudo rfcomm bind 0
Note, the "0" is for rfcomm0, not the channel. Then when you are finished,
Code:
sudo rfcomm release 0
I don't know what is different about doing it this way as opposed to using "rfcomm connect ..." but this way seems to work a bit more reliably for some reason.
Yeah. Using bind / release in this case would be a workaround and not a solution. A proper solution would be to have "rfcomm connect" work as it should. I would suggest filing a bug report against the BlueZ package through your distribution.
If anyone does know of a proper solution or patch, I would certainly like to know as well. I often have to tear down rfcomm connections or even restart the bluetooth daemon in order to get things working.
You mention using bluetooth in a server to listen for connections. If you do not necessarily know what bluetooth devices are in the vicinity, then adding them to rfcomm.conf in advance would definitely be problematic. If this is the case you could try writing a script to automate this - run "hcitool scan" to get the MAC address(es), i.e. parse this output and add these devices to rfcomm.conf. Certainly inconvenient, but might work.
Also judging from your response in your other link, you may not know the proper channel. I don't know the reliability of connecting to multiple channels at once - you would need "sdptool browse" to find the proper channel for what you are trying to connect for. I cannot really guide you in how to do this, because I don't know what kind of channels you need. (For example, sdbtool tells me that my phone can broadcast NMEA data on Channel 5, so when I want to see GPS info I add channel 5 in rfcomm.conf.)
Another thought - does your server's bluetooth chip use closed firmware? That might have something to do with those TIOCGSERIAL issues, though that's probably a kernel ( > 3.6 ) problem. Then again, you say that when a device connects fine, you still see that message.
Last edited by ordealbyfire83; 10-20-2017 at 10:43 PM.
You mention using bluetooth in a server to listen for connections. If you do not necessarily know what bluetooth devices are in the vicinity, then adding them to rfcomm.conf in advance would definitely be problematic. If this is the case you could try writing a script to automate this - run "hcitool scan" to get the MAC address(es), i.e. parse this output and add these devices to rfcomm.conf. Certainly inconvenient, but might work.
This can work but I prefer to remove the connection properly.
Quote:
Also judging from your response in your other link, you may not know the proper channel. I don't know the reliability of connecting to multiple channels at once - you would need "sdptool browse" to find the proper channel for what you are trying to connect for. I cannot really guide you in how to do this, because I don't know what kind of channels you need. (For example, sdbtool tells me that my phone can broadcast NMEA data on Channel 5, so when I want to see GPS info I add channel 5 in rfcomm.conf.)
I create my own services with sdptool. I have an script that removes the default services, then creates others with serial profile. Also I change the Uuid of every sdptool service I create, so they can be distinguished separately from the Android device (client). When this is done, I do as many "rfcomm listen" as services I have.
I do this because from Android, the way of connecting to a bluetooth service is by Uuid, not by channel number. The number of the channel doesn't really matter.
Quote:
Another thought - does your server's bluetooth chip use closed firmware? That might have something to do with those TIOCGSERIAL issues, though that's probably a kernel ( > 3.6 ) problem. Then again, you say that when a device connects fine, you still see that message.
I have tried with other bluetooth devices and the problem is still there...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.