ServiceDiscoveryDialog::ServiceDiscoveryDialog(const QString &name, const QBluetoothAddress &address, QWidget *parent) : QDialog(parent), ui(new Ui_ServiceDiscovery) { ui->setupUi(this); //Using default Bluetooth adapter QBluetoothLocalDevice localDevice; QBluetoothAddress adapterAddress = localDevice.address(); /* * In case of multiple Bluetooth adapters it is possible to * set which adapter will be used by providing MAC Address. * Example code: * * QBluetoothAddress adapterAddress("XX:XX:XX:XX:XX:XX"); * discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress); */ discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress); discoveryAgent->setRemoteAddress(address); setWindowTitle(name); connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(addService(QBluetoothServiceInfo))); connect(discoveryAgent, SIGNAL(finished()), ui->status, SLOT(hide())); discoveryAgent->start(); }
void Handover::sendBluetoothService() { QBluetoothLocalDevice localDevice; const QString data = localDevice.address().toString() + QLatin1Char(' ') + QString::number(m_localServerPort); m_remote->write(data.toUtf8()); }
void tst_QBluetoothLocalDevice::tst_address() { if (!QBluetoothLocalDevice::allDevices().count()) QSKIP("Skipping test due to missing Bluetooth device"); QBluetoothLocalDevice localDevice; QVERIFY(!localDevice.address().toString().isEmpty()); }
void tst_QBluetoothLocalDevice::tst_construction() { QBluetoothLocalDevice localDevice; QVERIFY(localDevice.isValid()); QBluetoothLocalDevice anotherDevice = new QBluetoothLocalDevice(QBluetoothAddress(000000000000)); QVERIFY(anotherDevice.isValid()); QVERIFY(anotherDevice.address().toUInt64() != 0); }
void Handover::readBluetoothService() { QByteArray rawData = m_client->readAll(); QString data = QString::fromUtf8(rawData.constData(), rawData.size()); QStringList split = data.split(QLatin1Char(' ')); QBluetoothAddress address = QBluetoothAddress(split.at(0)); quint16 port = split.at(1).toUInt(); QBluetoothLocalDevice localDevice; QBluetoothAddress localAddress = localDevice.address(); if (localAddress < address) { m_address = address; m_serverPort = port; emit bluetoothServiceChanged(); } }
void tst_QBluetoothLocalDevice::tst_address() { QBluetoothLocalDevice localDevice; QVERIFY(!localDevice.address().toString().isEmpty()); }
QBluetoothAddress QBluetoothSocketPrivate::localAddress() const { QBluetoothLocalDevice ld; return ld.address(); }