Unsolved QBluetooth: can we define custom serial protocol?
-
Greetings,
I am using QBluetooth class to communicate with HC-05 Bluetooth using the android app. I have got a question that how can we define the custom serial mode (baud, data bits, stop bit, even or odd parity)?Looking forward to your kind response.
Best Regards,
Ahsan -
Hi. Bluetooth (in my modest opinion), is similar at a tcp connection so you can't define baud rate and it is not necessary.
You can define your custom protocol without any problem.
In the past I have implemented bluetooth connection in Linux, Windows (not necessaary because after pairing you will have a virtual com port so you can use the device easely using the standar com port object) and Android.
I haven't use the Qt bluetooth stack, I have created a component in java for Android and a wrapper for bluetooth library for Linux.
It was more easely than use the Qt cluetooth stack. -
@mrdebug thank you for the considerate reply. Does that mean I can send the data via Bluetooth (connected to Arduino) using any baud rate, 1 or 2 stop bit(s) and parity? and Qt Bluetooth will automatically adapt to it?
-
Which arduino adapter are you using?
If you are using an uart to bluetooth adapter, Arduino side you have to set the arduino baud rate according with the bluetooth adapter. Such as a gprs modem.
When your byte stream in entered in the bluetooth tube the baud rate, stop bit and parity have no sense. -
@mrdebug I am using Arduino DUE with HC-05 SPP Bluetooth. The current serial mode is 38400, 8-n-1.
-
Perfect, it is a AT commands based device.
As first step I suggest you to pair it with a Windows machine.
After tah you will have a new virtual com port in the WIndows machine.
As second step, using a software such as putty you can open the new virtual com port. The baud rate Windows side will be ignored.
Now you can excange data betwneen arduino and Windows.
As third step you can start to implement a your custom protocol and to manage the bluetooth connection directly in your software. -
@mrdebug thank you so much. for the sake of clarification, I do not need to define baud rate, parity, start/stop bits in Qt.