Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Search only for bluetooth devices that are turned on

Search only for bluetooth devices that are turned on

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 283 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stefano84
    wrote on last edited by
    #1

    Hello to all,
    in my software i want to search only for bluetooth devices that are turned on. Currently, my software also shows me bluetooth devices registered in windows that are not turned on. How can I do?

        if (!localDevice)
            localDevice = new QBluetoothLocalDevice();
    
        if (!localDevice->isValid())
        {
            emit SignalConnectionNotification(BT_LOCAL_DEVICE_ERROR);
            return;
        }
    
        localDevice->powerOn();
        adapter = localDevice->address();
    
        discoveryAgent = new QBluetoothDeviceDiscoveryAgent(adapter);
    
        QObject::connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(BluetoothDeviceDiscovered(QBluetoothDeviceInfo)));
        QObject::connect(discoveryAgent, SIGNAL(finished()), this, SLOT(BluetoothDeviceDiscoveredFinished()));
        QObject::connect(discoveryAgent, SIGNAL(canceled()), this, SLOT(BluetoothDeviceDiscoveredFinished()));
    
        discoveryAgent->start();
    

    If instead of finding the devices I find the services everything works. I can only find the services of bluetooth devices that are turned on. But the search takes a long time to finish (more than 2 minutes). This is because I have many bluetooth devices in the windows registry.

    Can anyone help me out?

    I am using Qt 5.14.0 on windows

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by sierdzio
      #2

      As far as I remember (I haven't used BT on Windows since ~2 years), this is just the way it works. Windows reports all paired devices as "available". It's stupid but that's their way they've done it.

      I think Qt 5.14 or 5.15 added some new functionality (like an experimental BT implementation) which goes around this limitation - please look for it in release announcements or blog posts. It is not compiled into official Qt packages, but can be compiled from source.

      (Z(:^

      S 2 Replies Last reply
      2
      • sierdzioS sierdzio

        As far as I remember (I haven't used BT on Windows since ~2 years), this is just the way it works. Windows reports all paired devices as "available". It's stupid but that's their way they've done it.

        I think Qt 5.14 or 5.15 added some new functionality (like an experimental BT implementation) which goes around this limitation - please look for it in release announcements or blog posts. It is not compiled into official Qt packages, but can be compiled from source.

        S Offline
        S Offline
        Stefano84
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • sierdzioS sierdzio

          As far as I remember (I haven't used BT on Windows since ~2 years), this is just the way it works. Windows reports all paired devices as "available". It's stupid but that's their way they've done it.

          I think Qt 5.14 or 5.15 added some new functionality (like an experimental BT implementation) which goes around this limitation - please look for it in release announcements or blog posts. It is not compiled into official Qt packages, but can be compiled from source.

          S Offline
          S Offline
          Stefano84
          wrote on last edited by
          #4

          @sierdzio
          Thank you for your answer

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved