QBluetoothLeUart/qbluetoothleuartdevice.cpp
Dorian Zedler 60d10f056b
- update example
- some fixes
- added QBluetoothLeUartDeviceModel for use with QML
2020-10-11 15:49:51 +02:00

37 lines
857 B
C++

#include "qbluetoothleuartdevice.h"
QBluetoothLeUartDevice::QBluetoothLeUartDevice(QBluetoothDeviceInfo info, QObject *parent) : QObject(parent)
{
this->bluetoothDeviceInfo = info;
}
QString QBluetoothLeUartDevice::getName()
{
if(bluetoothDeviceInfo.isValid())
return bluetoothDeviceInfo.name();
else
return "";
}
QBluetoothDeviceInfo QBluetoothLeUartDevice::getDevice()
{
return bluetoothDeviceInfo;
}
QString QBluetoothLeUartDevice::getAddress()
{
#ifdef Q_OS_MAC
// workaround for Core Bluetooth:
return bluetoothDeviceInfo.deviceUuid().toString();
#else
return bluetoothDeviceInfo.address().toString();
#endif
}
void QBluetoothLeUartDevice::setDevice(QBluetoothDeviceInfo device)
{
if(device != this->bluetoothDeviceInfo) {
bluetoothDeviceInfo = device;
emit deviceChanged();
}
}