Crashing while turn on/off BTLE adapter
-
Hi, i got crashing while turn on/off BTLE power.
it often crashing with QBluetoothDeviceDiscoveryAgent. now i am usingQSharedPointer<QBluetoothLocalDevice> _btlePower;
QBluetoothLocalDevice::HostMode mode = _btlePower->hostMode();if (mode == QBluetoothLocalDevice::HostPoweredOff)
_isBTLEPowerOn = false;
else
_isBTLEPowerOn = true;i use it to check the power before each time use QBluetoothDeviceDiscoveryAgent.
but sometime it still happened crashing somewhere. what is the best solution that QT support to handle this issue? -
@Pham-Hoang said in Crashing while turn on/off BTLE adapter:
crashing somewhere
Use debugger to see where exactly it is crashing and check the stack trace.
-
@jsulm actually, it is hard to catch the issue while coding/debugging. it is rarely, i see it in running time with log file.
-
Hi,
Any more information in the logs ?
-
How often are you doing that check ?
-
@SGaist said in Crashing while turn on/off BTLE adapter:
w often are you doing that che
i check it 1 time in onStartDeviceDiscovery before call
discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); -
i know discoveryAgent->start() can make a crashing while BTLE adapter off. anything more?
btw, i think it is perfect if QT help to handle the issue internal that return a error code or something which don't break
-
@Pham-Hoang can't say I ever ran into this issue, and my application continuously calls start everytime the finished Signal is emitted (with a 2 second delay to not completely drain the batteries).
Do you listen and react to the
QBluetoothDeviceDiscoveryAgent::error()
signal? -
@J.Hilk said in Crashing while turn on/off BTLE adapter:
hDeviceDiscoveryAgent::err
i call start discovery each 10 seconds. the issue came when you trying to switch on/off BTLE adapter many times.
QBluetoothDeviceDiscoveryAgent::error() . yep, i have it. but if it go to error signal that mean it will not crashing. -
@Pham-Hoang you may have to explain that a bit more to me.
If you turn of your BTLE adapter
QBluetoothDeviceDiscoveryAgent::PoweredOffError
is emitted and you detect that and everything is fine.But if you rapidly turn the adapter on and off it can happen that the adapter is actully powered of but allready/or still registered (from the OS) as connected and powerdOn ?
If that's the case, than I don't see a way to catch that particular error case.
-
@J.Hilk said in Crashing while turn on/off BTLE adapter:
QBluetoothDeviceDiscoveryAgent::PoweredOffError
this emitted is raised when discoveryAgent already started and in discovering. then if a turn off event happen, it will emit
QBluetoothDeviceDiscoveryAgent::PoweredOffError.
but the issue could came before discoveryAgent start and after i checked isBTLEPowerON()
or some other cases that i don't know yet.But if you rapidly turn the adapter on and off it can happen that the adapter is actully powered of but allready/or still registered (from the OS) as connected and powerdOn ?
If that's the case, than I don't see a way to catch that particular error case.yep, it is a case
-
By the way, can you give more information about your setup ? (hardware/software)