The issue of Bluetooth scanning connection crash
-
// 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
-
@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. -
@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.
-
@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
-
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