×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    105

    How to set Bluetooth to on in Qt

    I have an application, that requires bluetooth to send over some bytes using bluetooth. I want to app to turn on the bluetooth setting automatically when the app is launched. How do I do that?

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: How to set Bluetooth to on in Qt

    Hi,
    You can use BlueZ DBus Adapter to switch on/off Bluetooth.

    Here the steps to switch on the device:
    1. Get the Available adapter with ListAdapter method
    /home/developer $ dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.ListAdapters
    method return sender=:1.200 -> dest=:1.362 reply_serial=2
    array [
    object path "/org/bluez/1785/hci0"
    ]

    2. Switch on bluetooth adapter with:
    dbus-send --system --type=method_call --dest=org.bluez /org/bluez/1785/hci0 org.bluez.Adapter.SetProperty string:Powered variant:boolean:true


    NOTE: In Qt you have to use QDBus to call these methods [1]
    List of Methods supported by Bluez Adaptor can be found at the following page: [2]

    [1] http://techbase.kde.org/Development/...a_D-Bus_Method
    [2] http://maemo.org/api_refs/5.0/beta/bluez/adapter.html

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    105

    Re: How to set Bluetooth to on in Qt

    Is there a way to call it with Qt Mobility APIs?

  4. #4
    Registered User
    Join Date
    Sep 2011
    Posts
    1

    Re: How to set Bluetooth to on in Qt

    maybe this help:

    QBluetoothLocalDevice Class Reference
    Bluetooth Scanner Example

    Code:
    QBluetoothLocalDevice *localDevice;
    // ...
    localDevice = new QBluetoothLocalDevice;
    // ......
    // enable device
    localDevice->powerOn();
    // disable device
    localDevice->setHostMode(QBluetoothLocalDevice::HostPoweredOff);

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    105

    Re: How to set Bluetooth to on in Qt

    Thanks all for the suggestions. This works.
    Quote Originally Posted by hhrhhr View Post
    maybe this help:

    QBluetoothLocalDevice Class Reference
    Bluetooth Scanner Example

    Code:
    QBluetoothLocalDevice *localDevice;
    // ...
    localDevice = new QBluetoothLocalDevice;
    // ......
    // enable device
    localDevice->powerOn();
    // disable device
    localDevice->setHostMode(QBluetoothLocalDevice::HostPoweredOff);

Similar Threads

  1. Replies: 0
    Last Post: 2004-04-12, 12:25
  2. Replies: 0
    Last Post: 2004-04-12, 12:23
  3. Replies: 0
    Last Post: 2004-04-12, 12:22
  4. Replies: 0
    Last Post: 2004-04-12, 12:21
  5. Replies: 3
    Last Post: 2003-12-29, 13:54

Posting Permissions

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