SteffenH
SteffenH

Reputation: 107

QBluetoothSocketPrivate::_q_readNotify() 14 error

i write an simple application to access the PBAP of my smartphone from my pc (Linux, Debian).

I see all services of my smartphone, i can also connect (the smartphone gets a pairing request). But after a few seconds i get the following error:

qt.bluetooth.bluez: void QBluetoothSocketPrivate::_q_readNotify() 14 error: -1 "Die Ressource ist zur Zeit nicht verfügbar"

Has anybody an idea how to fix it?

This is the function i call:

        void ServiceDiscoveryDialog::startClient(const QBluetoothServiceInfo &remoteService)
    {


        // Connect to service
        socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
        qDebug() << "Create socket";
        socket->connectToService(remoteAddress, 1);
        qDebug() << "ConnectToServiceTry done";

        connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
        connect(socket, SIGNAL(connected()), this, SLOT(connected()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
        }

Thank you.

Upvotes: 1

Views: 843

Answers (1)

DYangu
DYangu

Reputation: 619

After reading about QBluetoothSocketPrivate::_q_readNotify() here:

http://code.qt.io/cgit/qt/qtconnectivity.git/tree/src/bluetooth/qbluetoothsocket_bluez.cpp?h=5.3.2

void QBluetoothSocketPrivate::_q_readNotify()
{
    Q_Q(QBluetoothSocket);
    char *writePointer = buffer.reserve(QPRIVATELINEARBUFFER_BUFFERSIZE);
//    qint64 readFromDevice = q->readData(writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE);
    int readFromDevice = ::read(socket, writePointer, QPRIVATELINEARBUFFER_BUFFERSIZE);
    buffer.chop(QPRIVATELINEARBUFFER_BUFFERSIZE - (readFromDevice < 0 ? 0 : readFromDevice));
    if(readFromDevice <= 0){
        int errsv = errno;
        readNotifier->setEnabled(false);
        connectWriteNotifier->setEnabled(false);
        errorString = qt_error_string(errsv);
        qCWarning(QT_BT_BLUEZ) << Q_FUNC_INFO << socket << "error:" << readFromDevice << errorString;
        if(errsv == EHOSTDOWN)
            q->setSocketError(QBluetoothSocket::HostNotFoundError);
        else
            q->setSocketError(QBluetoothSocket::UnknownSocketError);

        q->disconnectFromService();
    }
    else {
        emit q->readyRead();
    }
}

It seems your device is loosing connection and showing that error accordingly.

Upvotes: 2

Related Questions