×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    12

    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)));
    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?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    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

  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    12

    Re: Detecting Bluetooth pairing

    Quote Originally Posted by kusumk View Post
    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
    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.

Similar Threads

  1. Bluetooth NFC pairing
    By Alex_Polt in forum Near Field Communication
    Replies: 7
    Last Post: 2010-02-12, 09:32
  2. Bluetooth pairing
    By Alex_Polt in forum Near Field Communication
    Replies: 1
    Last Post: 2008-02-13, 13:46
  3. Bluetooth Pairing
    By jigneshshah in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-04-11, 14:57
  4. Detecting and initiating bluetooth pairing
    By GrahamDouglas in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-02-02, 10:53
  5. Bluetooth pairing
    By chris3388 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-04-10, 16:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •