@@ -502,17 +502,27 @@ void Connection::updateSignalSlot()
502
502
void Connection::BTServer_initServiceInfo ()
503
503
{
504
504
// call it once
505
+
506
+ // Reference:
507
+ // https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host/service-discovery-protocol--sdp--specification.html
508
+ // https://doc.qt.io/qt-5/qbluetoothserver.html#listen-1
509
+
510
+ const QBluetoothUuid serviceUuid (QLatin1String (" 4de17a00-52cb-11e6-bdf4-0800200c9a66" ));
511
+
512
+ // Configure service attribute: BluetoothProfileDescriptorList(0x0009)
505
513
QBluetoothServiceInfo::Sequence profileSequence;
506
514
QBluetoothServiceInfo::Sequence classId;
507
515
classId << QVariant::fromValue (QBluetoothUuid (QBluetoothUuid::SerialPort));
508
- classId << QVariant::fromValue (quint16 (0x100 ));
516
+ classId << QVariant::fromValue (quint16 (0x100 )); // profile version number: 1.0(initial version)
509
517
profileSequence.append (QVariant::fromValue (classId));
510
518
m_RfcommServiceInfo.setAttribute (QBluetoothServiceInfo::BluetoothProfileDescriptorList, profileSequence);
511
519
512
520
classId.clear ();
513
- // Add user defined UUID there
521
+ // "The UUIDs should be listed in order from the most specific class to the most general class unless otherwise specified by the profile specifications defining the service classes."
522
+ // Android requires custom uuid to be set as service class
514
523
// classId << QVariant::fromValue(QBluetoothUuid(serialServiceUuid));
515
- classId << QVariant::fromValue (QBluetoothUuid (QBluetoothUuid::SerialPort));
524
+ classId << QVariant::fromValue (serviceUuid);
525
+ // classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
516
526
517
527
m_RfcommServiceInfo.setAttribute (QBluetoothServiceInfo::ServiceClassIds, classId);
518
528
@@ -525,7 +535,7 @@ void Connection::BTServer_initServiceInfo()
525
535
// ! [Service UUID set]
526
536
// use QBluetoothUuid::SerialPort there
527
537
// m_RfcommServiceInfo.setServiceUuid(QBluetoothUuid(serialServiceUuid));
528
- m_RfcommServiceInfo.setServiceUuid (QBluetoothUuid::SerialPort );
538
+ m_RfcommServiceInfo.setServiceUuid (serviceUuid );
529
539
// ! [Service UUID set]
530
540
531
541
// ! [Service Discoverability]
@@ -534,6 +544,7 @@ void Connection::BTServer_initServiceInfo()
534
544
m_RfcommServiceInfo.setAttribute (QBluetoothServiceInfo::BrowseGroupList,
535
545
publicBrowse);
536
546
// ! [Service Discoverability]
547
+ m_Bt
537
548
}
538
549
539
550
void Connection::BTServer_updateServicePort ()
0 commit comments