summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/android
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2016-08-04 12:54:48 +0200
committerAlex Blasche <alexander.blasche@qt.io>2017-01-23 07:15:40 +0000
commit72f7df5738a8ed168c9d10a0474a5c42999250e8 (patch)
tree3522515e42f657b43e7057e78bde4edc5e0129e2 /src/bluetooth/android
parent8a0d14f4933bcd933e1258731472479ec33ade6a (diff)
Android: Beginnings of Android Bluetooth Peripheral support
Focus is on the Java side of things. The Gatt server & LE advertiser can be started and stopped. This patch builds the foundation for future changes. The C++ side is only very rudimentary and a lot of debugging helper are left inside the new code sections. Change-Id: Ic56da3ec6471ccb438fc2088fbf5eeb3053d5cf1 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src/bluetooth/android')
-rw-r--r--src/bluetooth/android/lowenergynotificationhub.cpp17
-rw-r--r--src/bluetooth/android/lowenergynotificationhub_p.h2
2 files changed, 13 insertions, 6 deletions
diff --git a/src/bluetooth/android/lowenergynotificationhub.cpp b/src/bluetooth/android/lowenergynotificationhub.cpp
index 2a6cdce3..219124fa 100644
--- a/src/bluetooth/android/lowenergynotificationhub.cpp
+++ b/src/bluetooth/android/lowenergynotificationhub.cpp
@@ -53,18 +53,25 @@ QReadWriteLock LowEnergyNotificationHub::lock;
Q_DECLARE_LOGGING_CATEGORY(QT_BT_ANDROID)
-LowEnergyNotificationHub::LowEnergyNotificationHub(
- const QBluetoothAddress &remote, QObject *parent)
+LowEnergyNotificationHub::LowEnergyNotificationHub(const QBluetoothAddress &remote,
+ bool isPeripheral, QObject *parent)
: QObject(parent), javaToCtoken(0)
{
QAndroidJniEnvironment env;
- const QAndroidJniObject address =
+
+ if (isPeripheral) {
+ qCDebug(QT_BT_ANDROID) << "Creating Android Peripheral/Server support for BTLE";
+ jBluetoothLe = QAndroidJniObject("org/qtproject/qt5/android/bluetooth/QtBluetoothLEServer",
+ "(Landroid/content/Context;)V", QtAndroidPrivate::context());
+ } else {
+ qCDebug(QT_BT_ANDROID) << "Creating Android Central/Client support for BTLE";
+ const QAndroidJniObject address =
QAndroidJniObject::fromString(remote.toString());
- jBluetoothLe = QAndroidJniObject("org/qtproject/qt5/android/bluetooth/QtBluetoothLE",
+ jBluetoothLe = QAndroidJniObject("org/qtproject/qt5/android/bluetooth/QtBluetoothLE",
"(Ljava/lang/String;Landroid/content/Context;)V",
address.object<jstring>(),
QtAndroidPrivate::activity() ? QtAndroidPrivate::activity() : QtAndroidPrivate::service());
-
+ }
if (env->ExceptionCheck() || !jBluetoothLe.isValid()) {
env->ExceptionDescribe();
diff --git a/src/bluetooth/android/lowenergynotificationhub_p.h b/src/bluetooth/android/lowenergynotificationhub_p.h
index a957aac0..cfee78e4 100644
--- a/src/bluetooth/android/lowenergynotificationhub_p.h
+++ b/src/bluetooth/android/lowenergynotificationhub_p.h
@@ -67,7 +67,7 @@ class LowEnergyNotificationHub : public QObject
{
Q_OBJECT
public:
- explicit LowEnergyNotificationHub(const QBluetoothAddress &remote,
+ explicit LowEnergyNotificationHub(const QBluetoothAddress &remote, bool isPeripheral,
QObject *parent = 0);
~LowEnergyNotificationHub();