Hi, I'm having a problem with establishing a functioning SPP connection via RFCOMM. I've already had success using SPP-loopback.py with bluetoothctl, but I want to make a startup script that will automatically connect to a given bluetooth address. I've been attempting to follow the instructions as provided in the bluetooth guide but the problem I seem to be having is getting RFCOMM to handle the communication instead of the test-profile script since the New Connection message format from the script is appearing. I have been leaving the script running in the background with the & control operator so that SPP appears in the SDP. I also set up the RFCOMM listen command to run in the background so I can input the cat /dev/rfcomm0 command and view the strings sent from the BlueTerm App on an Android tablet. This is the point where I run into trouble since the last command returns:
cat: can't open 'rfcomm0': Connection refused
I figure this might be happening because the script is in control so I'm wondering if I'm not suppose to be running the script in the background and that there is another way to make the SPP profile appear in the SDP. What am I doing wrong here?
Thanks in advance,
I was able to establish an SPP connection to an Android phone (with Android 6.0 - Marshmallow). I tried to use Blueterm but I was not able to establish the connection with this app, I used instead another free app called Bluetooth SPP manager. These are the steps I took:
rfkill unblock bluetooth
# discover your phone and find its MAC address
# say yes to everything on your Edison and hit the pair button on your phone
sdptool add --channel=22 SP
rfcomm watch /dev/rfcomm0 22 > /dev/null &
# connect for your phone to the Edison establishing the SPP connection
When you want to close the connection follow these steps:
The Edison sometimes has issues if the connection is closed before the device is disconnected.
The steps you provided aren't working for me either. I am not able to connect to my Edison with either the Bluetooth spp pro app or Bluetooth SPP Manager. Both apps return a cannot connect to device error. I've tried different variations with the commands you gave me such as attempting to connect over channel 1 as well but that didn't either. Both apps still work with the SPP-loopback.py code. The device I'm testing on is the acer A1-840 and it's running Android version 4.4.4. Not sure if that helps with understanding what's going on.
I'm also unfamiliar with sdptool. Is the SP service already included on the Edison?
Even after making sure the Edison trusts the tablet I am running into the same result. The error message says "unable to connect to device". I followed the steps exactly as provided, except for the initial pairing process because both devices had already been paired and connected previously. The only difference I tried from Peter's instructions is changing the channel from 22 to 1. That didn't work either. This was first tested running version 120 on my edison board. After upgrading to the current version, 146, I restarted the whole process just as instructed with no difference in the result. I tried using channel 1 again, also to no avail. There is no difference in steps taken in comparison to Peter's instructions. Entering the final line returns "cat: can't open '/dev/rfcomm0': No such file or directory". I figure this error appears because no connection is made in the first place. Trusting the device after pairing didn't help either.
I'd firstly suggest you to update to the latest version of the Yocto image since you are using an outdated version. You can get the latest version in https://software.intel.com/en-us/iot/hardware/edison/downloads IoT - Intel® Edison Board Download | Intel® Developer Zone.
Regarding the issue you are currently experiencing, I found it very weird, I would suggest you to reflash your board but since you need to flash the latest version of the image, that should do it. Let us know if you see any difference when using the latest image.
Flashing the Edison with the latest image did not produce any different results for me.
Fortunately though, I've found an alternative for my application. Instead of using rfcomm, I've inserted my own code into SPP-loopback.py to read commands and make system calls to scripts that execute my commands.
For one of my commands, I put together a shell script that uses the ftp-client python executable from the bluez package's test folder. However, I had to find some help from the bluez developers to fix a bug in ftp-client. Should I make a separate post about the necessary changes made to ftp-client?
Here's a link to the correspondence for the patch in a mailing list:
http://www.spinics.net/lists/linux-bluetooth/msg65672.html Re: [PATCH] test: Fix ftp-client not printing progress — Linux Bluetooth
I'm not sure where the updated file can be found but at least the changes are listed. The patch will correct the keyErrors and valueError when running ftp-client. The original file is located in the test folder of the bluez package.