summaryrefslogtreecommitdiff
path: root/src/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/CMakeLists.txt2
-rw-r--r--src/bluetooth/qbluetoothuuid.h9
-rw-r--r--src/bluetooth/qbluetoothuuid_darwin.mm46
3 files changed, 57 insertions, 0 deletions
diff --git a/src/bluetooth/CMakeLists.txt b/src/bluetooth/CMakeLists.txt
index 45cddda3..a603e3c9 100644
--- a/src/bluetooth/CMakeLists.txt
+++ b/src/bluetooth/CMakeLists.txt
@@ -190,6 +190,7 @@ elseif(MACOS)
qbluetoothserviceinfo_macos.mm
qbluetoothsocket_macos.mm qbluetoothsocket_macos_p.h
qlowenergycontroller_darwin.mm qlowenergycontroller_darwin_p.h
+ qbluetoothuuid_darwin.mm
DEFINES
QT_OSX_BLUETOOTH
LIBRARIES
@@ -216,6 +217,7 @@ elseif(IOS)
qbluetoothsocket_dummy.cpp qbluetoothsocket_dummy_p.h
qlowenergycontroller_darwin.mm qlowenergycontroller_darwin_p.h
darwin/btperipheralmanager.mm darwin/btperipheralmanager_p.h
+ qbluetoothuuid_darwin.mm
DEFINES
QT_IOS_BLUETOOTH
LIBRARIES
diff --git a/src/bluetooth/qbluetoothuuid.h b/src/bluetooth/qbluetoothuuid.h
index 6ee1f26f..0978780d 100644
--- a/src/bluetooth/qbluetoothuuid.h
+++ b/src/bluetooth/qbluetoothuuid.h
@@ -12,6 +12,10 @@
#include <QtCore/QDebug>
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+Q_FORWARD_DECLARE_OBJC_CLASS(CBUUID);
+#endif
+
QT_BEGIN_NAMESPACE
#if QT_BLUETOOTH_REMOVED_SINCE(6, 6)
@@ -376,6 +380,11 @@ public:
quint128 toUInt128() const;
#endif
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QBluetoothUuid fromCBUUID(CBUUID *cbUuid);
+ CBUUID *toCBUUID() const Q_DECL_NS_RETURNS_AUTORELEASED;
+#endif
+
static QString serviceClassToString(ServiceClassUuid uuid);
static QString protocolToString(ProtocolUuid uuid);
static QString characteristicToString(CharacteristicType uuid);
diff --git a/src/bluetooth/qbluetoothuuid_darwin.mm b/src/bluetooth/qbluetoothuuid_darwin.mm
new file mode 100644
index 00000000..056a2666
--- /dev/null
+++ b/src/bluetooth/qbluetoothuuid_darwin.mm
@@ -0,0 +1,46 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "darwin/btutility_p.h"
+
+#include "qbluetoothuuid.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \brief Constructs a new QBluetoothUuid, containing a copy of the \a cbUuid CBUUID.
+
+ \note this function is only available on Apple platforms.
+
+ \since 6.6
+ \ingroup platform-type-conversions
+*/
+QBluetoothUuid QBluetoothUuid::fromCBUUID(CBUUID *cbUuid)
+{
+ if (!cbUuid)
+ return {};
+
+ return DarwinBluetooth::qt_uuid(cbUuid);
+}
+
+/*!
+ \brief Creates a CBUUID from a QBluetoothUuid.
+
+ The resulting CBUUID is autoreleased.
+
+ \note this function is only available on Apple platforms.
+
+ \since 6.6
+ \ingroup platform-type-conversions
+*/
+
+CBUUID *QBluetoothUuid::toCBUUID() const
+{
+ const auto cbUuidGuard = DarwinBluetooth::cb_uuid(*this);
+ // cb_uuid returns a strong reference (RAII object). Let
+ // it do its job and release, but we return auto-released
+ // CBUUID, as documented.
+ return [[cbUuidGuard.data() retain] autorelease];
+}
+
+QT_END_NAMESPACE