BlueZ Baudrate in Linux

Hello Everyone,

I’m nearing the final stages of a project and I can’t seem to find anything on Google to solve the latest problem. I have a bluesmirf connected to an STM32 parsing some sensor data packets. The STM32 sends one byte at a time and on my PC I can confirm that the data being sent via bluetooth is correct by viewing the bytes with Hterm and comparing those bytes to the data on the STM32. Now my application is Linux based (due to some quirks with Windows, go figure…). In C++ using Bluez with an rfcomm socket I can connect and receive data no problem, but the data is garbled… almost looks as if the bytes are shifted but I can’t confirm that. My thought is that the baudrate on the Linux side is too fast (i’m only sending data from the STM32 at a baud of 9600). Can anyone tell me how to change that rate? I’m assuming it would be something to put in the rfcomm.config file…

I’ll keep looking on Google but I figured I might get someone here who did something similar before.

Thanks and happy hacking!

OK! I found the issue.

Even though my Windows PC was receiving the correct bytes it must have been operating at a faster speed or the Virtual Com port was implementing flow control with the bluetooth dongle. I slowed down my microcontroller by sending a byte from my Linux machine (I view it as a CTS byte) the microcontroller sees that and then waits for my program to move to the very next function and connect to the socket. This takes a while and completely slows down my program (I’m guessing it’s due to opening the socket file descriptor?) but I’m getting correct data. Does anyone have any thoughts on how to speed this up? I would like to have at least one set of sensor data per second.

Any help is appreciated.

I’m using an RFCOMM socket and using the unistd read() write() functions.