QBluetoothSocketPrivate::_q_readNotify() 14 错误

QBluetoothSocketPrivate::_q_readNotify() 14 error

我编写了一个简单的应用程序来从我的电脑(Linux、Debian)访问我的智能手机的 PBAP。

我看到我智能手机的所有服务,我也可以连接(智能手机收到配对请求)。但几秒钟后我收到以下错误:

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

有人知道如何解决吗?

这是我调用的函数:

        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()));
        }

谢谢。

在此处阅读 QBluetoothSocketPrivate::_q_readNotify() 后:

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();
    }
}

您的设备似乎正在断开连接并相应地显示该错误。