summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-06-28 14:34:17 +0200
committerAlex Blasche <alexander.blasche@qt.io>2017-06-28 13:30:06 +0000
commitcb1403c242e5ca9033a4390b058b194157b9bcc9 (patch)
treedb52a883364e96209494379053541ff757e0b400 /examples
parent9fcdb6bc25ee55bd0900b35734c58c9313f5b974 (diff)
Adjust btchat example to Android UUID SDP discovery bug
Task-number: QTBUG-61392 Change-Id: Ia7d680a40b0fe359dfb5fe69ad9f3e83fe9ccb7d Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/bluetooth/btchat/btchat.pro1
-rw-r--r--examples/bluetooth/btchat/chat.cpp14
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/bluetooth/btchat/btchat.pro b/examples/bluetooth/btchat/btchat.pro
index 08fdd4a7..6ecae4c7 100644
--- a/examples/bluetooth/btchat/btchat.pro
+++ b/examples/bluetooth/btchat/btchat.pro
@@ -2,6 +2,7 @@ TEMPLATE = app
TARGET = btchat
QT = core bluetooth widgets
+android: QT += androidextras
SOURCES = \
main.cpp \
diff --git a/examples/bluetooth/btchat/chat.cpp b/examples/bluetooth/btchat/chat.cpp
index 51a2d4ed..929a42e4 100644
--- a/examples/bluetooth/btchat/chat.cpp
+++ b/examples/bluetooth/btchat/chat.cpp
@@ -49,11 +49,18 @@
#include <qbluetoothdeviceinfo.h>
#include <qbluetoothlocaldevice.h>
+#ifdef Q_OS_ANDROID
+#include <QtAndroidExtras/QtAndroid>
+#endif
+
#include <QTimer>
#include <QDebug>
static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
+#ifdef Q_OS_ANDROID
+static const QLatin1String reverseUuid("c8e96402-0102-cf9c-274b-701a950fe1e8");
+#endif
Chat::Chat(QWidget *parent)
: QDialog(parent), currentAdapterIndex(0), ui(new Ui_Chat)
@@ -170,7 +177,14 @@ void Chat::connectClicked()
localAdapters.at(currentAdapterIndex).address();
RemoteSelector remoteSelector(adapter);
+#ifdef Q_OS_ANDROID
+ if (QtAndroid::androidSdkVersion() >= 23)
+ remoteSelector.startDiscovery(QBluetoothUuid(reverseUuid));
+ else
+ remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid));
+#else
remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid));
+#endif
if (remoteSelector.exec() == QDialog::Accepted) {
QBluetoothServiceInfo service = remoteSelector.service();