Unify Windows logging categories
There were two logging categories on Windows: qt.bluetooth.winrt and qt.bluetooth.windows. As there is now only one Windows backend, multiple logging categories are not required. This patch removes qt.bluetooth.winrt and changes all usages to qt.bluetooth.windows. Change-Id: I3f42774e77326fa30f3f7bff6cac8160bf4e644f Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
parent
24f12bce2c
commit
e6f7e7b756
|
@ -11,6 +11,9 @@ General
|
||||||
|
|
||||||
- Win32 backend has been removed. There will not be a working Bluetooth backend when Qt is built with mingw.
|
- Win32 backend has been removed. There will not be a working Bluetooth backend when Qt is built with mingw.
|
||||||
|
|
||||||
|
- Since there is now only one Windows backend, the logging category qt.bluetooth.winrt was removed.
|
||||||
|
The corresponding log messages are now in qt.bluetooth.windows.
|
||||||
|
|
||||||
QBluetooth namespace
|
QBluetooth namespace
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,6 @@ Q_LOGGING_CATEGORY(QT_BT, "qt.bluetooth")
|
||||||
Q_LOGGING_CATEGORY(QT_BT_ANDROID, "qt.bluetooth.android")
|
Q_LOGGING_CATEGORY(QT_BT_ANDROID, "qt.bluetooth.android")
|
||||||
Q_LOGGING_CATEGORY(QT_BT_BLUEZ, "qt.bluetooth.bluez")
|
Q_LOGGING_CATEGORY(QT_BT_BLUEZ, "qt.bluetooth.bluez")
|
||||||
Q_LOGGING_CATEGORY(QT_BT_WINDOWS, "qt.bluetooth.windows")
|
Q_LOGGING_CATEGORY(QT_BT_WINDOWS, "qt.bluetooth.windows")
|
||||||
Q_LOGGING_CATEGORY(QT_BT_WINRT, "qt.bluetooth.winrt")
|
Q_LOGGING_CATEGORY(QT_BT_WINDOWS_SERVICE_THREAD, "qt.bluetooth.winrt.service.thread")
|
||||||
Q_LOGGING_CATEGORY(QT_BT_WINRT_SERVICE_THREAD, "qt.bluetooth.winrt.service.thread")
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
|
@ -69,24 +69,24 @@ using namespace ABI::Windows::Storage::Streams;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
#define EMIT_WORKER_ERROR_AND_RETURN_IF_FAILED(msg, error, ret) \
|
#define EMIT_WORKER_ERROR_AND_RETURN_IF_FAILED(msg, error, ret) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
emit errorOccured(error); \
|
emit errorOccured(error); \
|
||||||
qCWarning(QT_BT_WINRT) << msg; \
|
qCWarning(QT_BT_WINDOWS) << msg; \
|
||||||
ret; \
|
ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WARN_AND_RETURN_IF_FAILED(msg, ret) \
|
#define WARN_AND_RETURN_IF_FAILED(msg, ret) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
qCWarning(QT_BT_WINRT) << msg; \
|
qCWarning(QT_BT_WINDOWS) << msg; \
|
||||||
ret; \
|
ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WARN_AND_CONTINUE_IF_FAILED(msg) \
|
#define WARN_AND_CONTINUE_IF_FAILED(msg) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
qCWarning(QT_BT_WINRT) << msg; \
|
qCWarning(QT_BT_WINDOWS) << msg; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ static ManufacturerData extractManufacturerData(ComPtr<IBluetoothLEAdvertisement
|
||||||
WARN_AND_CONTINUE_IF_FAILED("Could not obtain manufacturer data set.");
|
WARN_AND_CONTINUE_IF_FAILED("Could not obtain manufacturer data set.");
|
||||||
const QByteArray bufferData = byteArrayFromBuffer(buffer);
|
const QByteArray bufferData = byteArrayFromBuffer(buffer);
|
||||||
if (ret.contains(id))
|
if (ret.contains(id))
|
||||||
qCWarning(QT_BT_WINRT) << "Company ID already present in manufacturer data.";
|
qCWarning(QT_BT_WINDOWS) << "Company ID already present in manufacturer data.";
|
||||||
ret.insert(id, bufferData);
|
ret.insert(id, bufferData);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -214,7 +214,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::start()
|
||||||
setupLEDeviceWatcher();
|
setupLEDeviceWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Worker started";
|
qCDebug(QT_BT_WINDOWS) << "Worker started";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWinRTBluetoothDeviceDiscoveryWorker::stopLEWatcher()
|
void QWinRTBluetoothDeviceDiscoveryWorker::stopLEWatcher()
|
||||||
|
@ -264,7 +264,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::startDeviceDiscovery(QBluetoothDevice
|
||||||
|
|
||||||
void QWinRTBluetoothDeviceDiscoveryWorker::onDeviceDiscoveryFinished(IAsyncOperation<DeviceInformationCollection *> *op, QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode)
|
void QWinRTBluetoothDeviceDiscoveryWorker::onDeviceDiscoveryFinished(IAsyncOperation<DeviceInformationCollection *> *op, QBluetoothDeviceDiscoveryAgent::DiscoveryMethod mode)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << (mode == QBluetoothDeviceDiscoveryAgent::ClassicMethod ? "BT" : "BTLE")
|
qCDebug(QT_BT_WINDOWS) << (mode == QBluetoothDeviceDiscoveryAgent::ClassicMethod ? "BT" : "BTLE")
|
||||||
<< " scan completed";
|
<< " scan completed";
|
||||||
ComPtr<IVectorView<DeviceInformation *>> devices;
|
ComPtr<IVectorView<DeviceInformation *>> devices;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -461,7 +461,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::classicBluetoothInfoFromDeviceIdAsync
|
||||||
if (!m_pendingPairedDevices
|
if (!m_pendingPairedDevices
|
||||||
&& !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
|
&& !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
|
||||||
finishDiscovery();
|
finishDiscovery();
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain bluetooth device from id";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain bluetooth device from id";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
||||||
|
@ -481,7 +481,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::classicBluetoothInfoFromDeviceIdAsync
|
||||||
if (!m_pendingPairedDevices
|
if (!m_pendingPairedDevices
|
||||||
&& !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
|
&& !(requestedModes & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod))
|
||||||
finishDiscovery();
|
finishDiscovery();
|
||||||
qCWarning(QT_BT_WINRT) << "Could not register device found callback";
|
qCWarning(QT_BT_WINDOWS) << "Could not register device found callback";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,7 +495,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::leBluetoothInfoFromDeviceIdAsync(HSTR
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
--m_pendingPairedDevices;
|
--m_pendingPairedDevices;
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain bluetooth device from id";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain bluetooth device from id";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
||||||
|
@ -512,7 +512,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::leBluetoothInfoFromDeviceIdAsync(HSTR
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
--m_pendingPairedDevices;
|
--m_pendingPairedDevices;
|
||||||
qCWarning(QT_BT_WINRT) << "Could not register device found callback";
|
qCWarning(QT_BT_WINDOWS) << "Could not register device found callback";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::leBluetoothInfoFromAddressAsync(quint
|
||||||
HRESULT hr = m_leDeviceStatics->FromBluetoothAddressAsync(address, &deviceFromAddressOperation);
|
HRESULT hr = m_leDeviceStatics->FromBluetoothAddressAsync(address, &deviceFromAddressOperation);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain bluetooth device from address";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain bluetooth device from address";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
QPointer<QWinRTBluetoothDeviceDiscoveryWorker> thisPointer(this);
|
||||||
|
@ -539,7 +539,7 @@ void QWinRTBluetoothDeviceDiscoveryWorker::leBluetoothInfoFromAddressAsync(quint
|
||||||
}).Get());
|
}).Get());
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
qCWarning(QT_BT_WINRT) << "Could not register device found callback";
|
qCWarning(QT_BT_WINDOWS) << "Could not register device found callback";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoun
|
||||||
IVectorView <Rfcomm::RfcommDeviceService *> *deviceServices;
|
IVectorView <Rfcomm::RfcommDeviceService *> *deviceServices;
|
||||||
hr = device->get_RfcommServices(&deviceServices);
|
hr = device->get_RfcommServices(&deviceServices);
|
||||||
if (hr == E_ACCESSDENIED) {
|
if (hr == E_ACCESSDENIED) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain device services. Please check you have "
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain device services. Please check you have "
|
||||||
"permission to access the device.";
|
"permission to access the device.";
|
||||||
} else {
|
} else {
|
||||||
EMIT_WORKER_ERROR_AND_RETURN_IF_FAILED("Could not obtain device services",
|
EMIT_WORKER_ERROR_AND_RETURN_IF_FAILED("Could not obtain device services",
|
||||||
|
@ -614,7 +614,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onPairedClassicBluetoothDeviceFoun
|
||||||
uuids.append(QBluetoothUuid(uuid));
|
uuids.append(QBluetoothUuid(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Discovered BT device: " << QString::number(address) << btName
|
qCDebug(QT_BT_WINDOWS) << "Discovered BT device: " << QString::number(address) << btName
|
||||||
<< "Num UUIDs" << uuids.count();
|
<< "Num UUIDs" << uuids.count();
|
||||||
|
|
||||||
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, classOfDeviceInt);
|
QBluetoothDeviceInfo info(QBluetoothAddress(address), btName, classOfDeviceInt);
|
||||||
|
@ -668,7 +668,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFoundAsync(IAsy
|
||||||
HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IBluetoothLEDevice> device, PairingCheck pairingCheck)
|
HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IBluetoothLEDevice> device, PairingCheck pairingCheck)
|
||||||
{
|
{
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCDebug(QT_BT_WINRT) << "onBluetoothLEDeviceFound: No device given";
|
qCDebug(QT_BT_WINDOWS) << "onBluetoothLEDeviceFound: No device given";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
QBluetoothDeviceDiscoveryAgent::Error::UnknownError,
|
QBluetoothDeviceDiscoveryAgent::Error::UnknownError,
|
||||||
return S_OK);
|
return S_OK);
|
||||||
if (!deviceInfo) {
|
if (!deviceInfo) {
|
||||||
qCDebug(QT_BT_WINRT) << "onBluetoothLEDeviceFound: Could not obtain device information";
|
qCDebug(QT_BT_WINDOWS) << "onBluetoothLEDeviceFound: Could not obtain device information";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
ComPtr<IDeviceInformation2> deviceInfo2;
|
ComPtr<IDeviceInformation2> deviceInfo2;
|
||||||
|
@ -718,7 +718,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
|
||||||
if (status != AsyncStatus::Completed) {
|
if (status != AsyncStatus::Completed) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not pair device";
|
qCDebug(QT_BT_WINDOWS) << "Could not pair device";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,7 +727,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
hr = op->GetResults(&result);
|
hr = op->GetResults(&result);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
emit tPointer->errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit tPointer->errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain pairing result";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain pairing result";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,7 +735,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
hr = result.Get()->get_Status(&pairingStatus);
|
hr = result.Get()->get_Status(&pairingStatus);
|
||||||
if (FAILED(hr) || pairingStatus != DevicePairingResultStatus_Paired) {
|
if (FAILED(hr) || pairingStatus != DevicePairingResultStatus_Paired) {
|
||||||
emit tPointer->errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
emit tPointer->errorOccured(QBluetoothDeviceDiscoveryAgent::UnknownError);
|
||||||
qCWarning(QT_BT_WINRT) << "Device pairing failed";
|
qCWarning(QT_BT_WINDOWS) << "Device pairing failed";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
const qint16 rssi = m_foundLEDevices.value(address);
|
const qint16 rssi = m_foundLEDevices.value(address);
|
||||||
const ManufacturerData manufacturerData = m_foundLEManufacturerData.value(address);
|
const ManufacturerData manufacturerData = m_foundLEManufacturerData.value(address);
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Discovered BTLE device: " << QString::number(address) << btName
|
qCDebug(QT_BT_WINDOWS) << "Discovered BTLE device: " << QString::number(address) << btName
|
||||||
<< "Num UUIDs" << uuids.count() << "RSSI:" << rssi
|
<< "Num UUIDs" << uuids.count() << "RSSI:" << rssi
|
||||||
<< "Num manufacturer data" << manufacturerData.count();
|
<< "Num manufacturer data" << manufacturerData.count();
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IBluetoothLEDevice> device)
|
HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IBluetoothLEDevice> device)
|
||||||
{
|
{
|
||||||
if (!device) {
|
if (!device) {
|
||||||
qCDebug(QT_BT_WINRT) << "onBluetoothLEDeviceFound: No device given";
|
qCDebug(QT_BT_WINDOWS) << "onBluetoothLEDeviceFound: No device given";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
QBluetoothDeviceDiscoveryAgent::Error::UnknownError,
|
QBluetoothDeviceDiscoveryAgent::Error::UnknownError,
|
||||||
return S_OK);
|
return S_OK);
|
||||||
if (!deviceInfo) {
|
if (!deviceInfo) {
|
||||||
qCDebug(QT_BT_WINRT) << "onBluetoothLEDeviceFound: Could not obtain device information";
|
qCDebug(QT_BT_WINDOWS) << "onBluetoothLEDeviceFound: Could not obtain device information";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
ComPtr<IDeviceInformation2> deviceInfo2;
|
ComPtr<IDeviceInformation2> deviceInfo2;
|
||||||
|
@ -886,7 +886,7 @@ HRESULT QWinRTBluetoothDeviceDiscoveryWorker::onBluetoothLEDeviceFound(ComPtr<IB
|
||||||
}
|
}
|
||||||
const ManufacturerData manufacturerData = m_foundLEManufacturerData.value(address);
|
const ManufacturerData manufacturerData = m_foundLEManufacturerData.value(address);
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Discovered BTLE device: " << QString::number(address) << btName
|
qCDebug(QT_BT_WINDOWS) << "Discovered BTLE device: " << QString::number(address) << btName
|
||||||
<< "Num UUIDs" << uuids.count() << "RSSI:" << rssi
|
<< "Num UUIDs" << uuids.count() << "RSSI:" << rssi
|
||||||
<< "Num manufacturer data" << manufacturerData.count();
|
<< "Num manufacturer data" << manufacturerData.count();
|
||||||
|
|
||||||
|
@ -974,7 +974,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::registerDevice(const QBluetoothDevic
|
||||||
for (QList<QBluetoothDeviceInfo>::iterator iter = discoveredDevices.begin();
|
for (QList<QBluetoothDeviceInfo>::iterator iter = discoveredDevices.begin();
|
||||||
iter != discoveredDevices.end(); ++iter) {
|
iter != discoveredDevices.end(); ++iter) {
|
||||||
if (iter->address() == info.address()) {
|
if (iter->address() == info.address()) {
|
||||||
qCDebug(QT_BT_WINRT) << "Updating device" << iter->name() << iter->address();
|
qCDebug(QT_BT_WINDOWS) << "Updating device" << iter->name() << iter->address();
|
||||||
// merge service uuids
|
// merge service uuids
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QList<QBluetoothUuid> uuids = iter->serviceUuids();
|
QList<QBluetoothUuid> uuids = iter->serviceUuids();
|
||||||
|
@ -1007,7 +1007,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::updateDeviceData(const QBluetoothAdd
|
||||||
for (QList<QBluetoothDeviceInfo>::iterator iter = discoveredDevices.begin();
|
for (QList<QBluetoothDeviceInfo>::iterator iter = discoveredDevices.begin();
|
||||||
iter != discoveredDevices.end(); ++iter) {
|
iter != discoveredDevices.end(); ++iter) {
|
||||||
if (iter->address() == address) {
|
if (iter->address() == address) {
|
||||||
qCDebug(QT_BT_WINRT) << "Updating data for device" << iter->name() << iter->address();
|
qCDebug(QT_BT_WINDOWS) << "Updating data for device" << iter->name() << iter->address();
|
||||||
if (fields.testFlag(QBluetoothDeviceInfo::Field::RSSI))
|
if (fields.testFlag(QBluetoothDeviceInfo::Field::RSSI))
|
||||||
iter->setRssi(rssi);
|
iter->setRssi(rssi);
|
||||||
if (fields.testFlag(QBluetoothDeviceInfo::Field::ManufacturerData))
|
if (fields.testFlag(QBluetoothDeviceInfo::Field::ManufacturerData))
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef ITypedEventHandler<StreamSocketListener *, StreamSocketListenerConnectio
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
QHash<QBluetoothServerPrivate *, int> __fakeServerPorts;
|
QHash<QBluetoothServerPrivate *, int> __fakeServerPorts;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ HRESULT QBluetoothServerPrivate::handleClientConnection(IStreamSocketListener *l
|
||||||
{
|
{
|
||||||
Q_Q(QBluetoothServer);
|
Q_Q(QBluetoothServer);
|
||||||
if (!socketListener || socketListener.Get() != listener) {
|
if (!socketListener || socketListener.Get() != listener) {
|
||||||
qCDebug(QT_BT_WINRT) << "Accepting connection from wrong listener. We should not be here.";
|
qCDebug(QT_BT_WINDOWS) << "Accepting connection from wrong listener. We should not be here.";
|
||||||
Q_UNREACHABLE();
|
Q_UNREACHABLE();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -132,12 +132,12 @@ HRESULT QBluetoothServerPrivate::handleClientConnection(IStreamSocketListener *l
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
QMutexLocker locker(&pendingConnectionsMutex);
|
QMutexLocker locker(&pendingConnectionsMutex);
|
||||||
if (pendingConnections.count() < maxPendingConnections) {
|
if (pendingConnections.count() < maxPendingConnections) {
|
||||||
qCDebug(QT_BT_WINRT) << "Accepting connection";
|
qCDebug(QT_BT_WINDOWS) << "Accepting connection";
|
||||||
pendingConnections.append(socket);
|
pendingConnections.append(socket);
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
q->newConnection();
|
q->newConnection();
|
||||||
} else {
|
} else {
|
||||||
qCDebug(QT_BT_WINRT) << "Refusing connection";
|
qCDebug(QT_BT_WINDOWS) << "Refusing connection";
|
||||||
}
|
}
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -185,9 +185,9 @@ bool QBluetoothServer::listen(const QBluetoothAddress &address, quint16 port)
|
||||||
if (__fakeServerPorts.key(port) == 0) {
|
if (__fakeServerPorts.key(port) == 0) {
|
||||||
__fakeServerPorts[d] = port;
|
__fakeServerPorts[d] = port;
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Port" << port << "registered";
|
qCDebug(QT_BT_WINDOWS) << "Port" << port << "registered";
|
||||||
} else {
|
} else {
|
||||||
qCWarning(QT_BT_WINRT) << "server with port" << port << "already registered or port invalid";
|
qCWarning(QT_BT_WINDOWS) << "server with port" << port << "already registered or port invalid";
|
||||||
d->m_lastError = ServiceAlreadyRegisteredError;
|
d->m_lastError = ServiceAlreadyRegisteredError;
|
||||||
emit errorOccurred(d->m_lastError);
|
emit errorOccurred(d->m_lastError);
|
||||||
return false;
|
return false;
|
||||||
|
@ -201,7 +201,7 @@ void QBluetoothServer::setMaxPendingConnections(int numConnections)
|
||||||
Q_D(QBluetoothServer);
|
Q_D(QBluetoothServer);
|
||||||
QMutexLocker locker(&d->pendingConnectionsMutex);
|
QMutexLocker locker(&d->pendingConnectionsMutex);
|
||||||
if (d->pendingConnections.count() > numConnections) {
|
if (d->pendingConnections.count() > numConnections) {
|
||||||
qCWarning(QT_BT_WINRT) << "There are currently more than" << numConnections << "connections"
|
qCWarning(QT_BT_WINDOWS) << "There are currently more than" << numConnections << "connections"
|
||||||
<< "pending. Number of maximum pending connections was not changed.";
|
<< "pending. Number of maximum pending connections was not changed.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ typedef Collections::IIterator<ValueItem *> ValueIterator;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
#define TYPE_UINT8 8
|
#define TYPE_UINT8 8
|
||||||
#define TYPE_UINT16 9
|
#define TYPE_UINT16 9
|
||||||
|
@ -132,7 +132,7 @@ void QWinRTBluetoothServiceDiscoveryWorker::start()
|
||||||
HRESULT QWinRTBluetoothServiceDiscoveryWorker::onBluetoothDeviceFoundAsync(IAsyncOperation<BluetoothDevice *> *op, AsyncStatus status)
|
HRESULT QWinRTBluetoothServiceDiscoveryWorker::onBluetoothDeviceFoundAsync(IAsyncOperation<BluetoothDevice *> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status != Completed) {
|
if (status != Completed) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not find device";
|
qCDebug(QT_BT_WINDOWS) << "Could not find device";
|
||||||
emit errorOccured();
|
emit errorOccured();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ HRESULT QWinRTBluetoothServiceDiscoveryWorker::onBluetoothDeviceFoundAsync(IAsyn
|
||||||
([address, this](IAsyncOperation<RfcommDeviceServicesResult *> *op, AsyncStatus status)
|
([address, this](IAsyncOperation<RfcommDeviceServicesResult *> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status != Completed) {
|
if (status != Completed) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain service list";
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain service list";
|
||||||
emit errorOccured();
|
emit errorOccured();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -277,33 +277,33 @@ void QWinRTBluetoothServiceDiscoveryWorker::processServiceSearchResult(quint64 a
|
||||||
hr = dataReader->ReadByte(&value);
|
hr = dataReader->ReadByte(&value);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
info.setAttribute(key, value);
|
info.setAttribute(key, value);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT8" << Qt::hex << value;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT8" << Qt::hex << value;
|
||||||
} else if (type == TYPE_UINT16) {
|
} else if (type == TYPE_UINT16) {
|
||||||
quint16 value;
|
quint16 value;
|
||||||
hr = dataReader->ReadUInt16(&value);
|
hr = dataReader->ReadUInt16(&value);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
info.setAttribute(key, value);
|
info.setAttribute(key, value);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT16" << Qt::hex << value;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT16" << Qt::hex << value;
|
||||||
} else if (type == TYPE_UINT32) {
|
} else if (type == TYPE_UINT32) {
|
||||||
quint32 value;
|
quint32 value;
|
||||||
hr = dataReader->ReadUInt32(&value);
|
hr = dataReader->ReadUInt32(&value);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
info.setAttribute(key, value);
|
info.setAttribute(key, value);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT32" << Qt::hex << value;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UINT32" << Qt::hex << value;
|
||||||
} else if (type == TYPE_SHORT_UUID) {
|
} else if (type == TYPE_SHORT_UUID) {
|
||||||
quint16 value;
|
quint16 value;
|
||||||
hr = dataReader->ReadUInt16(&value);
|
hr = dataReader->ReadUInt16(&value);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
const QBluetoothUuid uuid(value);
|
const QBluetoothUuid uuid(value);
|
||||||
info.setAttribute(key, uuid);
|
info.setAttribute(key, uuid);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
|
||||||
} else if (type == TYPE_LONG_UUID) {
|
} else if (type == TYPE_LONG_UUID) {
|
||||||
GUID value;
|
GUID value;
|
||||||
hr = dataReader->ReadGuid(&value);
|
hr = dataReader->ReadGuid(&value);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
const QBluetoothUuid uuid(value);
|
const QBluetoothUuid uuid(value);
|
||||||
info.setAttribute(key, uuid);
|
info.setAttribute(key, uuid);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "UUID" << Qt::hex << uuid;
|
||||||
} else if (type == TYPE_STRING) {
|
} else if (type == TYPE_STRING) {
|
||||||
BYTE length;
|
BYTE length;
|
||||||
hr = dataReader->ReadByte(&length);
|
hr = dataReader->ReadByte(&length);
|
||||||
|
@ -313,18 +313,18 @@ void QWinRTBluetoothServiceDiscoveryWorker::processServiceSearchResult(quint64 a
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
const QString str = QString::fromWCharArray(WindowsGetStringRawBuffer(value.Get(), nullptr));
|
const QString str = QString::fromWCharArray(WindowsGetStringRawBuffer(value.Get(), nullptr));
|
||||||
info.setAttribute(key, str);
|
info.setAttribute(key, str);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "STRING" << str;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "STRING" << str;
|
||||||
} else if (type == TYPE_SEQUENCE) {
|
} else if (type == TYPE_SEQUENCE) {
|
||||||
bool ok;
|
bool ok;
|
||||||
QBluetoothServiceInfo::Sequence sequence = readSequence(dataReader, &ok, nullptr);
|
QBluetoothServiceInfo::Sequence sequence = readSequence(dataReader, &ok, nullptr);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
info.setAttribute(key, sequence);
|
info.setAttribute(key, sequence);
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE" << sequence;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE" << sequence;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE ERROR";
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type << "SEQUENCE ERROR";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(QT_BT_WINRT) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type;
|
qCDebug(QT_BT_WINDOWS) << "UUID" << uuid << "KEY" << Qt::hex << key << "TYPE" << Qt::dec << type;
|
||||||
}
|
}
|
||||||
hr = iterator->MoveNext(¤t);
|
hr = iterator->MoveNext(¤t);
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ QBluetoothServiceInfo::Sequence QWinRTBluetoothServiceDiscoveryWorker::readSeque
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
qCDebug(QT_BT_WINRT) << "SEQUENCE ERROR" << type;
|
qCDebug(QT_BT_WINDOWS) << "SEQUENCE ERROR" << type;
|
||||||
result.clear();
|
result.clear();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -561,7 +561,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::processFoundService(quint64 deviceA
|
||||||
|
|
||||||
if (!isDuplicatedService(returnInfo)) {
|
if (!isDuplicatedService(returnInfo)) {
|
||||||
discoveredServices.append(returnInfo);
|
discoveredServices.append(returnInfo);
|
||||||
qCDebug(QT_BT_WINRT) << "Discovered services" << discoveredDevices.at(0).address().toString()
|
qCDebug(QT_BT_WINDOWS) << "Discovered services" << discoveredDevices.at(0).address().toString()
|
||||||
<< returnInfo.serviceName() << returnInfo.serviceUuid()
|
<< returnInfo.serviceName() << returnInfo.serviceUuid()
|
||||||
<< ">>>" << returnInfo.serviceClassUuids();
|
<< ">>>" << returnInfo.serviceClassUuids();
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ using namespace ABI::Windows::Storage::Streams;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
#define TYPE_VOID 0
|
#define TYPE_VOID 0
|
||||||
#define TYPE_UINT8 8
|
#define TYPE_UINT8 8
|
||||||
|
@ -133,7 +133,7 @@ bool writeStringHelper(const QString &string, ComPtr<IDataWriter> writer)
|
||||||
const int stringLength = string.length();
|
const int stringLength = string.length();
|
||||||
unsigned char type = TYPE_STRING_BASE;
|
unsigned char type = TYPE_STRING_BASE;
|
||||||
if (stringLength < 0) {
|
if (stringLength < 0) {
|
||||||
qCWarning(QT_BT_WINRT) << "Can not write invalid string value to buffer";
|
qCWarning(QT_BT_WINDOWS) << "Can not write invalid string value to buffer";
|
||||||
return false;
|
return false;
|
||||||
} if (stringLength <= 0xff) {
|
} if (stringLength <= 0xff) {
|
||||||
type += 5;
|
type += 5;
|
||||||
|
@ -159,7 +159,7 @@ bool writeStringHelper(const QString &string, ComPtr<IDataWriter> writer)
|
||||||
hr = writer->WriteString(stringRef.Get(), &bytesWritten);
|
hr = writer->WriteString(stringRef.Get(), &bytesWritten);
|
||||||
RETURN_FALSE_IF_FAILED("Could not write string to buffer.");
|
RETURN_FALSE_IF_FAILED("Could not write string to buffer.");
|
||||||
if (bytesWritten != string.length()) {
|
if (bytesWritten != string.length()) {
|
||||||
qCWarning(QT_BT_WINRT) << "Did not write full value to buffer";
|
qCWarning(QT_BT_WINDOWS) << "Did not write full value to buffer";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -180,7 +180,7 @@ bool repairProfileDescriptorListIfNeeded(ComPtr<IBuffer> &buffer)
|
||||||
hr = reader->ReadByte(&type);
|
hr = reader->ReadByte(&type);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
if (!typeIsOfBase(type, TYPE_SEQUENCE_BASE)) {
|
if (!typeIsOfBase(type, TYPE_SEQUENCE_BASE)) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "Malformed profile descriptor list read";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "Malformed profile descriptor list read";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ bool repairProfileDescriptorListIfNeeded(ComPtr<IBuffer> &buffer)
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
// We have to "repair" the structure if the outer sequence contains a uuid directly
|
// We have to "repair" the structure if the outer sequence contains a uuid directly
|
||||||
if (type == TYPE_UUID16 && length == 4) {
|
if (type == TYPE_UUID16 && length == 4) {
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Repairing profile descriptor list";
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Repairing profile descriptor list";
|
||||||
quint16 uuid;
|
quint16 uuid;
|
||||||
hr = reader->ReadUInt16(&uuid);
|
hr = reader->ReadUInt16(&uuid);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
|
@ -234,68 +234,68 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
|
|
||||||
switch (int(attribute.type())) {
|
switch (int(attribute.type())) {
|
||||||
case QMetaType::Void:
|
case QMetaType::Void:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Void:";
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Void:";
|
||||||
hr = writer->WriteByte(TYPE_VOID);
|
hr = writer->WriteByte(TYPE_VOID);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::UChar:
|
case QMetaType::UChar:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UChar:" << attribute.value<quint8>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UChar:" << attribute.value<quint8>();
|
||||||
hr = writer->WriteByte(TYPE_UINT8);
|
hr = writer->WriteByte(TYPE_UINT8);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteByte(attribute.value<quint8>());
|
hr = writer->WriteByte(attribute.value<quint8>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::UShort:
|
case QMetaType::UShort:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UShort:" << attribute.value<quint16>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UShort:" << attribute.value<quint16>();
|
||||||
hr = writer->WriteByte(TYPE_UINT16);
|
hr = writer->WriteByte(TYPE_UINT16);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteUInt16(attribute.value<quint16>());
|
hr = writer->WriteUInt16(attribute.value<quint16>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::UInt:
|
case QMetaType::UInt:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UInt:" << attribute.value<quint32>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::UInt:" << attribute.value<quint32>();
|
||||||
hr = writer->WriteByte(TYPE_UINT32);
|
hr = writer->WriteByte(TYPE_UINT32);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteUInt32(attribute.value<quint32>());
|
hr = writer->WriteUInt32(attribute.value<quint32>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::ULongLong:
|
case QMetaType::ULongLong:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::ULongLong:" << attribute.value<quint64>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::ULongLong:" << attribute.value<quint64>();
|
||||||
hr = writer->WriteByte(TYPE_UINT64);
|
hr = writer->WriteByte(TYPE_UINT64);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteUInt64(attribute.value<quint64>());
|
hr = writer->WriteUInt64(attribute.value<quint64>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::Char:
|
case QMetaType::Char:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Char:" << attribute.value<qint8>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Char:" << attribute.value<qint8>();
|
||||||
hr = writer->WriteByte(TYPE_INT8);
|
hr = writer->WriteByte(TYPE_INT8);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteByte(attribute.value<qint8>());
|
hr = writer->WriteByte(attribute.value<qint8>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::Short:
|
case QMetaType::Short:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Short:" << attribute.value<qint16>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Short:" << attribute.value<qint16>();
|
||||||
hr = writer->WriteByte(TYPE_INT16);
|
hr = writer->WriteByte(TYPE_INT16);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteInt16(attribute.value<qint16>());
|
hr = writer->WriteInt16(attribute.value<qint16>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::Int:
|
case QMetaType::Int:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Int:" << attribute.value<qint32>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Int:" << attribute.value<qint32>();
|
||||||
hr = writer->WriteByte(TYPE_INT32);
|
hr = writer->WriteByte(TYPE_INT32);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteInt32(attribute.value<qint32>());
|
hr = writer->WriteInt32(attribute.value<qint32>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::LongLong:
|
case QMetaType::LongLong:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::LongLong:" << attribute.value<qint64>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::LongLong:" << attribute.value<qint64>();
|
||||||
hr = writer->WriteByte(TYPE_INT64);
|
hr = writer->WriteByte(TYPE_INT64);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteInt64(attribute.value<qint64>());
|
hr = writer->WriteInt64(attribute.value<qint64>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::QByteArray: {
|
case QMetaType::QByteArray: {
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::QByteArray:" << attribute.value<QString>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::QByteArray:" << attribute.value<QString>();
|
||||||
const QString stringValue = QString::fromLatin1(attribute.value<QByteArray>().toHex());
|
const QString stringValue = QString::fromLatin1(attribute.value<QByteArray>().toHex());
|
||||||
const bool writeSuccess = writeStringHelper(stringValue, writer);
|
const bool writeSuccess = writeStringHelper(stringValue, writer);
|
||||||
if (!writeSuccess)
|
if (!writeSuccess)
|
||||||
|
@ -303,7 +303,7 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMetaType::QString: {
|
case QMetaType::QString: {
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::QString:" << attribute.value<QString>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::QString:" << attribute.value<QString>();
|
||||||
const QString stringValue = attribute.value<QString>();
|
const QString stringValue = attribute.value<QString>();
|
||||||
const bool writeSucces = writeStringHelper(stringValue, writer);
|
const bool writeSucces = writeStringHelper(stringValue, writer);
|
||||||
if (!writeSucces)
|
if (!writeSucces)
|
||||||
|
@ -311,14 +311,14 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QMetaType::Bool:
|
case QMetaType::Bool:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Bool:" << attribute.value<bool>();
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering attribute of type QMetaType::Bool:" << attribute.value<bool>();
|
||||||
hr = writer->WriteByte(TYPE_BOOLEAN);
|
hr = writer->WriteByte(TYPE_BOOLEAN);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteByte(attribute.value<bool>());
|
hr = writer->WriteByte(attribute.value<bool>());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case QMetaType::QUrl:
|
case QMetaType::QUrl:
|
||||||
qCWarning(QT_BT_WINRT) << "Don't know how to register QMetaType::QUrl";
|
qCWarning(QT_BT_WINDOWS) << "Don't know how to register QMetaType::QUrl";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
break;
|
break;
|
||||||
case QVariant::UserType:
|
case QVariant::UserType:
|
||||||
|
@ -327,17 +327,17 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
const int minimumSize = uuid.minimumSize();
|
const int minimumSize = uuid.minimumSize();
|
||||||
switch (uuid.minimumSize()) {
|
switch (uuid.minimumSize()) {
|
||||||
case 0:
|
case 0:
|
||||||
qCWarning(QT_BT_WINRT) << "Don't know how to register Uuid of length 0";
|
qCWarning(QT_BT_WINDOWS) << "Don't know how to register Uuid of length 0";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
case 2:
|
case 2:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering Uuid attribute with length 2:" << uuid;
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering Uuid attribute with length 2:" << uuid;
|
||||||
hr = writer->WriteByte(TYPE_UUID16);
|
hr = writer->WriteByte(TYPE_UUID16);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteUInt16(uuid.toUInt16());
|
hr = writer->WriteUInt16(uuid.toUInt16());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering Uuid attribute with length 4:" << uuid;
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering Uuid attribute with length 4:" << uuid;
|
||||||
hr = writer->WriteByte(TYPE_UUID32);
|
hr = writer->WriteByte(TYPE_UUID32);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteUInt32(uuid.toUInt32());
|
hr = writer->WriteUInt32(uuid.toUInt32());
|
||||||
|
@ -345,7 +345,7 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
default:
|
default:
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registering Uuid attribute:" << uuid;
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registering Uuid attribute:" << uuid;
|
||||||
hr = writer->WriteByte(TYPE_UUID128);
|
hr = writer->WriteByte(TYPE_UUID128);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = writer->WriteGuid(uuid);
|
hr = writer->WriteGuid(uuid);
|
||||||
|
@ -353,7 +353,7 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (attribute.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
|
} else if (attribute.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
|
||||||
qCDebug(QT_BT_WINRT) << "Registering sequence attribute";
|
qCDebug(QT_BT_WINDOWS) << "Registering sequence attribute";
|
||||||
const QBluetoothServiceInfo::Sequence *sequence =
|
const QBluetoothServiceInfo::Sequence *sequence =
|
||||||
static_cast<const QBluetoothServiceInfo::Sequence *>(attribute.data());
|
static_cast<const QBluetoothServiceInfo::Sequence *>(attribute.data());
|
||||||
ComPtr<IDataWriter> tmpWriter;
|
ComPtr<IDataWriter> tmpWriter;
|
||||||
|
@ -363,7 +363,7 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
for (const QVariant &v : *sequence) {
|
for (const QVariant &v : *sequence) {
|
||||||
ComPtr<IBuffer> tmpBuffer = bufferFromAttribute(v);
|
ComPtr<IBuffer> tmpBuffer = bufferFromAttribute(v);
|
||||||
if (!tmpBuffer) {
|
if (!tmpBuffer) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not create buffer from attribute in sequence";
|
qCWarning(QT_BT_WINDOWS) << "Could not create buffer from attribute in sequence";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
quint32 l;
|
quint32 l;
|
||||||
|
@ -403,14 +403,14 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
|
||||||
// write sequence data
|
// write sequence data
|
||||||
hr = writer->WriteBuffer(tmpBuffer.Get());
|
hr = writer->WriteBuffer(tmpBuffer.Get());
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registered sequence attribute with length" << length;
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registered sequence attribute with length" << length;
|
||||||
} else if (attribute.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
|
} else if (attribute.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
|
||||||
qCWarning(QT_BT_WINRT) << "Don't know how to register user type Alternative";
|
qCWarning(QT_BT_WINDOWS) << "Don't know how to register user type Alternative";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qCWarning(QT_BT_WINRT) << "Unknown variant type" << attribute.userType();
|
qCWarning(QT_BT_WINDOWS) << "Unknown variant type" << attribute.userType();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
ComPtr<IBuffer> buffer;
|
ComPtr<IBuffer> buffer;
|
||||||
|
@ -440,7 +440,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (protocolDescriptor(QBluetoothUuid::ProtocolUuid::Rfcomm).isEmpty()) {
|
if (protocolDescriptor(QBluetoothUuid::ProtocolUuid::Rfcomm).isEmpty()) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "Only RFCOMM services can be registered on WinRT";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "Only RFCOMM services can be registered on WinRT";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = QWinRTFunctions::await(op, serviceProvider.GetAddressOf());
|
hr = QWinRTFunctions::await(op, serviceProvider.GetAddressOf());
|
||||||
if (hr == HRESULT_FROM_WIN32(ERROR_DEVICE_NOT_AVAILABLE)) {
|
if (hr == HRESULT_FROM_WIN32(ERROR_DEVICE_NOT_AVAILABLE)) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "No bluetooth adapter available.";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "No bluetooth adapter available.";
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
|
@ -474,7 +474,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
|
||||||
|
|
||||||
ComPtr<IStreamSocketListener> listener = sPriv->listener();
|
ComPtr<IStreamSocketListener> listener = sPriv->listener();
|
||||||
if (!listener) {
|
if (!listener) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "Could not obtain listener from server.";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "Could not obtain listener from server.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,17 +493,17 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress &loca
|
||||||
|
|
||||||
result = writeSdpAttributes();
|
result = writeSdpAttributes();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not write SDP attributes.";
|
qCWarning(QT_BT_WINDOWS) << "Could not write SDP attributes.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qCDebug(QT_BT_WINRT) << "SDP attributes written.";
|
qCDebug(QT_BT_WINDOWS) << "SDP attributes written.";
|
||||||
|
|
||||||
ComPtr<IRfcommServiceProvider2> serviceProvider2;
|
ComPtr<IRfcommServiceProvider2> serviceProvider2;
|
||||||
hr = serviceProvider.As(&serviceProvider2);
|
hr = serviceProvider.As(&serviceProvider2);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
hr = serviceProvider2->StartAdvertisingWithRadioDiscoverability(listener.Get(), true);
|
hr = serviceProvider2->StartAdvertisingWithRadioDiscoverability(listener.Get(), true);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "Could not start advertising. Check your SDP data.";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "Could not start advertising. Check your SDP data.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ bool QBluetoothServiceInfoPrivate::writeSdpAttributes()
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ComPtr<IBuffer> buffer = bufferFromAttribute(attribute);
|
ComPtr<IBuffer> buffer = bufferFromAttribute(attribute);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not create buffer from attribute with id:" << key;
|
qCWarning(QT_BT_WINDOWS) << "Could not create buffer from attribute with id:" << key;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +567,7 @@ bool QBluetoothServiceInfoPrivate::writeSdpAttributes()
|
||||||
// WinRT accept the list without breaking existing apps we have to repair this structure.
|
// WinRT accept the list without breaking existing apps we have to repair this structure.
|
||||||
if (key == QBluetoothServiceInfo::BluetoothProfileDescriptorList) {
|
if (key == QBluetoothServiceInfo::BluetoothProfileDescriptorList) {
|
||||||
if (!repairProfileDescriptorListIfNeeded(buffer)) {
|
if (!repairProfileDescriptorListIfNeeded(buffer)) {
|
||||||
qCWarning(QT_BT_WINRT) << Q_FUNC_INFO << "Error while checking/repairing structure of profile descriptor list";
|
qCWarning(QT_BT_WINDOWS) << Q_FUNC_INFO << "Error while checking/repairing structure of profile descriptor list";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,7 +582,7 @@ bool QBluetoothServiceInfoPrivate::writeSdpAttributes()
|
||||||
hr = rawAttributes->Insert(key, buffer.Get(), &replaced);
|
hr = rawAttributes->Insert(key, buffer.Get(), &replaced);
|
||||||
Q_ASSERT_SUCCEEDED(hr);
|
Q_ASSERT_SUCCEEDED(hr);
|
||||||
Q_ASSERT(!replaced);
|
Q_ASSERT(!replaced);
|
||||||
qCDebug(QT_BT_WINRT) << Q_FUNC_INFO << "Registered attribute" << QString::number(key, 16).rightJustified(4, '0') << "with value" << attribute;
|
qCDebug(QT_BT_WINDOWS) << Q_FUNC_INFO << "Registered attribute" << QString::number(key, 16).rightJustified(4, '0') << "with value" << attribute;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef IAsyncOperationWithProgress<IBuffer *, UINT32> IAsyncBufferOperation;
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
struct SocketGlobal
|
struct SocketGlobal
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ static qint64 writeIOStream(ComPtr<IOutputStream> stream, const char *data, qint
|
||||||
{
|
{
|
||||||
ComPtr<IBuffer> buffer;
|
ComPtr<IBuffer> buffer;
|
||||||
if (len > UINT32_MAX) {
|
if (len > UINT32_MAX) {
|
||||||
qCWarning(QT_BT_WINRT) << "writeIOStream can only write up to" << UINT32_MAX << "bytes.";
|
qCWarning(QT_BT_WINDOWS) << "writeIOStream can only write up to" << UINT32_MAX << "bytes.";
|
||||||
len = UINT32_MAX;
|
len = UINT32_MAX;
|
||||||
}
|
}
|
||||||
quint32 ulen = static_cast<quint32>(len);
|
quint32 ulen = static_cast<quint32>(len);
|
||||||
|
@ -412,7 +412,7 @@ void QBluetoothSocketPrivateWinRT::connectToService(
|
||||||
|
|
||||||
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState
|
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState
|
||||||
&& q->state() != QBluetoothSocket::SocketState::ServiceLookupState) {
|
&& q->state() != QBluetoothSocket::SocketState::ServiceLookupState) {
|
||||||
qCWarning(QT_BT_WINRT) << "QBluetoothSocket::connectToService called on busy socket";
|
qCWarning(QT_BT_WINDOWS) << "QBluetoothSocket::connectToService called on busy socket";
|
||||||
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
||||||
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
||||||
return;
|
return;
|
||||||
|
@ -467,10 +467,10 @@ void QBluetoothSocketPrivateWinRT::connectToService(
|
||||||
// try doing service discovery to see if we can find the socket
|
// try doing service discovery to see if we can find the socket
|
||||||
if (service.serviceUuid().isNull()
|
if (service.serviceUuid().isNull()
|
||||||
&& !service.serviceClassUuids().contains(QBluetoothUuid::ServiceClassUuid::SerialPort)) {
|
&& !service.serviceClassUuids().contains(QBluetoothUuid::ServiceClassUuid::SerialPort)) {
|
||||||
qCWarning(QT_BT_WINRT) << "No port, no PSM, and no UUID provided. Unable to connect";
|
qCWarning(QT_BT_WINDOWS) << "No port, no PSM, and no UUID provided. Unable to connect";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qCDebug(QT_BT_WINRT) << "Need a port/psm, doing discovery";
|
qCDebug(QT_BT_WINDOWS) << "Need a port/psm, doing discovery";
|
||||||
q->doDeviceDiscovery(service, openMode);
|
q->doDeviceDiscovery(service, openMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,7 @@ void QBluetoothSocketPrivateWinRT::connectToService(
|
||||||
Q_Q(QBluetoothSocket);
|
Q_Q(QBluetoothSocket);
|
||||||
|
|
||||||
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState) {
|
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState) {
|
||||||
qCWarning(QT_BT_WINRT) << "QBluetoothSocketPrivateWinRT::connectToService called on busy socket";
|
qCWarning(QT_BT_WINDOWS) << "QBluetoothSocketPrivateWinRT::connectToService called on busy socket";
|
||||||
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
||||||
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
||||||
return;
|
return;
|
||||||
|
@ -506,7 +506,7 @@ void QBluetoothSocketPrivateWinRT::connectToService(
|
||||||
Q_Q(QBluetoothSocket);
|
Q_Q(QBluetoothSocket);
|
||||||
|
|
||||||
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState) {
|
if (q->state() != QBluetoothSocket::SocketState::UnconnectedState) {
|
||||||
qCWarning(QT_BT_WINRT) << "QBluetoothSocketPrivateWinRT::connectToService called on busy socket";
|
qCWarning(QT_BT_WINDOWS) << "QBluetoothSocketPrivateWinRT::connectToService called on busy socket";
|
||||||
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
errorString = QBluetoothSocket::tr("Trying to connect while connection is in progress");
|
||||||
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
||||||
return;
|
return;
|
||||||
|
@ -590,7 +590,7 @@ quint16 QBluetoothSocketPrivateWinRT::localPort() const
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const uint port = qt_QStringFromHString(localPortString).toUInt(&ok);
|
const uint port = qt_QStringFromHString(localPortString).toUInt(&ok);
|
||||||
if (!ok || port > UINT16_MAX) {
|
if (!ok || port > UINT16_MAX) {
|
||||||
qCWarning(QT_BT_WINRT) << "Unexpected local port";
|
qCWarning(QT_BT_WINDOWS) << "Unexpected local port";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return quint16(port);
|
return quint16(port);
|
||||||
|
@ -647,7 +647,7 @@ quint16 QBluetoothSocketPrivateWinRT::peerPort() const
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const uint port = qt_QStringFromHString(remotePortString).toUInt(&ok);
|
const uint port = qt_QStringFromHString(remotePortString).toUInt(&ok);
|
||||||
if (!ok || port > UINT16_MAX) {
|
if (!ok || port > UINT16_MAX) {
|
||||||
qCWarning(QT_BT_WINRT) << "Unexpected remote port";
|
qCWarning(QT_BT_WINDOWS) << "Unexpected remote port";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return quint16(port);
|
return quint16(port);
|
||||||
|
@ -670,7 +670,7 @@ qint64 QBluetoothSocketPrivateWinRT::writeData(const char *data, qint64 maxSize)
|
||||||
|
|
||||||
qint64 bytesWritten = writeIOStream(stream, data, maxSize);
|
qint64 bytesWritten = writeIOStream(stream, data, maxSize);
|
||||||
if (bytesWritten < 0) {
|
if (bytesWritten < 0) {
|
||||||
qCWarning(QT_BT_WINRT) << "Socket::writeData: " << state;
|
qCWarning(QT_BT_WINDOWS) << "Socket::writeData: " << state;
|
||||||
errorString = QBluetoothSocket::tr("Cannot read while not connected");
|
errorString = QBluetoothSocket::tr("Cannot read while not connected");
|
||||||
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
q->setSocketError(QBluetoothSocket::SocketError::OperationError);
|
||||||
}
|
}
|
||||||
|
@ -710,7 +710,7 @@ bool QBluetoothSocketPrivateWinRT::setSocketDescriptor(int socketDescriptor, QBl
|
||||||
Q_UNUSED(socketType);
|
Q_UNUSED(socketType);
|
||||||
Q_UNUSED(socketState);
|
Q_UNUSED(socketState);
|
||||||
Q_UNUSED(openMode);
|
Q_UNUSED(openMode);
|
||||||
qCWarning(QT_BT_WINRT) << "No socket descriptor support on WinRT.";
|
qCWarning(QT_BT_WINDOWS) << "No socket descriptor support on WinRT.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class QLowEnergyController
|
\class QLowEnergyController
|
||||||
|
|
|
@ -85,13 +85,13 @@ typedef IGattReadClientCharacteristicConfigurationDescriptorResult IClientCharCo
|
||||||
|
|
||||||
#define WARN_AND_CONTINUE_IF_FAILED(hr, msg) \
|
#define WARN_AND_CONTINUE_IF_FAILED(hr, msg) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
qCWarning(QT_BT_WINRT) << msg; \
|
qCWarning(QT_BT_WINDOWS) << msg; \
|
||||||
continue; \
|
continue; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_FOR_DEVICE_CONNECTION_ERROR_IMPL(this, hr, msg, ret) \
|
#define CHECK_FOR_DEVICE_CONNECTION_ERROR_IMPL(this, hr, msg, ret) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
qCWarning(QT_BT_WINRT) << msg; \
|
qCWarning(QT_BT_WINDOWS) << msg; \
|
||||||
this->unregisterFromStatusChanges(); \
|
this->unregisterFromStatusChanges(); \
|
||||||
this->setError(QLowEnergyController::ConnectionError); \
|
this->setError(QLowEnergyController::ConnectionError); \
|
||||||
this->setState(QLowEnergyController::UnconnectedState); \
|
this->setState(QLowEnergyController::UnconnectedState); \
|
||||||
|
@ -103,13 +103,13 @@ typedef IGattReadClientCharacteristicConfigurationDescriptorResult IClientCharCo
|
||||||
|
|
||||||
#define CHECK_HR_AND_SET_SERVICE_ERROR(hr, msg, service, error, ret) \
|
#define CHECK_HR_AND_SET_SERVICE_ERROR(hr, msg, service, error, ret) \
|
||||||
if (FAILED(hr)) { \
|
if (FAILED(hr)) { \
|
||||||
qCDebug(QT_BT_WINRT) << msg; \
|
qCDebug(QT_BT_WINDOWS) << msg; \
|
||||||
service->setError(error); \
|
service->setError(error); \
|
||||||
ret; \
|
ret; \
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS)
|
||||||
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINRT_SERVICE_THREAD)
|
Q_DECLARE_LOGGING_CATEGORY(QT_BT_WINDOWS_SERVICE_THREAD)
|
||||||
|
|
||||||
static QByteArray byteArrayFromGattResult(const ComPtr<IGattReadResult> &gattResult,
|
static QByteArray byteArrayFromGattResult(const ComPtr<IGattReadResult> &gattResult,
|
||||||
bool isWCharString = false)
|
bool isWCharString = false)
|
||||||
|
@ -118,7 +118,7 @@ static QByteArray byteArrayFromGattResult(const ComPtr<IGattReadResult> &gattRes
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = gattResult->get_Value(&buffer);
|
hr = gattResult->get_Value(&buffer);
|
||||||
if (FAILED(hr) || !buffer) {
|
if (FAILED(hr) || !buffer) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain buffer from GattReadResult";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain buffer from GattReadResult";
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
return byteArrayFromBuffer(buffer, isWCharString);
|
return byteArrayFromBuffer(buffer, isWCharString);
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
QLowEnergyService::DiscoveryMode mode)
|
QLowEnergyService::DiscoveryMode mode)
|
||||||
: mService(service), mMode(mode), mDeviceService(deviceService)
|
: mService(service), mMode(mode), mDeviceService(deviceService)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
}
|
}
|
||||||
|
|
||||||
~QWinRTLowEnergyServiceHandlerNew()
|
~QWinRTLowEnergyServiceHandlerNew()
|
||||||
|
@ -144,7 +144,7 @@ public slots:
|
||||||
void obtainCharList()
|
void obtainCharList()
|
||||||
{
|
{
|
||||||
mIndicateChars.clear();
|
mIndicateChars.clear();
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
ComPtr<IAsyncOperation<GattCharacteristicsResult *>> characteristicsOp;
|
ComPtr<IAsyncOperation<GattCharacteristicsResult *>> characteristicsOp;
|
||||||
ComPtr<IGattCharacteristicsResult> characteristicsResult;
|
ComPtr<IGattCharacteristicsResult> characteristicsResult;
|
||||||
HRESULT hr = mDeviceService->GetCharacteristicsAsync(&characteristicsOp);
|
HRESULT hr = mDeviceService->GetCharacteristicsAsync(&characteristicsOp);
|
||||||
|
@ -172,7 +172,7 @@ public slots:
|
||||||
ComPtr<IGattCharacteristic> characteristic;
|
ComPtr<IGattCharacteristic> characteristic;
|
||||||
hr = characteristics->GetAt(i, &characteristic);
|
hr = characteristics->GetAt(i, &characteristic);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic at" << i;
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic at" << i;
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ public slots:
|
||||||
ComPtr<IGattCharacteristic3> characteristic3;
|
ComPtr<IGattCharacteristic3> characteristic3;
|
||||||
hr = characteristic.As(&characteristic3);
|
hr = characteristic.As(&characteristic3);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not cast characteristic";
|
qCWarning(QT_BT_WINDOWS) << "Could not cast characteristic";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public slots:
|
||||||
ComPtr<IAsyncOperation<GattDescriptorsResult*>> descAsyncResult;
|
ComPtr<IAsyncOperation<GattDescriptorsResult*>> descAsyncResult;
|
||||||
hr = characteristic3->GetDescriptorsAsync(&descAsyncResult);
|
hr = characteristic3->GetDescriptorsAsync(&descAsyncResult);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain list of descriptors";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain list of descriptors";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ public slots:
|
||||||
(IAsyncOperation<GattDescriptorsResult *> *op,
|
(IAsyncOperation<GattDescriptorsResult *> *op,
|
||||||
AsyncStatus status) {
|
AsyncStatus status) {
|
||||||
if (status != AsyncStatus::Completed) {
|
if (status != AsyncStatus::Completed) {
|
||||||
qCWarning(QT_BT_WINRT) << "Descriptor operation unsuccessful";
|
qCWarning(QT_BT_WINDOWS) << "Descriptor operation unsuccessful";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -211,7 +211,7 @@ public slots:
|
||||||
|
|
||||||
HRESULT hr = characteristic->get_AttributeHandle(&handle);
|
HRESULT hr = characteristic->get_AttributeHandle(&handle);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic's attribute handle";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic's attribute handle";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -225,7 +225,7 @@ public slots:
|
||||||
GUID guuid;
|
GUID guuid;
|
||||||
hr = characteristic->get_Uuid(&guuid);
|
hr = characteristic->get_Uuid(&guuid);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic's Uuid";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic's Uuid";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -234,7 +234,7 @@ public slots:
|
||||||
GattCharacteristicProperties properties;
|
GattCharacteristicProperties properties;
|
||||||
hr = characteristic->get_CharacteristicProperties(&properties);
|
hr = characteristic->get_CharacteristicProperties(&properties);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic's properties";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic's properties";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -246,7 +246,7 @@ public slots:
|
||||||
hr = characteristic->ReadValueWithCacheModeAsync(BluetoothCacheMode_Uncached,
|
hr = characteristic->ReadValueWithCacheModeAsync(BluetoothCacheMode_Uncached,
|
||||||
&readOp);
|
&readOp);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not read characteristic";
|
qCWarning(QT_BT_WINDOWS) << "Could not read characteristic";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -254,13 +254,13 @@ public slots:
|
||||||
ComPtr<IGattReadResult> readResult;
|
ComPtr<IGattReadResult> readResult;
|
||||||
hr = QWinRTFunctions::await(readOp, readResult.GetAddressOf());
|
hr = QWinRTFunctions::await(readOp, readResult.GetAddressOf());
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic read result";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic read result";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
if (!readResult)
|
if (!readResult)
|
||||||
qCWarning(QT_BT_WINRT) << "Characteristic read result is null";
|
qCWarning(QT_BT_WINDOWS) << "Characteristic read result is null";
|
||||||
else
|
else
|
||||||
charData.value = byteArrayFromGattResult(readResult);
|
charData.value = byteArrayFromGattResult(readResult);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public slots:
|
||||||
ComPtr<IGattDescriptorsResult> result;
|
ComPtr<IGattDescriptorsResult> result;
|
||||||
hr = op->GetResults(&result);
|
hr = op->GetResults(&result);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain descriptor read result";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain descriptor read result";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -279,7 +279,7 @@ public slots:
|
||||||
GattCommunicationStatus commStatus;
|
GattCommunicationStatus commStatus;
|
||||||
hr = result->get_Status(&commStatus);
|
hr = result->get_Status(&commStatus);
|
||||||
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT) << "Descriptor operation failed";
|
qCWarning(QT_BT_WINDOWS) << "Descriptor operation failed";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -287,7 +287,7 @@ public slots:
|
||||||
|
|
||||||
hr = result->get_Descriptors(&descriptors);
|
hr = result->get_Descriptors(&descriptors);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain list of descriptors";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain list of descriptors";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -296,7 +296,7 @@ public slots:
|
||||||
uint descriptorCount;
|
uint descriptorCount;
|
||||||
hr = descriptors->get_Size(&descriptorCount);
|
hr = descriptors->get_Size(&descriptorCount);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain list of descriptors' size";
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain list of descriptors' size";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
checkAllCharacteristicsDiscovered();
|
checkAllCharacteristicsDiscovered();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -380,7 +380,7 @@ public slots:
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}).Get());
|
}).Get());
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not register descriptor callback";
|
qCWarning(QT_BT_WINDOWS) << "Could not register descriptor callback";
|
||||||
--mCharacteristicsCountToBeDiscovered;
|
--mCharacteristicsCountToBeDiscovered;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -456,7 +456,7 @@ void QLowEnergyControllerPrivateWinRT::init()
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::connectToDevice()
|
void QLowEnergyControllerPrivateWinRT::connectToDevice()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
mAbortPending = false;
|
mAbortPending = false;
|
||||||
Q_Q(QLowEnergyController);
|
Q_Q(QLowEnergyController);
|
||||||
if (remoteDevice.isNull()) {
|
if (remoteDevice.isNull()) {
|
||||||
|
@ -478,7 +478,7 @@ void QLowEnergyControllerPrivateWinRT::connectToDevice()
|
||||||
hr = QWinRTFunctions::await(deviceFromIdOperation, mDevice.GetAddressOf(),
|
hr = QWinRTFunctions::await(deviceFromIdOperation, mDevice.GetAddressOf(),
|
||||||
QWinRTFunctions::ProcessMainThreadEvents, 5000);
|
QWinRTFunctions::ProcessMainThreadEvents, 5000);
|
||||||
if (FAILED(hr) || !mDevice) {
|
if (FAILED(hr) || !mDevice) {
|
||||||
qCWarning(QT_BT_WINRT) << "Could not find LE device";
|
qCWarning(QT_BT_WINDOWS) << "Could not find LE device";
|
||||||
setError(QLowEnergyController::InvalidBluetoothAdapterError);
|
setError(QLowEnergyController::InvalidBluetoothAdapterError);
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
return;
|
return;
|
||||||
|
@ -502,7 +502,7 @@ void QLowEnergyControllerPrivateWinRT::connectToDevice()
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::disconnectFromDevice()
|
void QLowEnergyControllerPrivateWinRT::disconnectFromDevice()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
Q_Q(QLowEnergyController);
|
Q_Q(QLowEnergyController);
|
||||||
setState(QLowEnergyController::ClosingState);
|
setState(QLowEnergyController::ClosingState);
|
||||||
unregisterFromValueChanges();
|
unregisterFromValueChanges();
|
||||||
|
@ -520,7 +520,7 @@ ComPtr<IGattDeviceService> QLowEnergyControllerPrivateWinRT::getNativeService(
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = mDevice->GetGattService(serviceUuid, &deviceService);
|
hr = mDevice->GetGattService(serviceUuid, &deviceService);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native service for Uuid" << serviceUuid;
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native service for Uuid" << serviceUuid;
|
||||||
return deviceService;
|
return deviceService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ ComPtr<IGattCharacteristic> QLowEnergyControllerPrivateWinRT::getNativeCharacter
|
||||||
void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothUuid &serviceUuid,
|
void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothUuid &serviceUuid,
|
||||||
const QBluetoothUuid &charUuid)
|
const QBluetoothUuid &charUuid)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << "Registering characteristic" << charUuid << "in service"
|
qCDebug(QT_BT_WINDOWS) << "Registering characteristic" << charUuid << "in service"
|
||||||
<< serviceUuid << "for value changes";
|
<< serviceUuid << "for value changes";
|
||||||
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
||||||
GUID guuid;
|
GUID guuid;
|
||||||
|
@ -576,7 +576,7 @@ void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothU
|
||||||
}
|
}
|
||||||
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(serviceUuid, charUuid);
|
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(serviceUuid, charUuid);
|
||||||
if (!characteristic) {
|
if (!characteristic) {
|
||||||
qCDebug(QT_BT_WINRT).nospace() << "Could not obtain native characteristic " << charUuid
|
qCDebug(QT_BT_WINDOWS).nospace() << "Could not obtain native characteristic " << charUuid
|
||||||
<< " from service " << serviceUuid << ". Qt will not be able to signal"
|
<< " from service " << serviceUuid << ". Qt will not be able to signal"
|
||||||
<< " changes for this characteristic.";
|
<< " changes for this characteristic.";
|
||||||
return;
|
return;
|
||||||
|
@ -589,23 +589,23 @@ void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothU
|
||||||
&token);
|
&token);
|
||||||
RETURN_IF_FAILED("Could not register characteristic for value changes", return)
|
RETURN_IF_FAILED("Could not register characteristic for value changes", return)
|
||||||
mValueChangedTokens.append(ValueChangedEntry(characteristic, token));
|
mValueChangedTokens.append(ValueChangedEntry(characteristic, token));
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charUuid << "in service"
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charUuid << "in service"
|
||||||
<< serviceUuid << "registered for value changes";
|
<< serviceUuid << "registered for value changes";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::unregisterFromValueChanges()
|
void QLowEnergyControllerPrivateWinRT::unregisterFromValueChanges()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << "Unregistering " << mValueChangedTokens.count() << " value change tokens";
|
qCDebug(QT_BT_WINDOWS) << "Unregistering " << mValueChangedTokens.count() << " value change tokens";
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
|
||||||
if (!entry.characteristic) {
|
if (!entry.characteristic) {
|
||||||
qCWarning(QT_BT_WINRT) << "Unregistering from value changes for characteristic failed."
|
qCWarning(QT_BT_WINDOWS) << "Unregistering from value changes for characteristic failed."
|
||||||
<< "Characteristic has been deleted";
|
<< "Characteristic has been deleted";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hr = entry.characteristic->remove_ValueChanged(entry.token);
|
hr = entry.characteristic->remove_ValueChanged(entry.token);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
qCWarning(QT_BT_WINRT) << "Unregistering from value changes for characteristic failed.";
|
qCWarning(QT_BT_WINDOWS) << "Unregistering from value changes for characteristic failed.";
|
||||||
}
|
}
|
||||||
mValueChangedTokens.clear();
|
mValueChangedTokens.clear();
|
||||||
}
|
}
|
||||||
|
@ -628,7 +628,7 @@ bool QLowEnergyControllerPrivateWinRT::registerForStatusChanges()
|
||||||
if (!mDevice)
|
if (!mDevice)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = mDevice->add_ConnectionStatusChanged(
|
hr = mDevice->add_ConnectionStatusChanged(
|
||||||
|
@ -640,7 +640,7 @@ bool QLowEnergyControllerPrivateWinRT::registerForStatusChanges()
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::unregisterFromStatusChanges()
|
void QLowEnergyControllerPrivateWinRT::unregisterFromStatusChanges()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__;
|
||||||
if (mDevice && mStatusChangedToken.value) {
|
if (mDevice && mStatusChangedToken.value) {
|
||||||
mDevice->remove_ConnectionStatusChanged(mStatusChangedToken);
|
mDevice->remove_ConnectionStatusChanged(mStatusChangedToken);
|
||||||
mStatusChangedToken.value = 0;
|
mStatusChangedToken.value = 0;
|
||||||
|
@ -708,7 +708,7 @@ void QLowEnergyControllerPrivateWinRT::obtainIncludedServices(
|
||||||
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain included service's Uuid");
|
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain included service's Uuid");
|
||||||
const QBluetoothUuid includedUuid(guuid);
|
const QBluetoothUuid includedUuid(guuid);
|
||||||
QSharedPointer<QLowEnergyServicePrivate> includedPointer;
|
QSharedPointer<QLowEnergyServicePrivate> includedPointer;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__
|
||||||
<< "Changing service pointer from thread"
|
<< "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
if (serviceList.contains(includedUuid)) {
|
if (serviceList.contains(includedUuid)) {
|
||||||
|
@ -734,7 +734,7 @@ HRESULT QLowEnergyControllerPrivateWinRT::onServiceDiscoveryFinished(ABI::Window
|
||||||
{
|
{
|
||||||
Q_Q(QLowEnergyController);
|
Q_Q(QLowEnergyController);
|
||||||
if (status != AsyncStatus::Completed) {
|
if (status != AsyncStatus::Completed) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain services";
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain services";
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
ComPtr<IGattDeviceServicesResult> result;
|
ComPtr<IGattDeviceServicesResult> result;
|
||||||
|
@ -766,7 +766,7 @@ HRESULT QLowEnergyControllerPrivateWinRT::onServiceDiscoveryFinished(ABI::Window
|
||||||
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain service's Uuid");
|
WARN_AND_CONTINUE_IF_FAILED(hr, "Could not obtain service's Uuid");
|
||||||
const QBluetoothUuid service(guuid);
|
const QBluetoothUuid service(guuid);
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__
|
||||||
<< "Changing service pointer from thread"
|
<< "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
QSharedPointer<QLowEnergyServicePrivate> pointer;
|
QSharedPointer<QLowEnergyServicePrivate> pointer;
|
||||||
|
@ -795,7 +795,7 @@ HRESULT QLowEnergyControllerPrivateWinRT::onServiceDiscoveryFinished(ABI::Window
|
||||||
|
|
||||||
void QLowEnergyControllerPrivateWinRT::discoverServices()
|
void QLowEnergyControllerPrivateWinRT::discoverServices()
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << "Service discovery initiated";
|
qCDebug(QT_BT_WINDOWS) << "Service discovery initiated";
|
||||||
|
|
||||||
ComPtr<IBluetoothLEDevice3> device3;
|
ComPtr<IBluetoothLEDevice3> device3;
|
||||||
HRESULT hr = mDevice.As(&device3);
|
HRESULT hr = mDevice.As(&device3);
|
||||||
|
@ -813,29 +813,29 @@ void QLowEnergyControllerPrivateWinRT::discoverServices()
|
||||||
void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(
|
void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(
|
||||||
const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode)
|
const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << service;
|
||||||
if (!serviceList.contains(service)) {
|
if (!serviceList.contains(service)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Discovery done of unknown service:"
|
qCWarning(QT_BT_WINDOWS) << "Discovery done of unknown service:"
|
||||||
<< service.toString();
|
<< service.toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<IGattDeviceService> deviceService = getNativeService(service);
|
ComPtr<IGattDeviceService> deviceService = getNativeService(service);
|
||||||
if (!deviceService) {
|
if (!deviceService) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native service for uuid " << service;
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native service for uuid " << service;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto reactOnDiscoveryError = [](QSharedPointer<QLowEnergyServicePrivate> service,
|
auto reactOnDiscoveryError = [](QSharedPointer<QLowEnergyServicePrivate> service,
|
||||||
const QString &msg)
|
const QString &msg)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << msg;
|
qCDebug(QT_BT_WINDOWS) << msg;
|
||||||
service->setError(QLowEnergyService::UnknownError);
|
service->setError(QLowEnergyService::UnknownError);
|
||||||
service->setState(QLowEnergyService::RemoteService);
|
service->setState(QLowEnergyService::RemoteService);
|
||||||
};
|
};
|
||||||
//update service data
|
//update service data
|
||||||
QSharedPointer<QLowEnergyServicePrivate> pointer = serviceList.value(service);
|
QSharedPointer<QLowEnergyServicePrivate> pointer = serviceList.value(service);
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
pointer->setState(QLowEnergyService::RemoteServiceDiscovering);
|
pointer->setState(QLowEnergyService::RemoteServiceDiscovering);
|
||||||
ComPtr<IGattDeviceService3> deviceService3;
|
ComPtr<IGattDeviceService3> deviceService3;
|
||||||
|
@ -887,7 +887,7 @@ void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(
|
||||||
|
|
||||||
const QBluetoothUuid service(guuid);
|
const QBluetoothUuid service(guuid);
|
||||||
if (service.isNull()) {
|
if (service.isNull()) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not find service";
|
qCDebug(QT_BT_WINDOWS) << "Could not find service";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -913,7 +913,7 @@ void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(
|
||||||
QLowEnergyServicePrivate::CharData> charList, QList<QBluetoothUuid> indicateChars,
|
QLowEnergyServicePrivate::CharData> charList, QList<QBluetoothUuid> indicateChars,
|
||||||
QLowEnergyHandle startHandle, QLowEnergyHandle endHandle) {
|
QLowEnergyHandle startHandle, QLowEnergyHandle endHandle) {
|
||||||
if (!serviceList.contains(service)) {
|
if (!serviceList.contains(service)) {
|
||||||
qCWarning(QT_BT_WINRT) << "Discovery done of unknown service:"
|
qCWarning(QT_BT_WINDOWS) << "Discovery done of unknown service:"
|
||||||
<< service.toString();
|
<< service.toString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -955,8 +955,8 @@ void QLowEnergyControllerPrivateWinRT::readCharacteristic(
|
||||||
const QSharedPointer<QLowEnergyServicePrivate> service,
|
const QSharedPointer<QLowEnergyServicePrivate> service,
|
||||||
const QLowEnergyHandle charHandle)
|
const QLowEnergyHandle charHandle)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << service << charHandle;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
Q_ASSERT(!service.isNull());
|
Q_ASSERT(!service.isNull());
|
||||||
if (role == QLowEnergyController::PeripheralRole) {
|
if (role == QLowEnergyController::PeripheralRole) {
|
||||||
|
@ -966,18 +966,18 @@ void QLowEnergyControllerPrivateWinRT::readCharacteristic(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!service->characteristicList.contains(charHandle)) {
|
if (!service->characteristicList.contains(charHandle)) {
|
||||||
qCDebug(QT_BT_WINRT) << charHandle << "could not be found in service" << service->uuid;
|
qCDebug(QT_BT_WINDOWS) << charHandle << "could not be found in service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::CharacteristicReadError);
|
service->setError(QLowEnergyService::CharacteristicReadError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
||||||
if (!(charData.properties & QLowEnergyCharacteristic::Read))
|
if (!(charData.properties & QLowEnergyCharacteristic::Read))
|
||||||
qCDebug(QT_BT_WINRT) << "Read flag is not set for characteristic" << charData.uuid;
|
qCDebug(QT_BT_WINDOWS) << "Read flag is not set for characteristic" << charData.uuid;
|
||||||
|
|
||||||
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
||||||
if (!characteristic) {
|
if (!characteristic) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native characteristic" << charData.uuid
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native characteristic" << charData.uuid
|
||||||
<< "from service" << service->uuid;
|
<< "from service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::CharacteristicReadError);
|
service->setError(QLowEnergyService::CharacteristicReadError);
|
||||||
return;
|
return;
|
||||||
|
@ -990,7 +990,7 @@ void QLowEnergyControllerPrivateWinRT::readCharacteristic(
|
||||||
(IAsyncOperation<GattReadResult*> *op, AsyncStatus status)
|
(IAsyncOperation<GattReadResult*> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle << "read operation failed.";
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charHandle << "read operation failed.";
|
||||||
service->setError(QLowEnergyService::CharacteristicReadError);
|
service->setError(QLowEnergyService::CharacteristicReadError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1018,8 +1018,8 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
const QLowEnergyHandle charHandle,
|
const QLowEnergyHandle charHandle,
|
||||||
const QLowEnergyHandle descHandle)
|
const QLowEnergyHandle descHandle)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << service << charHandle << descHandle;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
Q_ASSERT(!service.isNull());
|
Q_ASSERT(!service.isNull());
|
||||||
if (role == QLowEnergyController::PeripheralRole) {
|
if (role == QLowEnergyController::PeripheralRole) {
|
||||||
|
@ -1029,7 +1029,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!service->characteristicList.contains(charHandle)) {
|
if (!service->characteristicList.contains(charHandle)) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "in characteristic" << charHandle
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "in characteristic" << charHandle
|
||||||
<< "cannot be found in service" << service->uuid;
|
<< "cannot be found in service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return;
|
return;
|
||||||
|
@ -1038,7 +1038,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
||||||
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
||||||
if (!characteristic) {
|
if (!characteristic) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native characteristic" << charData.uuid
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native characteristic" << charData.uuid
|
||||||
<< "from service" << service->uuid;
|
<< "from service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return;
|
return;
|
||||||
|
@ -1046,7 +1046,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
|
|
||||||
// Get native descriptor
|
// Get native descriptor
|
||||||
if (!charData.descriptorList.contains(descHandle))
|
if (!charData.descriptorList.contains(descHandle))
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "cannot be found in characteristic" << charHandle;
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "cannot be found in characteristic" << charHandle;
|
||||||
const QLowEnergyServicePrivate::DescData descData = charData.descriptorList.value(descHandle);
|
const QLowEnergyServicePrivate::DescData descData = charData.descriptorList.value(descHandle);
|
||||||
const QBluetoothUuid descUuid = descData.uuid;
|
const QBluetoothUuid descUuid = descData.uuid;
|
||||||
if (descUuid == QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration)) {
|
if (descUuid == QBluetoothUuid(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration)) {
|
||||||
|
@ -1058,7 +1058,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
(IAsyncOperation<ClientCharConfigDescriptorResult *> *op, AsyncStatus status)
|
(IAsyncOperation<ClientCharConfigDescriptorResult *> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "read operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "read operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1084,7 +1084,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
if (value == GattClientCharacteristicConfigurationDescriptorValue_None)
|
if (value == GattClientCharacteristicConfigurationDescriptorValue_None)
|
||||||
correct = true;
|
correct = true;
|
||||||
if (!correct) {
|
if (!correct) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle
|
||||||
<< "read operation failed. Obtained unexpected value.";
|
<< "read operation failed. Obtained unexpected value.";
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1136,11 +1136,11 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not await descritpor list's size",
|
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not await descritpor list's size",
|
||||||
service, QLowEnergyService::DescriptorReadError, return)
|
service, QLowEnergyService::DescriptorReadError, return)
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
qCWarning(QT_BT_WINRT) << "No descriptor with uuid" << descData.uuid << "was found.";
|
qCWarning(QT_BT_WINDOWS) << "No descriptor with uuid" << descData.uuid << "was found.";
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return;
|
return;
|
||||||
} else if (size > 1) {
|
} else if (size > 1) {
|
||||||
qCWarning(QT_BT_WINRT) << "There is more than 1 descriptor with uuid" << descData.uuid;
|
qCWarning(QT_BT_WINDOWS) << "There is more than 1 descriptor with uuid" << descData.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<IGattDescriptor> descriptor;
|
ComPtr<IGattDescriptor> descriptor;
|
||||||
|
@ -1155,7 +1155,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
(IAsyncOperation<GattReadResult*> *op, AsyncStatus status)
|
(IAsyncOperation<GattReadResult*> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "read operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "read operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1163,7 @@ void QLowEnergyControllerPrivateWinRT::readDescriptor(
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = op->GetResults(&descriptorValue);
|
hr = op->GetResults(&descriptorValue);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain result for descriptor" << descHandle;
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain result for descriptor" << descHandle;
|
||||||
service->setError(QLowEnergyService::DescriptorReadError);
|
service->setError(QLowEnergyService::DescriptorReadError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1190,8 +1190,8 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
const QByteArray &newValue,
|
const QByteArray &newValue,
|
||||||
QLowEnergyService::WriteMode mode)
|
QLowEnergyService::WriteMode mode)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << newValue << mode;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << service << charHandle << newValue << mode;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
Q_ASSERT(!service.isNull());
|
Q_ASSERT(!service.isNull());
|
||||||
if (role == QLowEnergyController::PeripheralRole) {
|
if (role == QLowEnergyController::PeripheralRole) {
|
||||||
|
@ -1200,7 +1200,7 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!service->characteristicList.contains(charHandle)) {
|
if (!service->characteristicList.contains(charHandle)) {
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle << "cannot be found in service"
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charHandle << "cannot be found in service"
|
||||||
<< service->uuid;
|
<< service->uuid;
|
||||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||||
return;
|
return;
|
||||||
|
@ -1210,12 +1210,12 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
const bool writeWithResponse = mode == QLowEnergyService::WriteWithResponse;
|
const bool writeWithResponse = mode == QLowEnergyService::WriteWithResponse;
|
||||||
if (!(charData.properties & (writeWithResponse ? QLowEnergyCharacteristic::Write
|
if (!(charData.properties & (writeWithResponse ? QLowEnergyCharacteristic::Write
|
||||||
: QLowEnergyCharacteristic::WriteNoResponse)))
|
: QLowEnergyCharacteristic::WriteNoResponse)))
|
||||||
qCDebug(QT_BT_WINRT) << "Write flag is not set for characteristic" << charHandle;
|
qCDebug(QT_BT_WINDOWS) << "Write flag is not set for characteristic" << charHandle;
|
||||||
|
|
||||||
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid,
|
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid,
|
||||||
charData.uuid);
|
charData.uuid);
|
||||||
if (!characteristic) {
|
if (!characteristic) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native characteristic" << charData.uuid
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native characteristic" << charData.uuid
|
||||||
<< "from service" << service->uuid;
|
<< "from service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||||
return;
|
return;
|
||||||
|
@ -1254,7 +1254,7 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle << "write operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1262,7 +1262,7 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
hr = op->GetResults(&result);
|
hr = op->GetResults(&result);
|
||||||
if (hr == E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH) {
|
if (hr == E_BLUETOOTH_ATT_INVALID_ATTRIBUTE_VALUE_LENGTH) {
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charHandle
|
||||||
<< "write operation was tried with invalid value length";
|
<< "write operation was tried with invalid value length";
|
||||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -1270,7 +1270,7 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(
|
||||||
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain characteristic write result",
|
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain characteristic write result",
|
||||||
service, QLowEnergyService::CharacteristicWriteError, return S_OK)
|
service, QLowEnergyService::CharacteristicWriteError, return S_OK)
|
||||||
if (result != GattCommunicationStatus_Success) {
|
if (result != GattCommunicationStatus_Success) {
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic" << charHandle << "write operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Characteristic" << charHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::CharacteristicWriteError);
|
service->setError(QLowEnergyService::CharacteristicWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1296,8 +1296,8 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
const QLowEnergyHandle descHandle,
|
const QLowEnergyHandle descHandle,
|
||||||
const QByteArray &newValue)
|
const QByteArray &newValue)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << service << charHandle << descHandle << newValue;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << service << charHandle << descHandle << newValue;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
Q_ASSERT(!service.isNull());
|
Q_ASSERT(!service.isNull());
|
||||||
if (role == QLowEnergyController::PeripheralRole) {
|
if (role == QLowEnergyController::PeripheralRole) {
|
||||||
|
@ -1307,7 +1307,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!service->characteristicList.contains(charHandle)) {
|
if (!service->characteristicList.contains(charHandle)) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "in characteristic" << charHandle
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "in characteristic" << charHandle
|
||||||
<< "could not be found in service" << service->uuid;
|
<< "could not be found in service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return;
|
return;
|
||||||
|
@ -1316,7 +1316,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
const QLowEnergyServicePrivate::CharData charData = service->characteristicList.value(charHandle);
|
||||||
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
ComPtr<IGattCharacteristic> characteristic = getNativeCharacteristic(service->uuid, charData.uuid);
|
||||||
if (!characteristic) {
|
if (!characteristic) {
|
||||||
qCDebug(QT_BT_WINRT) << "Could not obtain native characteristic" << charData.uuid
|
qCDebug(QT_BT_WINDOWS) << "Could not obtain native characteristic" << charData.uuid
|
||||||
<< "from service" << service->uuid;
|
<< "from service" << service->uuid;
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return;
|
return;
|
||||||
|
@ -1324,7 +1324,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
|
|
||||||
// Get native descriptor
|
// Get native descriptor
|
||||||
if (!charData.descriptorList.contains(descHandle))
|
if (!charData.descriptorList.contains(descHandle))
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "could not be found in Characteristic"
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "could not be found in Characteristic"
|
||||||
<< charHandle;
|
<< charHandle;
|
||||||
|
|
||||||
QLowEnergyServicePrivate::DescData descData = charData.descriptorList.value(descHandle);
|
QLowEnergyServicePrivate::DescData descData = charData.descriptorList.value(descHandle);
|
||||||
|
@ -1333,7 +1333,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
quint16 intValue = qFromLittleEndian<quint16>(newValue);
|
quint16 intValue = qFromLittleEndian<quint16>(newValue);
|
||||||
if (intValue & GattClientCharacteristicConfigurationDescriptorValue_Indicate
|
if (intValue & GattClientCharacteristicConfigurationDescriptorValue_Indicate
|
||||||
&& intValue & GattClientCharacteristicConfigurationDescriptorValue_Notify) {
|
&& intValue & GattClientCharacteristicConfigurationDescriptorValue_Notify) {
|
||||||
qCWarning(QT_BT_WINRT) << "Setting both Indicate and Notify is not supported on WinRT";
|
qCWarning(QT_BT_WINDOWS) << "Setting both Indicate and Notify is not supported on WinRT";
|
||||||
value = GattClientCharacteristicConfigurationDescriptorValue(
|
value = GattClientCharacteristicConfigurationDescriptorValue(
|
||||||
(GattClientCharacteristicConfigurationDescriptorValue_Indicate
|
(GattClientCharacteristicConfigurationDescriptorValue_Indicate
|
||||||
| GattClientCharacteristicConfigurationDescriptorValue_Notify));
|
| GattClientCharacteristicConfigurationDescriptorValue_Notify));
|
||||||
|
@ -1344,7 +1344,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
} else if (intValue == 0) {
|
} else if (intValue == 0) {
|
||||||
value = GattClientCharacteristicConfigurationDescriptorValue_None;
|
value = GattClientCharacteristicConfigurationDescriptorValue_None;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle
|
||||||
<< "write operation failed: Invalid value";
|
<< "write operation failed: Invalid value";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return;
|
return;
|
||||||
|
@ -1358,7 +1358,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "write operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1368,7 +1368,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain result for descriptor",
|
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain result for descriptor",
|
||||||
service, QLowEnergyService::DescriptorWriteError, return S_OK)
|
service, QLowEnergyService::DescriptorWriteError, return S_OK)
|
||||||
if (result != GattCommunicationStatus_Success) {
|
if (result != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT) << "Descriptor" << descHandle << "write operation failed";
|
qCWarning(QT_BT_WINDOWS) << "Descriptor" << descHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1400,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
GattCommunicationStatus commStatus;
|
GattCommunicationStatus commStatus;
|
||||||
hr = result->get_Status(&commStatus);
|
hr = result->get_Status(&commStatus);
|
||||||
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT) << "Descriptor operation failed";
|
qCWarning(QT_BT_WINDOWS) << "Descriptor operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1413,10 +1413,10 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain list of descriptors' size",
|
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain list of descriptors' size",
|
||||||
service, QLowEnergyService::DescriptorWriteError, return)
|
service, QLowEnergyService::DescriptorWriteError, return)
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
qCWarning(QT_BT_WINRT) << "No descriptor with uuid" << descData.uuid << "was found.";
|
qCWarning(QT_BT_WINDOWS) << "No descriptor with uuid" << descData.uuid << "was found.";
|
||||||
return;
|
return;
|
||||||
} else if (size > 1) {
|
} else if (size > 1) {
|
||||||
qCWarning(QT_BT_WINRT) << "There is more than 1 descriptor with uuid" << descData.uuid;
|
qCWarning(QT_BT_WINDOWS) << "There is more than 1 descriptor with uuid" << descData.uuid;
|
||||||
}
|
}
|
||||||
ComPtr<IGattDescriptor> descriptor;
|
ComPtr<IGattDescriptor> descriptor;
|
||||||
hr = descriptors->GetAt(0, &descriptor);
|
hr = descriptors->GetAt(0, &descriptor);
|
||||||
|
@ -1454,7 +1454,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
(IAsyncOperation<GattCommunicationStatus> *op, AsyncStatus status)
|
||||||
{
|
{
|
||||||
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "write operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1464,7 +1464,7 @@ void QLowEnergyControllerPrivateWinRT::writeDescriptor(
|
||||||
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain result for descriptor",
|
CHECK_HR_AND_SET_SERVICE_ERROR(hr, "Could not obtain result for descriptor",
|
||||||
service, QLowEnergyService::DescriptorWriteError, return S_OK)
|
service, QLowEnergyService::DescriptorWriteError, return S_OK)
|
||||||
if (result != GattCommunicationStatus_Success) {
|
if (result != GattCommunicationStatus_Success) {
|
||||||
qCDebug(QT_BT_WINRT) << "Descriptor" << descHandle << "write operation failed";
|
qCDebug(QT_BT_WINDOWS) << "Descriptor" << descHandle << "write operation failed";
|
||||||
service->setError(QLowEnergyService::DescriptorWriteError);
|
service->setError(QLowEnergyService::DescriptorWriteError);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -1490,20 +1490,20 @@ void QLowEnergyControllerPrivateWinRT::addToGenericAttributeList(const QLowEnerg
|
||||||
void QLowEnergyControllerPrivateWinRT::handleCharacteristicChanged(
|
void QLowEnergyControllerPrivateWinRT::handleCharacteristicChanged(
|
||||||
quint16 charHandle, const QByteArray &data)
|
quint16 charHandle, const QByteArray &data)
|
||||||
{
|
{
|
||||||
qCDebug(QT_BT_WINRT) << __FUNCTION__ << charHandle << data;
|
qCDebug(QT_BT_WINDOWS) << __FUNCTION__ << charHandle << data;
|
||||||
qCDebug(QT_BT_WINRT_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
qCDebug(QT_BT_WINDOWS_SERVICE_THREAD) << __FUNCTION__ << "Changing service pointer from thread"
|
||||||
<< QThread::currentThread();
|
<< QThread::currentThread();
|
||||||
QSharedPointer<QLowEnergyServicePrivate> service =
|
QSharedPointer<QLowEnergyServicePrivate> service =
|
||||||
serviceForHandle(charHandle);
|
serviceForHandle(charHandle);
|
||||||
if (service.isNull())
|
if (service.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qCDebug(QT_BT_WINRT) << "Characteristic change notification" << service->uuid
|
qCDebug(QT_BT_WINDOWS) << "Characteristic change notification" << service->uuid
|
||||||
<< charHandle << data.toHex();
|
<< charHandle << data.toHex();
|
||||||
|
|
||||||
QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
|
QLowEnergyCharacteristic characteristic = characteristicForHandle(charHandle);
|
||||||
if (!characteristic.isValid()) {
|
if (!characteristic.isValid()) {
|
||||||
qCWarning(QT_BT_WINRT) << "characteristicChanged: Cannot find characteristic";
|
qCWarning(QT_BT_WINDOWS) << "characteristicChanged: Cannot find characteristic";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,7 +1520,7 @@ void QLowEnergyControllerPrivateWinRT::handleServiceHandlerError(const QString &
|
||||||
if (state != QLowEnergyController::DiscoveringState)
|
if (state != QLowEnergyController::DiscoveringState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qCWarning(QT_BT_WINRT) << "Error while discovering services:" << error;
|
qCWarning(QT_BT_WINDOWS) << "Error while discovering services:" << error;
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
setError(QLowEnergyController::ConnectionError);
|
setError(QLowEnergyController::ConnectionError);
|
||||||
}
|
}
|
||||||
|
@ -1543,7 +1543,7 @@ void QLowEnergyControllerPrivateWinRT::connectToPairedDevice()
|
||||||
GattCommunicationStatus commStatus;
|
GattCommunicationStatus commStatus;
|
||||||
hr = deviceServicesResult->get_Status(&commStatus);
|
hr = deviceServicesResult->get_Status(&commStatus);
|
||||||
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT()) << "Service operation failed";
|
qCWarning(QT_BT_WINDOWS()) << "Service operation failed";
|
||||||
setError(QLowEnergyController::ConnectionError);
|
setError(QLowEnergyController::ConnectionError);
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
unregisterFromStatusChanges();
|
unregisterFromStatusChanges();
|
||||||
|
@ -1558,7 +1558,7 @@ void QLowEnergyControllerPrivateWinRT::connectToPairedDevice()
|
||||||
CHECK_FOR_DEVICE_CONNECTION_ERROR(hr, "Could not obtain service count", return)
|
CHECK_FOR_DEVICE_CONNECTION_ERROR(hr, "Could not obtain service count", return)
|
||||||
|
|
||||||
if (serviceCount == 0) {
|
if (serviceCount == 0) {
|
||||||
qCWarning(QT_BT_WINRT()) << "Found devices without services";
|
qCWarning(QT_BT_WINDOWS()) << "Found devices without services";
|
||||||
setError(QLowEnergyController::ConnectionError);
|
setError(QLowEnergyController::ConnectionError);
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
unregisterFromStatusChanges();
|
unregisterFromStatusChanges();
|
||||||
|
@ -1584,7 +1584,7 @@ void QLowEnergyControllerPrivateWinRT::connectToPairedDevice()
|
||||||
GattCommunicationStatus commStatus;
|
GattCommunicationStatus commStatus;
|
||||||
hr = characteristicsResult->get_Status(&commStatus);
|
hr = characteristicsResult->get_Status(&commStatus);
|
||||||
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT) << "Characteristic operation failed";
|
qCWarning(QT_BT_WINDOWS) << "Characteristic operation failed";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ComPtr<IVectorView<GattCharacteristic *>> characteristics;
|
ComPtr<IVectorView<GattCharacteristic *>> characteristics;
|
||||||
|
@ -1592,7 +1592,7 @@ void QLowEnergyControllerPrivateWinRT::connectToPairedDevice()
|
||||||
if (hr == E_ACCESSDENIED) {
|
if (hr == E_ACCESSDENIED) {
|
||||||
// Everything will work as expected up until this point if the manifest capabilties
|
// Everything will work as expected up until this point if the manifest capabilties
|
||||||
// for bluetooth LE are not set.
|
// for bluetooth LE are not set.
|
||||||
qCWarning(QT_BT_WINRT) << "Could not obtain characteristic list. Please check your "
|
qCWarning(QT_BT_WINDOWS) << "Could not obtain characteristic list. Please check your "
|
||||||
"manifest capabilities";
|
"manifest capabilities";
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
setError(QLowEnergyController::ConnectionError);
|
setError(QLowEnergyController::ConnectionError);
|
||||||
|
@ -1626,7 +1626,7 @@ void QLowEnergyControllerPrivateWinRT::connectToPairedDevice()
|
||||||
hr = result->get_Value(&buffer);
|
hr = result->get_Value(&buffer);
|
||||||
CHECK_FOR_DEVICE_CONNECTION_ERROR(hr, "Could not obtain characteristic value", return);
|
CHECK_FOR_DEVICE_CONNECTION_ERROR(hr, "Could not obtain characteristic value", return);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
qCDebug(QT_BT_WINRT) << "Problem reading value";
|
qCDebug(QT_BT_WINDOWS) << "Problem reading value";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1668,7 +1668,7 @@ void QLowEnergyControllerPrivateWinRT::connectToUnpairedDevice()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
if (FAILED(hr) || commStatus != GattCommunicationStatus_Success) {
|
||||||
qCWarning(QT_BT_WINRT()) << "Service operation failed";
|
qCWarning(QT_BT_WINDOWS()) << "Service operation failed";
|
||||||
setError(QLowEnergyController::ConnectionError);
|
setError(QLowEnergyController::ConnectionError);
|
||||||
setState(QLowEnergyController::UnconnectedState);
|
setState(QLowEnergyController::UnconnectedState);
|
||||||
unregisterFromStatusChanges();
|
unregisterFromStatusChanges();
|
||||||
|
|
Loading…
Reference in New Issue