From 2aa2a2c7e893a456be4fffdc8ae96810c3517e9a Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 22 Jun 2017 15:48:48 +0200 Subject: Adjust pingpong example to Android UUID SDP discovery bug Task-number: QTBUG-61392 Change-Id: Ie2173b57093db9285e8fc90dbec66f81b002f7c6 Reviewed-by: Oliver Wolff Reviewed-by: Timur Pocheptsov --- examples/bluetooth/pingpong/pingpong.cpp | 11 +++++++++++ examples/bluetooth/pingpong/pingpong.h | 3 ++- examples/bluetooth/pingpong/pingpong.pro | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/bluetooth/pingpong/pingpong.cpp b/examples/bluetooth/pingpong/pingpong.cpp index ab6ba8c7..58d5ff2f 100644 --- a/examples/bluetooth/pingpong/pingpong.cpp +++ b/examples/bluetooth/pingpong/pingpong.cpp @@ -40,6 +40,9 @@ #include "pingpong.h" #include +#ifdef Q_OS_ANDROID +#include +#endif PingPong::PingPong(): m_serverInfo(0), socket(0), discoveryAgent(0), interval(5), m_resultLeft(0), m_resultRight(0), @@ -253,8 +256,16 @@ void PingPong::startClient() connect(discoveryAgent, SIGNAL(finished()), this, SLOT(done())); connect(discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceScanError(QBluetoothServiceDiscoveryAgent::Error))); +#ifdef Q_OS_ANDROID //see QTBUG-61392 + if (QtAndroid::androidSdkVersion() >= 23) + discoveryAgent->setUuidFilter(QBluetoothUuid(androidUuid)); + else + discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#else discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); +#endif discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); + //! [Searching for the service] setMessage(QStringLiteral("Starting server discovery. You are the right player")); // m_role is set to 2 if it is a client diff --git a/examples/bluetooth/pingpong/pingpong.h b/examples/bluetooth/pingpong/pingpong.h index 650cd597..21c9ef1c 100644 --- a/examples/bluetooth/pingpong/pingpong.h +++ b/examples/bluetooth/pingpong/pingpong.h @@ -48,7 +48,8 @@ #include #include -static const QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString serviceUuid(QStringLiteral("e8e10f95-1a70-4b27-9ccf-02010264e9c9")); +static QString androidUuid(QStringLiteral("c9e96402-0102-cf9c-274b-701a950fe1e8")); class PingPong: public QObject { diff --git a/examples/bluetooth/pingpong/pingpong.pro b/examples/bluetooth/pingpong/pingpong.pro index 07675f27..aa79212e 100644 --- a/examples/bluetooth/pingpong/pingpong.pro +++ b/examples/bluetooth/pingpong/pingpong.pro @@ -2,6 +2,7 @@ TEMPLATE = app TARGET = pingpong QT += quick bluetooth +android: QT += androidextras # Input SOURCES += main.cpp \ -- cgit v1.2.3