diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2022-09-06 13:25:47 +0300 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2022-09-20 15:46:58 +0300 |
commit | 14db1fabef1ba2eb1a889c968e3b038f7978d6bd (patch) | |
tree | 4b492c8fbfaae84a57e08b0efd2fbb24b96a6600 /tests | |
parent | ab14918bcac02af14ba6dd7398f8056b3f49792e (diff) |
Clear previous bluetooth device/service discovery errors on restart
An example of the problem is when discovery is first tried while
bluetooth is OFF, and one gets the corresponding error. Then the
bluetooth is switched ON, and the discovery is restarted successfully.
However in this case the error() still remains as "power OFF" error
instead of "no error", which is misleading.
With device discovery agent the clearing is done at each individual
backend, rather than at the common public class start(). This is due
to the pending cancel/start logic, which we probably shouldn't interfere
with by clearing errors amidst pending operation. The Darwin backend
already cleared the error in its start(), and with this commit the
intent is to add similar clearing to the Android/Bluez/Win.
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104473
Change-Id: I713590a26eb2b8d4ee7873f3fe84e63e504523df
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bttestui/btlocaldevice.cpp | 21 | ||||
-rw-r--r-- | tests/bttestui/btlocaldevice.h | 1 | ||||
-rw-r--r-- | tests/bttestui/main.qml | 5 |
3 files changed, 27 insertions, 0 deletions
diff --git a/tests/bttestui/btlocaldevice.cpp b/tests/bttestui/btlocaldevice.cpp index e6aa8a8e..bf8f492e 100644 --- a/tests/bttestui/btlocaldevice.cpp +++ b/tests/bttestui/btlocaldevice.cpp @@ -794,6 +794,27 @@ void BtLocalDevice::dumpServerInformation() } } +template <typename T> +void printError(const QLatin1StringView name, T* ptr) +{ + if (!ptr) + return; + qDebug() << name << "error:" << ptr->error(); +} + +void BtLocalDevice::dumpErrors() +{ + qDebug() << "###### Errors"; + printError("Device agent"_L1, deviceAgent); + printError("Service agent"_L1, serviceAgent); + printError("LE Central"_L1, leCentralController.get()); + printError("LE Central Service"_L1, leCentralService.get()); + printError("LE Peripheral"_L1, lePeripheralController.get()); + printError("LE Peripheral Service"_L1, lePeripheralService.get()); + printError("Socket"_L1, socket); + printError("Server"_L1, server); +} + void BtLocalDevice::dumpInformation() { if (!localDevice) diff --git a/tests/bttestui/btlocaldevice.h b/tests/bttestui/btlocaldevice.h index 97e64ed1..4c093bdb 100644 --- a/tests/bttestui/btlocaldevice.h +++ b/tests/bttestui/btlocaldevice.h @@ -50,6 +50,7 @@ signals: public slots: //QBluetoothLocalDevice void dumpInformation(); + void dumpErrors(); void powerOn(); void reset(); void setHostMode(int newMode); diff --git a/tests/bttestui/main.qml b/tests/bttestui/main.qml index f0510fcf..38823199 100644 --- a/tests/bttestui/main.qml +++ b/tests/bttestui/main.qml @@ -350,6 +350,11 @@ Flickable { buttonText: "Reset" onClicked: device.reset() } + Button { + id: errorButton + buttonText: "Errors" + onClicked: device.dumpErrors() + } } } } |