aboutsummaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate_game/deviceinfo.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/heartrate_game/deviceinfo.py')
-rw-r--r--examples/bluetooth/heartrate_game/deviceinfo.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/bluetooth/heartrate_game/deviceinfo.py b/examples/bluetooth/heartrate_game/deviceinfo.py
new file mode 100644
index 000000000..5fd5c3270
--- /dev/null
+++ b/examples/bluetooth/heartrate_game/deviceinfo.py
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+import sys
+
+from PySide6.QtCore import QObject, Property, Signal
+
+from heartrate_global import simulator
+
+
+class DeviceInfo(QObject):
+
+ deviceChanged = Signal()
+
+ def __init__(self, device):
+ super().__init__()
+ self.m_device = device
+
+ def device(self):
+ return self.m_device
+
+ def setDevice(self, device):
+ self.m_device = device
+ self.deviceChanged.emit()
+
+ @Property(str, notify=deviceChanged)
+ def deviceName(self):
+ if simulator():
+ return "Demo device"
+ return self.m_device.name()
+
+ @Property(str, notify=deviceChanged)
+ def deviceAddress(self):
+ if simulator():
+ return "00:11:22:33:44:55"
+ if sys.platform == "Darwin": # workaround for Core Bluetooth:
+ return self.m_device.deviceUuid().toString()
+ return self.m_device.address().toString()