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:
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()));
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?
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:
So I looked at the D-Bus messages being sent when paring devices, and tried to connect using D-Bus like this:
Can anyone provide some hints or working code for this?
Thanks in advance.
My N9/N950 projects: