QBluetoothSocket::readyRead signal is not emitted
-
Hello,
This is regarding QBluetoothSocket. I am able to connect to the device. I am trying to send data to device and read it.
The read api returns 0.
The readyRead signal is not emitted.
Any suggestion / pointer will be useful.
Thanks
void ConnectedToServer()
{qDebug() << "Connected server peername " << mBluetoothSocket->peerName(); qDebug() << "Connected server peer port" << mBluetoothSocket->peerPort(); qDebug() << "Connected server peer Address" << mBluetoothSocket->peerAddress(); QString message; message = "test"; qDebug() << "Sending message " << message; sendMessage(message); mBluetoothSocket->waitForReadyRead(-1); readSocket();
}
void readSocket()
{
if (!mBluetoothSocket)
return;
qDebug() << "readSocket" << mBluetoothSocket->peerName();
qint64 ret;
char data[256] = {0};
ret = mBluetoothSocket->read(data,100);
qDebug() << "Data " << data;
qDebug() << " read ret " << ret;
while (mBluetoothSocket->canReadLine()) {
QByteArray line = mBluetoothSocket->readLine();
qDebug() << "readSocket data " << line.constData();
}
}void sendMessage(const QString &message)
{
qDebug() << "sendMessage";
qint64 ret;
QByteArray text = message.toUtf8() + '\n';
qDebug() << "sendMessage" << text;
ret = mBluetoothSocket->write(text);
qDebug() << "Return value" << ret;
}