From 8b9235b64ee108c5fde725c2ce21f10e32965fc6 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Mon, 23 Sep 2024 21:07:52 +0000 Subject: [PATCH] Fixing bluetooth under QT6/OpenSUSE Tumbleweed It looks like this has never worked under QT6, the implementation was inconsistent with the QT5 behaviour. Given that the QT5 behaviour works with the shipped Android app, I've tweaked the QT6 to be functionally equivalent to the QT5 implementations. https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/600#note_1018493 @diamnew if you are able to build and test this; that would be a great help. --- .../bluetooth/connectionmultiplexer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/backends/bluetooth/connectionmultiplexer.cpp b/core/backends/bluetooth/connectionmultiplexer.cpp index 6b1191efd..6f1c0729f 100644 --- a/core/backends/bluetooth/connectionmultiplexer.cpp +++ b/core/backends/bluetooth/connectionmultiplexer.cpp @@ -133,7 +133,7 @@ bool ConnectionMultiplexer::tryParseMessage() message_uuid_raw.data[i] = header[3 + i]; } #else - message_uuid_raw = qFromBigEndian(&header.data()[3]); + message_uuid_raw = qFromLittleEndian(&header.data()[3]); #endif QBluetoothUuid message_uuid = QBluetoothUuid(message_uuid_raw); @@ -236,8 +236,8 @@ QBluetoothUuid ConnectionMultiplexer::newChannel() message[0] = MESSAGE_OPEN_CHANNEL; qToBigEndian(0, &message.data()[1]); - const auto channelBytes = new_id.toByteArray(); - message.append(channelBytes.constData(), 16); + const auto channelBytes = new_id.toBytes(); + message.append((const char *)&channelBytes, 16); to_write_bytes.append(message); // Add the channel ourselves @@ -345,8 +345,8 @@ void ConnectionMultiplexer::channelCanRead(QBluetoothUuid channelId) QByteArray message(3, (char)0); message[0] = MESSAGE_READ; qToBigEndian(2, &message.data()[1]); - const auto channelBytes = channelId.toByteArray(); - message.append(channelBytes.constData(), 16); + const auto channelBytes = channelId.toBytes(); + message.append((const char *)&channelBytes, 16); message.append(2, 0); qToBigEndian(read_amount, &message.data()[19]); to_write_bytes.append(message); @@ -375,8 +375,8 @@ void ConnectionMultiplexer::channelCanWrite(QBluetoothUuid channelId) message[0] = MESSAGE_WRITE; qToBigEndian(amount, &message.data()[1]); - const auto channelBytes = channelId.toByteArray(); - message.append(channelBytes.constData(), 16); + const auto channelBytes = channelId.toBytes(); + message.append((const char *)&channelBytes, 16); message.append(data); to_write_bytes.append(message); // Try to send it immediately @@ -413,8 +413,8 @@ void ConnectionMultiplexer::closeChannel(QBluetoothUuid channelId) message[0] = MESSAGE_CLOSE_CHANNEL; qToBigEndian(0, &message.data()[1]); - const auto channelBytes = channelId.toByteArray(); - message.append(channelBytes.constData(), 16); + const auto channelBytes = channelId.toBytes(); + message.append((const char *)&channelBytes, 16); to_write_bytes.append(message); // Try to send it immediately bytesWritten();