From cb1403c242e5ca9033a4390b058b194157b9bcc9 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Wed, 28 Jun 2017 14:34:17 +0200 Subject: Adjust btchat example to Android UUID SDP discovery bug Task-number: QTBUG-61392 Change-Id: Ia7d680a40b0fe359dfb5fe69ad9f3e83fe9ccb7d Reviewed-by: Timur Pocheptsov --- examples/bluetooth/btchat/btchat.pro | 1 + examples/bluetooth/btchat/chat.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) (limited to 'examples/bluetooth') 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 #include +#ifdef Q_OS_ANDROID +#include +#endif + #include #include 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(); -- cgit v1.2.3