53 QLowEnergyControllerPrivateWinRT();
63 QLowEnergyService::DiscoveryMode mode)
override;
66 const QLowEnergyAdvertisingData &advertisingData,
67 const QLowEnergyAdvertisingData &scanResponseData)
override;
74 const QLowEnergyHandle charHandle)
override;
75 void readDescriptor(
const QSharedPointer<QLowEnergyServicePrivate> service,
76 const QLowEnergyHandle charHandle,
77 const QLowEnergyHandle descriptorHandle)
override;
81 const QLowEnergyHandle charHandle,
82 const QByteArray &newValue, QLowEnergyService::WriteMode mode)
override;
83 void writeDescriptor(
const QSharedPointer<QLowEnergyServicePrivate> service,
84 const QLowEnergyHandle charHandle,
85 const QLowEnergyHandle descriptorHandle,
86 const QByteArray &newValue)
override;
89 QLowEnergyHandle startHandle)
override;
91 int mtu()
const override;
94 void characteristicChanged(quint16 charHandle,
const QByteArray &data);
98 void handleCharacteristicChanged(quint16 charHandle,
const QByteArray &data);
99 void handleServiceHandlerError(
const QString &error);
102 void handleConnectionError(
const char *logMessage);
104 BluetoothLEDevice mDevice =
nullptr;
105 GattSession mGattSession =
nullptr;
106 winrt::event_token mStatusChangedToken{ 0 };
107 winrt::event_token mMtuChangedToken{ 0 };
108 struct ValueChangedEntry {
109 ValueChangedEntry() {}
110 ValueChangedEntry(GattCharacteristic c,
111 winrt::event_token t)
117 GattCharacteristic characteristic =
nullptr;
118 winrt::event_token token = { 0 };
120 QList<ValueChangedEntry> mValueChangedTokens;
122 QMap<QBluetoothUuid, GattDeviceService> m_openedServices;
123 QSet<QBluetoothUuid> m_requestDetailsServiceUuids;
125 using NativeServiceCallback = std::function<
void(GattDeviceService)>;
126 bool getNativeService(
const QBluetoothUuid &serviceUuid, NativeServiceCallback callback);
128 using NativeCharacteristicCallback = std::function<
void(GattCharacteristic)>;
129 bool getNativeCharacteristic(
const QBluetoothUuid &serviceUuid,
130 const QBluetoothUuid &charUuid,
131 NativeCharacteristicCallback callback);
133 void registerForValueChanges(
const QBluetoothUuid &serviceUuid,
const QBluetoothUuid &charUuid);
134 void unregisterFromValueChanges();
135 void onValueChange(GattCharacteristic characteristic, GattValueChangedEventArgs
const &args);
136 void onMtuChange(GattSession session, winrt::IInspectable args);
137 bool registerForMtuChanges();
138 void unregisterFromMtuChanges();
140 bool registerForStatusChanges();
141 void unregisterFromStatusChanges();
142 void onStatusChange(BluetoothLEDevice dev, winrt::IInspectable args);
144 void obtainIncludedServices(QSharedPointer<QLowEnergyServicePrivate> servicePointer,
145 GattDeviceService nativeService);
146 void onServiceDiscoveryFinished(winrt::Windows::Foundation::IAsyncOperation<GattDeviceServicesResult>
const &op,
147 winrt::AsyncStatus status);
149 void readCharacteristicHelper(
const QSharedPointer<QLowEnergyServicePrivate> service,
150 const QLowEnergyHandle charHandle,
151 GattCharacteristic characteristic);
152 void readDescriptorHelper(
const QSharedPointer<QLowEnergyServicePrivate> service,
153 const QLowEnergyHandle charHandle,
154 const QLowEnergyHandle descriptorHandle,
155 GattCharacteristic characteristic);
156 void writeCharacteristicHelper(
const QSharedPointer<QLowEnergyServicePrivate> service,
157 const QLowEnergyHandle charHandle,
const QByteArray &newValue,
158 bool writeWithResponse,
159 GattCharacteristic characteristic);
160 void writeDescriptorHelper(
const QSharedPointer<QLowEnergyServicePrivate> service,
161 const QLowEnergyHandle charHandle,
162 const QLowEnergyHandle descriptorHandle,
163 const QByteArray &newValue,
164 GattCharacteristic characteristic);
165 void discoverServiceDetailsHelper(
const QBluetoothUuid &service,
166 QLowEnergyService::DiscoveryMode mode,
167 GattDeviceService deviceService);
169 void clearAllServices();
170 void closeAndRemoveService(
const QBluetoothUuid &uuid);