blob: 55dcf0e8fe619f28dd4adf4efdc9362873be3718 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "deviceinfo.h"
#include "heartrate-global.h"
#include <QtBluetooth/qbluetoothaddress.h>
#include <QtBluetooth/qbluetoothuuid.h>
using namespace Qt::StringLiterals;
DeviceInfo::DeviceInfo(const QBluetoothDeviceInfo &info):
m_device(info)
{
}
QBluetoothDeviceInfo DeviceInfo::getDevice() const
{
return m_device;
}
QString DeviceInfo::getName() const
{
if (simulator)
return u"Demo device"_s;
return m_device.name();
}
QString DeviceInfo::getAddress() const
{
if (simulator)
return u"00:11:22:33:44:55"_s;
#ifdef Q_OS_DARWIN
// workaround for Core Bluetooth:
return m_device.deviceUuid().toString();
#else
return m_device.address().toString();
#endif
}
void DeviceInfo::setDevice(const QBluetoothDeviceInfo &device)
{
m_device = device;
emit deviceChanged();
}
|