Add handling for the identity packet to be split across two messages.
Summary: If the identity packet is split across two packets, then save it until we get a notification that more data is available for reading over the bluetooth link. Test Plan: Connect a phone and laptop over Bluetooth, and verify that both the phone and laptop are able to see each other, and that either side can start and successfully go through the pairing process. Reviewers: #kde_connect, mtijink Reviewed By: #kde_connect, mtijink Subscribers: mtijink, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17789
This commit is contained in:
parent
bafef14c52
commit
97551d09ff
2 changed files with 24 additions and 3 deletions
|
@ -166,9 +166,20 @@ void BluetoothLinkProvider::clientIdentityReceived()
|
|||
if (!socket) return;
|
||||
|
||||
QByteArray identityArray;
|
||||
while (socket->bytesAvailable() > 0 || !identityArray.contains('\n')) {
|
||||
|
||||
if (socket->property("identityArray").isValid()) {
|
||||
identityArray = socket->property("identityArray").toByteArray();
|
||||
}
|
||||
|
||||
while (!identityArray.contains('\n') && socket->bytesAvailable() > 0) {
|
||||
identityArray += socket->readAll();
|
||||
}
|
||||
if (!identityArray.contains('\n')) {
|
||||
// This method will get retriggered when more data is available.
|
||||
socket->setProperty("identityArray", identityArray);
|
||||
return;
|
||||
}
|
||||
socket->setProperty("identityArray", QVariant());
|
||||
|
||||
disconnect(socket, SIGNAL(readyRead()), this, SLOT(clientIdentityReceived()));
|
||||
|
||||
|
@ -248,9 +259,19 @@ void BluetoothLinkProvider::serverDataReceived()
|
|||
if (!socket) return;
|
||||
|
||||
QByteArray identityArray;
|
||||
while (socket->bytesAvailable() > 0 || !identityArray.contains('\n')) {
|
||||
if (socket->property("identityArray").isValid()) {
|
||||
identityArray = socket->property("identityArray").toByteArray();
|
||||
}
|
||||
|
||||
while (!identityArray.contains('\n') && socket->bytesAvailable() > 0) {
|
||||
identityArray += socket->readAll();
|
||||
}
|
||||
if (!identityArray.contains('\n')) {
|
||||
// This method will get retriggered when more data is available.
|
||||
socket->setProperty("identityArray", identityArray);
|
||||
return;
|
||||
}
|
||||
socket->setProperty("identityArray", QVariant());
|
||||
|
||||
disconnect(socket, SIGNAL(readyRead()), this, SLOT(serverDataReceived()));
|
||||
disconnect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(connectError()));
|
||||
|
|
|
@ -31,7 +31,7 @@ BluetoothPairingHandler::BluetoothPairingHandler(DeviceLink* deviceLink)
|
|||
, m_status(NotPaired)
|
||||
{
|
||||
m_pairingTimeout.setSingleShot(true);
|
||||
m_pairingTimeout.setInterval(30 * 1000); //30 seconds of timeout
|
||||
m_pairingTimeout.setInterval(pairingTimeoutMsec());
|
||||
connect(&m_pairingTimeout, &QTimer::timeout, this, &BluetoothPairingHandler::pairingTimeout);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue