Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Unable to connect to bluetooth device
RohitIti last edited by RohitIti
I am using btscanner qt example to connect to other bluetooth device to transfer data.
Currently the example contains only displaying of bluetooth device and upon selecting the device we will get all the services provided by the remote device.
I added my code to create an rfcomm connection inside addService function of service.cpp
Code is as follows:
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
qDebug() << serviceInfo.serviceUuid();
if(socket != NULL)
qDebug() << "Create socket" << serviceInfo.device().address().toString();
qDebug() << "ConnectToService done";
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
with this code i am getting proper selected bluetooth device name but the serviceUUid is all zeros.
and also i get the error saying qt.bluetooth.android: device is offline.
later i change serviceDiscoveryAgent.start() function to serviceDiscoveryAgent.start(QBluetoothServiceDiiscoveryAgent::DiscoveryMode::FullDiscovery)
this time i get the same result but the error is " qt.bluetooth.android: unknown host state "
I am running the code in qt 5.5.
I am flashing the apk on nexus 7 tablet and samsung mobile. am getting same result.
I am assuming that i am missing to add certain code but unable to find
Any solutions ?
Please don't post the same question in multiple sub-forums, one is enough.
Closing this one.