summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/bluez
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-08-31 14:56:58 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-09-14 12:15:04 +0000
commitba0988639b7951798002be10d6868718d56141f6 (patch)
tree7d4ac2c429d9b1291fdeefad7cf53ef07eb1f585 /src/bluetooth/bluez
parentaf07a801cb85094d2ab4a45244d5172e64f8ff7b (diff)
Implement handling of BTLE Battery services
Since BlueZ 5.48 battery services are no longer exposed via the generic GATT interface but have their own dedicated Battery1 interface. This patch transforms the dedicated interface back into the previous behavior. Essentially we are emulating the old interface to ensure that the QLowEnergyService user does not have to distinguish. Fixes: QTBUG-70222 Change-Id: Ib9fef41cf16f7562f169f51ee45b19f52de6a0c0 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/bluetooth/bluez')
-rw-r--r--src/bluetooth/bluez/battery1.cpp26
-rw-r--r--src/bluetooth/bluez/battery1_p.h51
-rw-r--r--src/bluetooth/bluez/bluez.pri2
-rwxr-xr-xsrc/bluetooth/bluez/generate1
-rw-r--r--src/bluetooth/bluez/org.bluez.Battery1.xml7
5 files changed, 87 insertions, 0 deletions
diff --git a/src/bluetooth/bluez/battery1.cpp b/src/bluetooth/bluez/battery1.cpp
new file mode 100644
index 00000000..f23cc205
--- /dev/null
+++ b/src/bluetooth/bluez/battery1.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -p battery1_p.h:battery1.cpp org.bluez.Battery1.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2018 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "battery1_p.h"
+
+/*
+ * Implementation of interface class OrgBluezBattery1Interface
+ */
+
+OrgBluezBattery1Interface::OrgBluezBattery1Interface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+OrgBluezBattery1Interface::~OrgBluezBattery1Interface()
+{
+}
+
diff --git a/src/bluetooth/bluez/battery1_p.h b/src/bluetooth/bluez/battery1_p.h
new file mode 100644
index 00000000..035382df
--- /dev/null
+++ b/src/bluetooth/bluez/battery1_p.h
@@ -0,0 +1,51 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.8
+ * Command line was: qdbusxml2cpp -p battery1_p.h:battery1.cpp org.bluez.Battery1.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2018 The Qt Company Ltd.
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef BATTERY1_P_H
+#define BATTERY1_P_H
+
+#include <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * Proxy class for interface org.bluez.Battery1
+ */
+class OrgBluezBattery1Interface: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.bluez.Battery1"; }
+
+public:
+ OrgBluezBattery1Interface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr);
+
+ ~OrgBluezBattery1Interface();
+
+ Q_PROPERTY(uchar Percentage READ percentage)
+ inline uchar percentage() const
+ { return qvariant_cast< uchar >(property("Percentage")); }
+
+public Q_SLOTS: // METHODS
+Q_SIGNALS: // SIGNALS
+};
+
+namespace org {
+ namespace bluez {
+ typedef ::OrgBluezBattery1Interface Battery1;
+ }
+}
+#endif
diff --git a/src/bluetooth/bluez/bluez.pri b/src/bluetooth/bluez/bluez.pri
index 4201f104..af7f0e0c 100644
--- a/src/bluetooth/bluez/bluez.pri
+++ b/src/bluetooth/bluez/bluez.pri
@@ -22,6 +22,7 @@ HEADERS += bluez/manager_p.h \
bluez/gattchar1_p.h \
bluez/gattdesc1_p.h \
bluez/gattservice1_p.h \
+ bluez/battery1_p.h \
bluez/bluez_data_p.h \
bluez/hcimanager_p.h \
bluez/remotedevicemanager_p.h \
@@ -51,6 +52,7 @@ SOURCES += bluez/manager.cpp \
bluez/gattchar1.cpp \
bluez/gattdesc1.cpp \
bluez/gattservice1.cpp \
+ bluez/battery1.cpp \
bluez/hcimanager.cpp \
bluez/remotedevicemanager.cpp \
bluez/bluetoothmanagement.cpp
diff --git a/src/bluetooth/bluez/generate b/src/bluetooth/bluez/generate
index 73d3b3f5..b3db63ff 100755
--- a/src/bluetooth/bluez/generate
+++ b/src/bluetooth/bluez/generate
@@ -24,4 +24,5 @@ qdbusxml2cpp -p obex_transfer1_bluez5_p.h:obex_transfer1_bluez5_p.h org.bluez.ob
qdbusxml2cpp -p gattchar1_p.h:gattchar1.cpp org.bluez.GattCharacteristic1.xml
qdbusxml2cpp -p gattdesc1_p.h:gattdesc1.cpp org.bluez.GattDescriptor1.xml
qdbusxml2cpp -p gattservice1_p.h:gattservice1.cpp org.bluez.GattService1.xml
+qdbusxml2cpp -p battery1_p.h:battery1.cpp org.bluez.Battery1.xml
diff --git a/src/bluetooth/bluez/org.bluez.Battery1.xml b/src/bluetooth/bluez/org.bluez.Battery1.xml
new file mode 100644
index 00000000..efa0309d
--- /dev/null
+++ b/src/bluetooth/bluez/org.bluez.Battery1.xml
@@ -0,0 +1,7 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.bluez.Battery1">
+ <property name="Percentage" type="y" access="read"></property>
+ </interface>
+</node>