Detecting Bluetooth pairing
Hi,
I need to detect when a Bluetooth device is paired with N9. But I have not had any success with it. I'm sure I'm doing something wrong, but I have trouble finding the error.
First I thought I could use the QtMobility framework to detect these changes, like this:
[code]
_btLocalDevice = new QBluetoothLocalDevice(this);
connect(_btLocalDevice, SIGNAL(pairingFinished(const QBluetoothAddress &, QBluetoothLocalDevice::Pairing)),
this, SLOT(pairingFinished(const QBluetoothAddress &, QBluetoothLocalDevice::Pairing)));
[/code]
Unfortunately the slot I've specified doesn't get called when a Bluetooth device is paired with N9.
So I looked at the D-Bus messages being sent when paring devices, and tried to connect using D-Bus like this:
[code]
if (!QDBusConnection::systemBus().connect(QString(), QString(),
"org.bluez.Device", "PropertyChanged",
this, SLOT(propertyChanged(QString,QVariant))))
qDebug("BluetoothClient::Failed to connect dbus signal isValid: %d", QDBusConnection::systemBus().lastError().isValid());
qDebug("BluetoothClient::Failed to connect dbus signal type: %d", QDBusConnection::systemBus().lastError().type());
qDebug("BluetoothClient::Failed to connect dbus signal: %s", qPrintable(QDBusConnection::systemBus().lastError().name()));
[/code]
This code, I thought, should catch a signal whenever Bluetooth property is changed. One of the properties is "Paired" that I want to catch. But that slot is never called, and the connect returns an error. QDBusConnection::connect documents say service and path parameters are optional, and in the above example I've let them empty. But I have tried different values for them also but it's still failing.
Can anyone provide some hints or working code for this?
Thanks in advance.
Re: Detecting Bluetooth pairing
Hi,
Does the connect work successfully, you can check the return value of the connect statement.
Also, did you try giving different names for the slot instead of exact signatures (pairingFinished)
-Kusuma
Re: Detecting Bluetooth pairing
[QUOTE=kusumk;904428]Hi,
Does the connect work successfully, you can check the return value of the connect statement.
Also, did you try giving different names for the slot instead of exact signatures (pairingFinished)
-Kusuma[/QUOTE]
I have solved the issue... and actually I wasn't interested in pairing as it turns out, but the connected value. I can now manage to get it using D-Bus. But thanks.