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. The issue of Bluetooth scanning connection crash
Forum Updated to NodeBB v4.3 + New Features

The issue of Bluetooth scanning connection crash

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 754 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.
  • H Offline
    H Offline
    hunter Li
    wrote on last edited by
    #1

    // Start Bluetooth scanning with a timer in the constructor
    deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
    if (!deviceDiscoveryAgent)
    {
    return;
    }
    m_timerCheckBlue = new QTimer(this);
    connect(m_timerCheckBlue, &QTimer::timeout, this, &MWidget::timerCheckBlue);
    m_timerCheckBlue->start(5000);

    // m_bCheckTimer When the scan is completed, triggering finished will scan again
    if (deviceDiscoveryAgent && m_bCheckTimer)
    {
    m_bCheckTimer = false;
    deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(3000);
    deviceDiscoveryAgent->start();
    //m_timerCheckBlue->stop();
    }

    My general logic is like this, but I don't know where it can cause a memory leak, and if I open multiple. Exes to run such a process, it can cause a memory explosion. Does Windows not support it? My Platform vs+Qt 12.11

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • H hunter Li

      // Start Bluetooth scanning with a timer in the constructor
      deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
      if (!deviceDiscoveryAgent)
      {
      return;
      }
      m_timerCheckBlue = new QTimer(this);
      connect(m_timerCheckBlue, &QTimer::timeout, this, &MWidget::timerCheckBlue);
      m_timerCheckBlue->start(5000);

      // m_bCheckTimer When the scan is completed, triggering finished will scan again
      if (deviceDiscoveryAgent && m_bCheckTimer)
      {
      m_bCheckTimer = false;
      deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(3000);
      deviceDiscoveryAgent->start();
      //m_timerCheckBlue->stop();
      }

      My general logic is like this, but I don't know where it can cause a memory leak, and if I open multiple. Exes to run such a process, it can cause a memory explosion. Does Windows not support it? My Platform vs+Qt 12.11

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @hunter-Li said in The issue of Bluetooth scanning connection crash:

      Does Windows not support it?

      Support what?
      Memory management is your job in C++.
      You should use a memory profiler to see where you have memory leaks.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      H 1 Reply Last reply
      1
      • jsulmJ jsulm

        @hunter-Li said in The issue of Bluetooth scanning connection crash:

        Does Windows not support it?

        Support what?
        Memory management is your job in C++.
        You should use a memory profiler to see where you have memory leaks.

        H Offline
        H Offline
        hunter Li
        wrote on last edited by
        #3

        @jsulm Support multiple processes to use QBluetoothDeviceDiscoveryAgent to scan Bluetooth

        C 1 Reply Last reply
        0
        • H hunter Li

          @jsulm Support multiple processes to use QBluetoothDeviceDiscoveryAgent to scan Bluetooth

          C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          @hunter-Li Multiple process are completely independent of each other. If they are all the same executable then they all suffer the same bugs. If one is truly causing a "memory explosion" then you need to identify where your code is going wrong. Of course, the "memory explosion" could have nothing to do with these Qt programs, for example a buggy Bluetooth driver; we cannot tell.

          Reduce it to to a single file program that fails and you'll probably find the problem if its in your code.

          1 Reply Last reply
          1
          • H hunter Li

            // Start Bluetooth scanning with a timer in the constructor
            deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
            if (!deviceDiscoveryAgent)
            {
            return;
            }
            m_timerCheckBlue = new QTimer(this);
            connect(m_timerCheckBlue, &QTimer::timeout, this, &MWidget::timerCheckBlue);
            m_timerCheckBlue->start(5000);

            // m_bCheckTimer When the scan is completed, triggering finished will scan again
            if (deviceDiscoveryAgent && m_bCheckTimer)
            {
            m_bCheckTimer = false;
            deviceDiscoveryAgent->setLowEnergyDiscoveryTimeout(3000);
            deviceDiscoveryAgent->start();
            //m_timerCheckBlue->stop();
            }

            My general logic is like this, but I don't know where it can cause a memory leak, and if I open multiple. Exes to run such a process, it can cause a memory explosion. Does Windows not support it? My Platform vs+Qt 12.11

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @hunter-Li Bluetooth LE on windows is tricky. at least last when I used it.

            I can give you the following feedback, that is dated back pre Qt 6!, So stuff has most likely changed:

            • You need MSVC, mingw has only a dummy backend
            • A connection loss or other issue is not detected correctly
            • Scanning has a 50/50 chance of working
            • I managed to completely nuke my Bluetooth-driver which required a complete shutdown ( battery removal) of my Laptop
              Service discovery had a good chance of returning invalid services, because of unhandled service changed signals (in the backend)

            I personally looking forward to your journey, if stuff is nowadays fixed I might have to revisit BTLE on windows :D


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              hunter Li
              wrote on last edited by
              #6

              I feel like everyone's response. Currently, I have negotiated with my team to compromise on using only one process to scan Ble. In addition, I have found that the debugging program outputs "qt. bluetooth. winrt: onBluetoothLEDeviceFound: No device given"? It's strange, but I didn't set a situation when running it

              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