Bluetooth serial port question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bluetooth serial port question

Jump to solution
3,207 Views
patsandt
Contributor III

I'm trying to figure out how to get a bluetooth serial port connection from my iMX6 target (uname -a = 4.1.18-i.MX6-PD15.3.1 #1 SMP Wed Mar 1 13:14:14 MST 2017 armv71 GNU/Linux)

I have a WiLink8 module, but I'm using a USB bluetooth dongle from Plugable.

The device seems to come up okay and my Windows computer sees it and reports its services correctly.

I have successfully had the embedded device report that Serial Port is a service and windows reports that it is COM8.

I type "rfcomm listen xx:xx:xx:xx:xx:xx" on the iMX6 and then use TeraTerm to open a terminal to COM8.

iMX6 reports a connection is created on /dev/rfcomm0.

I can type on the iMX6 console, apparently to the PC. I can type in TeraTerm, apparently to the iMX6. However, I can not see the iMX6 typing on the PC and cannot see the PC typing on the iMX6. Note that I'm not seeing "garbage" on either side. However, to be safe, I set the TeraTerm baud rate to 9600, which is the default baud rate for bluetooth spp (I think).

Any suggestions as to how I can get to the point where I can have text show up on both sides?

This is just in preparation for sending text back and forth under program control.

Thanks for any hints.  serial console bluetooth ‌

Labels (1)
0 Kudos
1 Solution
2,704 Views
patsandt
Contributor III

Okay, I got it working.

I connect to my console for the iMX6. For me that is COM6 on the PC. I use Tera Term.

After logging in as root, I ran a script: script contents =

hciconfig hci0 down
systemctl start bluetooth.service
sleep 1
hciconfig hci0 class 0x110100
hciconfig hci0 name javelin-bt
hciconfig hci0 up
sdptool del 0x10000
sdptool del 0x10001
sdptool del 0x10002
sdptool del 0x10003
sdptool del 0x10004
sdptool add --channel=1 SP
hciconfig hci0 piscan
Here is the explanation:
Line 1: I don't think you need to take it down, but just in case you are running a connection, I took hci0 down.
Line 2: start bluetooth service
Line 3: It seems to take a little time to get the service up.
Line 4: set the class type to include serial port. Note this seems to put in other non-serial port things too.
Line 5: set the name so I can recognize the device on the PC
Line 6: bring it back up now that the details are set.
Lines 7-11: remove any old services, including the non-serial port ones. Previously I had seen duplicates after next line.
Line 12: add the serial port service.
Line 13: make the box discoverable.
Next: "listen" (but not with the listen command) on rfcomm. This makes the /dev/rfcomm0 device show up in /dev.

rfcomm watch /dev/rfcomm0 <chan> screen /dev/rfcomm0 115200
On the PC: add the device. View properties and use the identified com port to connect: I use Tera Term and just open with my default settings of 115200 8N1.
Screen starts running in the COM6 Tera Term. Connection is running on COM8 also. However, in order to see what I was typing, I changed the Terminal settings in both to echo. I also adjusted the line ending types: Auto and CR/LF. All combined, I can type on one terminal and have it appear in the other. It is bidirectional.
I hope I've included enough details to make someone else's job less frustrating.

View solution in original post

0 Kudos
3 Replies
2,705 Views
patsandt
Contributor III

Okay, I got it working.

I connect to my console for the iMX6. For me that is COM6 on the PC. I use Tera Term.

After logging in as root, I ran a script: script contents =

hciconfig hci0 down
systemctl start bluetooth.service
sleep 1
hciconfig hci0 class 0x110100
hciconfig hci0 name javelin-bt
hciconfig hci0 up
sdptool del 0x10000
sdptool del 0x10001
sdptool del 0x10002
sdptool del 0x10003
sdptool del 0x10004
sdptool add --channel=1 SP
hciconfig hci0 piscan
Here is the explanation:
Line 1: I don't think you need to take it down, but just in case you are running a connection, I took hci0 down.
Line 2: start bluetooth service
Line 3: It seems to take a little time to get the service up.
Line 4: set the class type to include serial port. Note this seems to put in other non-serial port things too.
Line 5: set the name so I can recognize the device on the PC
Line 6: bring it back up now that the details are set.
Lines 7-11: remove any old services, including the non-serial port ones. Previously I had seen duplicates after next line.
Line 12: add the serial port service.
Line 13: make the box discoverable.
Next: "listen" (but not with the listen command) on rfcomm. This makes the /dev/rfcomm0 device show up in /dev.

rfcomm watch /dev/rfcomm0 <chan> screen /dev/rfcomm0 115200
On the PC: add the device. View properties and use the identified com port to connect: I use Tera Term and just open with my default settings of 115200 8N1.
Screen starts running in the COM6 Tera Term. Connection is running on COM8 also. However, in order to see what I was typing, I changed the Terminal settings in both to echo. I also adjusted the line ending types: Auto and CR/LF. All combined, I can type on one terminal and have it appear in the other. It is bidirectional.
I hope I've included enough details to make someone else's job less frustrating.
0 Kudos
2,704 Views
patsandt
Contributor III

Thanks for your response. /dev/rfcomm0 reports its baudrate as 9600. My console (where listen is running) is 115200. Not sure that matters, but just thought I'd mention it.

0 Kudos
2,704 Views
b36401
NXP Employee
NXP Employee

First please check baudrate and other options with "stty -F /dev/rfcomm0" command.
And set right options if necessary.

Have a great day,
Victor

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos