Im running Qt on ubuntu. I want to write a simple program that recieves a line from android device(this device already has a program to connect and send info) over Bluetooth. How do i start a bluetooth server in QT? I tried to find examples, but all of them act like a client that looks for connection. My program should wait for connection and once it gets a connection, it waits for incoming messages and reads them.
-
Might the QSerialPort be enough for your purposes? – ni1ight Oct 25 '17 at 09:08
-
I have never done that, how to make Serial port communicate with bluetooth? – TheBullet0070 Oct 25 '17 at 09:34
2 Answers
The Bluetooth API provides connectivity between Bluetooth enabled devices.
You can find Bluetooth examples in Qt website here, also see some Bluetooth examples in Qt Creator examples.
Bluetooth chat example
and Bluetooth file transfer example
is works for you.

- 4,119
- 8
- 43
- 66
-
I tried this chat example. I deleted everything except for server. When i try to connect, the server drops the connection, so i think this does not work for me as it is, it needs some rework, and i dont know what to change there – TheBullet0070 Oct 25 '17 at 07:20
The Bluetooth chat example may be used with various Bluetooth terminal applications. For example you could compile the Qt BT chat example on your computer and connect to it from your cell phone running a Bluetooth Terminal application.
In order to do that all that is needed is to change the UUID values as described here and here. That is, in the chatserver.cpp
file of the example one needs to change:
static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
Becomes:
static const QLatin1String serviceUuid("00001101-0000-1000-8000-00805F9B34FB");
You may also want to do the same thing in the chat.cpp if you are planning on using the client mode as well (in this case make sure to change the reversed UUID also, as described in this bug).

- 1
- 2