winrt: Add service thread logging
We can run into problems if the list of low energy services is changed from threads other than the main thread. Make it possible to log this information in order to debug these problems more easily. Task-number: QTBUG-75907 Change-Id: Icda8dff45b8c1a72291ade0b1d6f734ab485a241 Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
parent
d755f7ab67
commit
e511f35a90
|
|
@ -102,5 +102,6 @@ Q_LOGGING_CATEGORY(QT_BT, "qt.bluetooth")
|
|||
Q_LOGGING_CATEGORY(QT_BT_ANDROID, "qt.bluetooth.android")
|
||||
Q_LOGGING_CATEGORY(QT_BT_BLUEZ, "qt.bluetooth.bluez")
|
||||
Q_LOGGING_CATEGORY(QT_BT_WINRT, "qt.bluetooth.winrt")
|
||||
Q_LOGGING_CATEGORY(QT_BT_WINRT_SERVICE_THREAD, "qt.bluetooth.winrt.service.thread")
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ typedef GattReadClientCharacteristicConfigurationDescriptorResult ClientCharConf
|
|||
typedef IGattReadClientCharacteristicConfigurationDescriptorResult IClientCharConfigDescriptorResult;
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT_SERVICE_THREAD)
|
||||
|
||||
static QByteArray byteArrayFromGattResult(const ComPtr<IGattReadResult> &gattResult, bool isWCharString = false)
|
||||
{
|
||||
|
|
@ -501,6 +502,9 @@ void QLowEnergyControllerPrivateWinRT::obtainIncludedServices(QSharedPointer<QLo
|
|||
Q_ASSERT_SUCCEEDED(hr);
|
||||
const QBluetoothUuid includedUuid(guuid);
|
||||
QSharedPointer<QLowEnergyServicePrivate> includedPointer;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
||||
<< "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
if (serviceList.contains(includedUuid)) {
|
||||
includedPointer = serviceList.value(includedUuid);
|
||||
} else {
|
||||
|
|
@ -511,6 +515,9 @@ void QLowEnergyControllerPrivateWinRT::obtainIncludedServices(QSharedPointer<QLo
|
|||
includedPointer = QSharedPointer<QLowEnergyServicePrivate>(priv);
|
||||
serviceList.insert(includedUuid, includedPointer);
|
||||
}
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
||||
<< "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
includedPointer->type |= QLowEnergyService::IncludedService;
|
||||
servicePointer->includedServices.append(includedUuid);
|
||||
|
||||
|
|
@ -540,6 +547,9 @@ void QLowEnergyControllerPrivateWinRT::discoverServices()
|
|||
Q_ASSERT_SUCCEEDED(hr);
|
||||
const QBluetoothUuid service(guuid);
|
||||
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
||||
<< "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
QSharedPointer<QLowEnergyServicePrivate> pointer;
|
||||
if (serviceList.contains(service)) {
|
||||
pointer = serviceList.value(service);
|
||||
|
|
@ -579,6 +589,8 @@ void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(const QBluetoothUu
|
|||
|
||||
//update service data
|
||||
QSharedPointer<QLowEnergyServicePrivate> pointer = serviceList.value(service);
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
|
||||
pointer->setState(QLowEnergyService::DiscoveringServices);
|
||||
ComPtr<IGattDeviceService2> deviceService2;
|
||||
|
|
@ -672,6 +684,8 @@ void QLowEnergyControllerPrivateWinRT::readCharacteristic(const QSharedPointer<Q
|
|||
const QLowEnergyHandle charHandle)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::CharacteristicReadError);
|
||||
|
|
@ -737,6 +751,8 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(const QSharedPointer<QLowE
|
|||
const QLowEnergyHandle descHandle)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::DescriptorReadError);
|
||||
|
|
@ -873,6 +889,8 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(const QSharedPointer<
|
|||
QLowEnergyService::WriteMode mode)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << newValue << mode;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||
|
|
@ -963,6 +981,8 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
|||
const QByteArray &newValue)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle << newValue;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||
|
|
@ -1110,6 +1130,8 @@ void QLowEnergyControllerPrivateWinRT::handleCharacteristicChanged(
|
|||
quint16 charHandle, const QByteArray &data)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << charHandle << data;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
QSharedPointer<QLowEnergyServicePrivate> service =
|
||||
serviceForHandle(charHandle);
|
||||
if (service.isNull())
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ typedef IGattReadClientCharacteristicConfigurationDescriptorResult IClientCharCo
|
|||
}
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT_SERVICE_THREAD)
|
||||
|
||||
QLowEnergyControllerPrivate *createWinRTLowEnergyController()
|
||||
{
|
||||
|
|
@ -710,6 +711,9 @@ void QLowEnergyControllerPrivateWinRTNew::obtainIncludedServices(
|
|||
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain included service's Uuid");
|
||||
const QBluetoothUuid includedUuid(guuid);
|
||||
QSharedPointer<QLowEnergyServicePrivate> includedPointer;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
||||
<< "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
if (serviceList.contains(includedUuid)) {
|
||||
includedPointer = serviceList.value(includedUuid);
|
||||
} else {
|
||||
|
|
@ -765,6 +769,9 @@ HRESULT QLowEnergyControllerPrivateWinRTNew::onServiceDiscoveryFinished(ABI::Win
|
|||
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain service's Uuid");
|
||||
const QBluetoothUuid service(guuid);
|
||||
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
||||
<< "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
QSharedPointer<QLowEnergyServicePrivate> pointer;
|
||||
if (serviceList.contains(service)) {
|
||||
pointer = serviceList.value(service);
|
||||
|
|
@ -828,7 +835,8 @@ void QLowEnergyControllerPrivateWinRTNew::discoverServiceDetails(const QBluetoot
|
|||
|
||||
//update service data
|
||||
QSharedPointer<QLowEnergyServicePrivate> pointer = serviceList.value(service);
|
||||
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
pointer->setState(QLowEnergyService::DiscoveringServices);
|
||||
ComPtr<IGattDeviceService3> deviceService3;
|
||||
HRESULT hr = deviceService.As(&deviceService3);
|
||||
|
|
@ -942,6 +950,8 @@ void QLowEnergyControllerPrivateWinRTNew::readCharacteristic(
|
|||
const QLowEnergyHandle charHandle)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::CharacteristicReadError);
|
||||
|
|
@ -1009,6 +1019,8 @@ void QLowEnergyControllerPrivateWinRTNew::readDescriptor(
|
|||
const QLowEnergyHandle descHandle)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::DescriptorReadError);
|
||||
|
|
@ -1185,6 +1197,8 @@ void QLowEnergyControllerPrivateWinRTNew::writeCharacteristic(
|
|||
QLowEnergyService::WriteMode mode)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << newValue << mode;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||
|
|
@ -1296,6 +1310,8 @@ void QLowEnergyControllerPrivateWinRTNew::writeDescriptor(
|
|||
const QByteArray &newValue)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle << newValue;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
Q_ASSERT(!service.isNull());
|
||||
if (role == QLowEnergyController::PeripheralRole) {
|
||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||
|
|
@ -1494,6 +1510,8 @@ void QLowEnergyControllerPrivateWinRTNew::handleCharacteristicChanged(
|
|||
quint16 charHandle, const QByteArray &data)
|
||||
{
|
||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << charHandle << data;
|
||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||
<< QThread::currentThread();
|
||||
QSharedPointer<QLowEnergyServicePrivate> service =
|
||||
serviceForHandle(charHandle);
|
||||
if (service.isNull())
|
||||
|
|
|
|||
Loading…
Reference in New Issue