@@ -63,7 +63,7 @@ Device::Device(const QString &deviceAddr, const QString &deviceName, QObject *pa
63
63
// Check address validity
64
64
if (m_bleDevice.isValid () == false )
65
65
{
66
- qWarning () << " Device() '" << m_deviceAddress << " ' is an invalid QBluetoothDeviceInfo..." ;
66
+ qWarning () << " Device() '" << getAddress () << " ' is an invalid QBluetoothDeviceInfo..." ;
67
67
}
68
68
69
69
// Database
@@ -111,7 +111,7 @@ Device::Device(const QBluetoothDeviceInfo &d, QObject *parent) : QObject(parent)
111
111
// Check address validity
112
112
if (m_bleDevice.isValid () == false )
113
113
{
114
- qWarning () << " Device() '" << m_deviceAddress << " ' is an invalid QBluetoothDeviceInfo..." ;
114
+ qWarning () << " Device() '" << getAddress () << " ' is an invalid QBluetoothDeviceInfo..." ;
115
115
}
116
116
117
117
// Database
@@ -358,7 +358,7 @@ void Device::setTimeoutTimer(int)
358
358
359
359
bool Device::getSqlDeviceInfos ()
360
360
{
361
- // qDebug() << "Device::getSqlDeviceInfos(" << m_deviceAddress << ")";
361
+ // qDebug() << "Device::getSqlDeviceInfos(" << getAddress() << ")";
362
362
return false ;
363
363
}
364
364
@@ -394,30 +394,60 @@ bool Device::isUpdating() const
394
394
395
395
bool Device::hasAddressMAC () const
396
396
{
397
- #if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS)
398
- return true ;
399
- #endif
397
+ if (m_deviceAddressMAC.size () == 17 ) return true ;
398
+ if (m_deviceAddress.size () == 17 ) return true ;
400
399
401
- return !m_deviceAddressMAC. isEmpty () ;
400
+ return false ;
402
401
}
403
402
404
403
QString Device::getAddressMAC () const
405
404
{
406
- #if !defined(Q_OS_MACOS) && !defined(Q_OS_IOS)
407
- return m_deviceAddress;
408
- #endif
405
+ if (m_deviceAddressMAC.size () == 17 ) return m_deviceAddressMAC;
406
+ if (m_deviceAddress.size () == 17 ) return m_deviceAddress;
409
407
410
- return m_deviceAddressMAC ;
408
+ return QString () ;
411
409
}
412
410
413
411
void Device::setAddressMAC (const QString &mac)
414
412
{
415
413
// qDebug() << "setAddressMAC(" << mac << ")";
416
414
417
- if (m_deviceAddressMAC != mac )
415
+ if (mac. size () == 17 )
418
416
{
419
- m_deviceAddressMAC = mac;
420
- Q_EMIT settingsUpdated ();
417
+ if (m_deviceAddressMAC != mac)
418
+ {
419
+ m_deviceAddressMAC = mac;
420
+ Q_EMIT sensorUpdated ();
421
+ }
422
+ }
423
+ }
424
+
425
+ bool Device::hasAddressUUID () const
426
+ {
427
+ return (m_deviceAddress.size () == 38 );
428
+ }
429
+
430
+ QString Device::getAddressUUID () const
431
+ {
432
+ if (m_deviceAddress.size () == 38 ) return m_deviceAddress;
433
+
434
+ return QString ();
435
+ }
436
+
437
+ void Device::setAddressUUID (const QString &uuid)
438
+ {
439
+ // qDebug() << "setAddressUUID(" << uuid << ")";
440
+
441
+ if (uuid.size () == 38 )
442
+ {
443
+ if (m_deviceAddress.isEmpty () || m_deviceAddress.size () == 38 )
444
+ {
445
+ if (m_deviceAddress != uuid)
446
+ {
447
+ m_deviceAddress = uuid;
448
+ Q_EMIT sensorUpdated ();
449
+ }
450
+ }
421
451
}
422
452
}
423
453
@@ -576,7 +606,7 @@ void Device::setCoreConfiguration(const int bleconf)
576
606
577
607
void Device::setDeviceClass (const int major, const int minor, const int service)
578
608
{
579
- // qDebug() << "Device::setDeviceClass() " << info.name () << info.address () << info.minorDeviceClass() << info.majorDeviceClass() << info.serviceClasses() ;
609
+ // qDebug() << "Device::setDeviceClass() " << getName () << getAddress () << major << minor << service ;
580
610
581
611
if (m_major != major || m_minor != minor || m_service != service)
582
612
{
@@ -620,7 +650,7 @@ void Device::cleanRssi()
620
650
621
651
void Device::deviceConnected ()
622
652
{
623
- // qDebug() << "Device::deviceConnected(" << m_deviceAddress << ")";
653
+ // qDebug() << "Device::deviceConnected(" << getAddress() << ")";
624
654
625
655
m_ble_status = DeviceUtils::DEVICE_CONNECTED;
626
656
@@ -679,7 +709,7 @@ void Device::deviceConnected()
679
709
680
710
void Device::deviceDisconnected ()
681
711
{
682
- // qDebug() << "Device::deviceDisconnected(" << m_deviceAddress << ")";
712
+ // qDebug() << "Device::deviceDisconnected(" << getAddress() << ")";
683
713
684
714
Q_EMIT disconnected ();
685
715
@@ -690,7 +720,7 @@ void Device::deviceDisconnected()
690
720
void Device::deviceErrored (QLowEnergyController::Error error)
691
721
{
692
722
if (error <= QLowEnergyController::NoError) return ;
693
- qWarning () << " Device::deviceErrored(" << m_deviceAddress << " ) error:" << error;
723
+ qWarning () << " Device::deviceErrored(" << getAddress () << " ) error:" << error;
694
724
/*
695
725
QLowEnergyController::NoError 0 No error has occurred.
696
726
QLowEnergyController::UnknownError 1 An unknown error has occurred.
@@ -714,7 +744,7 @@ void Device::deviceErrored(QLowEnergyController::Error error)
714
744
715
745
void Device::deviceStateChanged (QLowEnergyController::ControllerState)
716
746
{
717
- // qDebug() << "Device::deviceStateChanged(" << m_deviceAddress << ") state:" << state;
747
+ // qDebug() << "Device::deviceStateChanged(" << getAddress() << ") state:" << state;
718
748
}
719
749
720
750
/* ************************************************************************** */
@@ -726,12 +756,12 @@ void Device::addLowEnergyService(const QBluetoothUuid &)
726
756
727
757
void Device::serviceDetailsDiscovered (QLowEnergyService::ServiceState)
728
758
{
729
- // qDebug() << "Device::serviceDetailsDiscovered(" << m_deviceAddress << ")";
759
+ // qDebug() << "Device::serviceDetailsDiscovered(" << getAddress() << ")";
730
760
}
731
761
732
762
void Device::serviceScanDone ()
733
763
{
734
- // qDebug() << "Device::serviceScanDone(" << m_deviceAddress << ")";
764
+ // qDebug() << "Device::serviceScanDone(" << getAddress() << ")";
735
765
}
736
766
737
767
/* ************************************************************************** */
0 commit comments