7#include <QCoreApplication>
8#include <QtCore/QLoggingCategory>
9#include <QtCore/QJniEnvironment>
10#include <QtCore/QJniObject>
11#include <QtBluetooth/QLowEnergyServiceData>
12#include <QtBluetooth/QLowEnergyCharacteristicData>
13#include <QtBluetooth/QLowEnergyDescriptorData>
14#include <QtBluetooth/QLowEnergyAdvertisingData>
15#include <QtBluetooth/QLowEnergyAdvertisingParameters>
16#include <QtBluetooth/QLowEnergyConnectionParameters>
32 QJniObject javaUuid = QJniObject::callStaticMethod<QtJniTypes::UUID>(
33 QtJniTypes::className<QtJniTypes::UUID>(),
"fromString",
34 javaString.object<jstring>());
50 hub->
javaObject().callMethod<
void>(
"disconnectServer");
59 qRegisterMetaType<QJniObject>();
64 this, &QLowEnergyControllerPrivateAndroid::connectionUpdated);
66 this, &QLowEnergyControllerPrivateAndroid::mtuChanged);
68 this, &QLowEnergyControllerPrivateAndroid::advertisementError);
70 this, &QLowEnergyControllerPrivateAndroid::serverCharacteristicChanged);
72 this, &QLowEnergyControllerPrivateAndroid::serverDescriptorWritten);
77 this, &QLowEnergyControllerPrivateAndroid::connectionUpdated);
79 this, &QLowEnergyControllerPrivateAndroid::mtuChanged);
81 this, &QLowEnergyControllerPrivateAndroid::servicesDiscovered);
83 this, &QLowEnergyControllerPrivateAndroid::serviceDetailsDiscoveryFinished);
85 this, &QLowEnergyControllerPrivateAndroid::characteristicRead);
87 this, &QLowEnergyControllerPrivateAndroid::descriptorRead);
89 this, &QLowEnergyControllerPrivateAndroid::characteristicWritten);
91 this, &QLowEnergyControllerPrivateAndroid::descriptorWritten);
93 this, &QLowEnergyControllerPrivateAndroid::characteristicChanged);
95 this, &QLowEnergyControllerPrivateAndroid::serviceError);
97 this, &QLowEnergyControllerPrivateAndroid::remoteRssiRead);
104 qCCritical(QT_BT_ANDROID) <<
"connectToDevice() LE controller has not been initialized";
111 qCWarning(QT_BT_ANDROID) <<
"connectToDevice() failed due to missing permissions";
117 qCWarning(QT_BT_ANDROID) <<
"Invalid/null remote device address";
125 qCWarning(QT_BT_ANDROID) <<
"Cannot initiate QtBluetoothLE";
152 hub->
javaObject().callMethod<
void>(
"disconnectServer");
154 hub->
javaObject().callMethod<
void>(
"disconnect");
165 if (hub && hub->
javaObject().callMethod<jboolean>(
"discoverServices")) {
166 qCDebug(QT_BT_ANDROID) <<
"Service discovery initiated";
179 qCWarning(QT_BT_ANDROID) <<
"Discovery of unknown service" << service.toString()
190 QJniObject uuid = QJniObject::fromString(tempUuid);
192 bool result = hub->
javaObject().callMethod<jboolean>(
"discoverServiceDetails",
193 uuid.object<jstring>(),
198 if (!servicePrivate.
isNull()) {
202 qCWarning(QT_BT_ANDROID) <<
"Cannot discover details for" << service.toString();
206 qCDebug(QT_BT_ANDROID) <<
"Discovery of" << service <<
"started";
218 if (!service->characteristicList.contains(charHandle))
223 payload = env->NewByteArray(newValue.
size());
224 env->SetByteArrayRegion(payload, 0, newValue.
size(),
230 qCDebug(QT_BT_ANDROID) <<
"Write characteristic with handle " << charHandle
231 << newValue.
toHex() <<
"(service:" << service->uuid
235 charHandle, payload, jint(
mode));
237 qCDebug(QT_BT_ANDROID) <<
"Write server characteristic with handle " << charHandle
238 << newValue.
toHex() <<
"(service:" << service->uuid;
241 if (characteristic.isValid()) {
244 "writeCharacteristic",
245 service->androidService.object<QtJniTypes::BluetoothGattService>(),
246 charUuid.object<QtJniTypes::UUID>(), payload);
248 service->characteristicList[charHandle].value = newValue;
253 env->DeleteLocalRef(payload);
269 payload = env->NewByteArray(newValue.
size());
270 env->SetByteArrayRegion(payload, 0, newValue.
size(),
276 qCDebug(QT_BT_ANDROID) <<
"Write descriptor with handle " << descHandle
277 << newValue.
toHex() <<
"(service:" << service->uuid <<
")";
279 descHandle, payload);
283 if (characteristic.isValid() && descriptor.isValid()) {
284 qCDebug(QT_BT_ANDROID) <<
"Write descriptor" << descriptor.uuid()
285 <<
"(service:" << service->uuid
286 <<
"char: " << characteristic.uuid() <<
")";
291 service->androidService.object<QtJniTypes::BluetoothGattService>(),
292 charUuid.object<QtJniTypes::UUID>(), descUuid.object<QtJniTypes::UUID>(),
295 service->characteristicList[charHandle].descriptorList[descHandle].value = newValue;
300 env->DeleteLocalRef(payload);
312 if (!service->characteristicList.contains(charHandle))
318 qCDebug(QT_BT_ANDROID) <<
"Read characteristic with handle"
319 << charHandle << service->uuid;
320 result = hub->
javaObject().callMethod<jboolean>(
"readCharacteristic", charHandle);
337 qCDebug(QT_BT_ANDROID) <<
"Read descriptor with handle"
338 << descriptorHandle << service->uuid;
339 result = hub->
javaObject().callMethod<jboolean>(
"readDescriptor", descriptorHandle);
346void QLowEnergyControllerPrivateAndroid::connectionUpdated(
350 qCDebug(QT_BT_ANDROID) <<
"Connection updated:"
351 <<
"error:" << errorCode
352 <<
"oldState:" <<
state
356 peripheralConnectionUpdated(
newState, errorCode);
358 centralConnectionUpdated(
newState, errorCode);
361void QLowEnergyControllerPrivateAndroid::mtuChanged(
int mtu)
364 qCDebug(QT_BT_ANDROID) <<
"MTU updated:"
369void QLowEnergyControllerPrivateAndroid::remoteRssiRead(
int rssi,
bool success)
377 qCDebug(QT_BT_ANDROID) <<
"Reading remote RSSI failed";
383void QLowEnergyControllerPrivateAndroid::peripheralConnectionUpdated(
404 hub->
javaObject().callMethod<jstring>(
"remoteAddress").toString());
412 emit q->disconnected();
420void QLowEnergyControllerPrivateAndroid::centralConnectionUpdated(
458 emit q->disconnected();
465void QLowEnergyControllerPrivateAndroid::servicesDiscovered(
480 priv->setController(
this);
489 emit q->discoveryFinished();
496void QLowEnergyControllerPrivateAndroid::serviceDetailsDiscoveryFinished(
497 const QString &serviceUuid,
int startHandle,
int endHandle)
501 qCWarning(QT_BT_ANDROID) <<
"Discovery done of unknown service:"
509 pointer->startHandle = startHandle;
510 pointer->endHandle = endHandle;
513 QJniObject uuid = QJniObject::fromString(serviceUuid);
515 "includedServices", uuid.object<jstring>());
516 if (javaIncludes.isValid()) {
524 pointer->includedServices.append(service);
529 if (!otherService.
isNull())
535 qCDebug(QT_BT_ANDROID) <<
"Service" << serviceUuid <<
"discovered (start:"
536 << startHandle <<
"end:" << endHandle <<
")" <<
pointer.
data();
541void QLowEnergyControllerPrivateAndroid::characteristicRead(
553 service->characteristicList[charHandle];
557 charDetails.
uuid = charUuid;
564 if (!characteristic.
isValid()) {
565 qCWarning(QT_BT_ANDROID) <<
"characteristicRead: Cannot find characteristic";
572void QLowEnergyControllerPrivateAndroid::descriptorRead(
582 bool entryUpdated =
false;
585 for ( ; charIt !=
service->characteristicList.end(); ++charIt) {
588 if (charDetails.
uuid != charUuid)
594 descDetails.
uuid = descUuid;
601 qCWarning(QT_BT_ANDROID) <<
"Cannot find/update descriptor"
602 << descUuid << charUuid << serviceUuid;
606 qCWarning(QT_BT_ANDROID) <<
"descriptorRead: Cannot find descriptor";
613void QLowEnergyControllerPrivateAndroid::characteristicWritten(
621 qCDebug(QT_BT_ANDROID) <<
"Characteristic write confirmation" <<
service->uuid
622 << charHandle <<
data.toHex() << errorCode;
630 if (!characteristic.
isValid()) {
631 qCWarning(QT_BT_ANDROID) <<
"characteristicWritten: Cannot find characteristic";
642void QLowEnergyControllerPrivateAndroid::descriptorWritten(
650 qCDebug(QT_BT_ANDROID) <<
"Descriptor write confirmation" <<
service->uuid
651 << descHandle <<
data.toHex() << errorCode;
660 qCWarning(QT_BT_ANDROID) <<
"descriptorWritten: Cannot find descriptor";
665 descHandle,
data,
false);
669void QLowEnergyControllerPrivateAndroid::serverDescriptorWritten(
672 qCDebug(QT_BT_ANDROID) <<
"Server descriptor change notification" << newValue.
toHex();
675 const QJniObject jniChar = jniDesc.callMethod<QtJniTypes::BluetoothGattCharacteristic>(
676 "getCharacteristic");
677 if (!jniChar.isValid())
681 jniChar.callMethod<QtJniTypes::BluetoothGattService>(
"getService");
682 if (!jniService.isValid())
685 QJniObject jniUuid = jniService.callMethod<QtJniTypes::UUID>(
"getUuid");
694 jniUuid = jniChar.callMethod<QtJniTypes::UUID>(
"getUuid");
696 if (characteristicUuid.isNull())
699 jniUuid = jniDesc.callMethod<QtJniTypes::UUID>(
"getUuid");
701 if (descriptorUuid.isNull())
708 const auto handleList = servicePrivate->characteristicList.keys();
709 for (
const auto charHandle: handleList) {
710 const auto &charData = servicePrivate->characteristicList.value(charHandle);
711 if (charData.uuid != characteristicUuid)
714 const auto &descHandleList = charData.descriptorList.keys();
715 for (
const auto descHandle: descHandleList) {
716 const auto &descData = charData.descriptorList.value(descHandle);
717 if (descData.uuid != descriptorUuid)
720 qCDebug(QT_BT_ANDROID) <<
"serverDescriptorChanged: Matching descriptor"
721 << descriptorUuid <<
"in char" << characteristicUuid
722 <<
"of service" << serviceUuid;
724 servicePrivate->characteristicList[charHandle].descriptorList[descHandle].value = newValue;
726 emit servicePrivate->descriptorWritten(
734void QLowEnergyControllerPrivateAndroid::characteristicChanged(
742 qCDebug(QT_BT_ANDROID) <<
"Characteristic change notification" <<
service->uuid
743 << charHandle <<
data.toHex() <<
"length:" <<
data.size();
746 if (!characteristic.
isValid()) {
747 qCWarning(QT_BT_ANDROID) <<
"characteristicChanged: Cannot find characteristic";
759void QLowEnergyControllerPrivateAndroid::serverCharacteristicChanged(
762 qCDebug(QT_BT_ANDROID) <<
"Server characteristic change notification"
763 << newValue.
toHex() <<
"length:" << newValue.
size();
766 QJniObject service = characteristic.callMethod<QtJniTypes::BluetoothGattService>(
782 jniUuid = characteristic.callMethod<QtJniTypes::UUID>(
"getUuid");
784 if (characteristicUuid.isNull())
788 const auto handleList = servicePrivate->characteristicList.keys();
790 for (
const auto handle: handleList) {
792 if (charData.
uuid != characteristicUuid)
795 qCDebug(QT_BT_ANDROID) <<
"serverCharacteristicChanged: Matching characteristic"
796 << characteristicUuid <<
" on " << serviceUuid;
797 charData.
value = newValue;
805 emit servicePrivate->characteristicChanged(
809void QLowEnergyControllerPrivateAndroid::serviceError(
825void QLowEnergyControllerPrivateAndroid::advertisementError(
int errorCode)
832 errorString = QLowEnergyController::tr(
"Advertisement data is larger than 31 bytes");
835 errorString = QLowEnergyController::tr(
"Advertisement feature not supported on the platform");
838 errorString = QLowEnergyController::tr(
"Error occurred trying to start advertising");
841 errorString = QLowEnergyController::tr(
"Failed due to too many advertisers");
844 errorString = QLowEnergyController::tr(
"Unknown advertisement error");
880 QJniObject parcelUuid = QJniObject::callStaticMethod<QtJniTypes::ParcelUuid>(
881 QtJniTypes::className<QtJniTypes::ParcelUuid>(),
"fromString",
882 javaString.object<jstring>());
889 QJniObject builder = QJniObject::construct<QtJniTypes::AdvertiseDataBuilder>();
892 builder = builder.callMethod<QtJniTypes::AdvertiseDataBuilder>(
893 "setIncludeDeviceName", !
data.localName().isEmpty());
894 builder = builder.callMethod<QtJniTypes::AdvertiseDataBuilder>(
895 "setIncludeTxPowerLevel",
data.includePowerLevel());
897 for (
const auto &service :
services) {
898 builder = builder.callMethod<QtJniTypes::AdvertiseDataBuilder>(
"addServiceUuid",
902 if (!
data.manufacturerData().isEmpty()) {
904 const qint32 nativeSize =
data.manufacturerData().size();
905 jbyteArray nativeData = env->NewByteArray(nativeSize);
906 env->SetByteArrayRegion(nativeData, 0, nativeSize,
907 reinterpret_cast<const jbyte*
>(
data.manufacturerData().constData()));
908 builder = builder.callMethod<QtJniTypes::AdvertiseDataBuilder>(
909 "addManufacturerData", jint(
data.manufacturerId()), nativeData);
910 env->DeleteLocalRef(nativeData);
912 if (!builder.isValid()) {
913 qCWarning(QT_BT_ANDROID) <<
"Cannot set manufacturer id/data";
936 QJniObject javaAdvertiseData = builder.callMethod<QtJniTypes::AdvertiseData>(
"build");
937 return javaAdvertiseData;
942 QJniObject builder = QJniObject::construct<QtJniTypes::AdvertiseSettingsBuilder>();
944 bool connectable =
false;
956 builder = builder.callMethod<QtJniTypes::AdvertiseSettingsBuilder>(
957 "setConnectable", connectable);
963 QJniObject javaAdvertiseSettings = builder.callMethod<QtJniTypes::AdvertiseSettings>(
"build");
964 return javaAdvertiseSettings;
975 qCWarning(QT_BT_ANDROID) <<
"startAdvertising() failed due to missing permissions";
982 qCWarning(QT_BT_ANDROID) <<
"Cannot initiate QtBluetoothLEServer";
993 const bool result = hub->
javaObject().callMethod<jboolean>(
"startAdvertising",
994 jAdvertiseData.object<QtJniTypes::AdvertiseData>(),
995 jScanResponse.object<QtJniTypes::AdvertiseData>(),
996 jAdvertiseSettings.object<QtJniTypes::AdvertiseSettings>());
1006 hub->
javaObject().callMethod<
void>(
"stopAdvertising");
1021 qCWarning(QT_BT_ANDROID) <<
"On Android, connection requests only work for central role";
1025 const bool result = hub->
javaObject().callMethod<jboolean>(
"requestConnectionUpdatePriority",
1026 params.minimumInterval());
1028 qCWarning(QT_BT_ANDROID) <<
"Cannot set connection update priority";
1041 permission |= QJniObject::getStaticField<jint>(
1042 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1048 permission |= QJniObject::getStaticField<jint>(
1049 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1050 "PERMISSION_READ_ENCRYPTED");
1054 permission |= QJniObject::getStaticField<jint>(
1055 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1056 "PERMISSION_READ_ENCRYPTED_MITM");
1065 permission |= QJniObject::getStaticField<jint>(
1066 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1067 "PERMISSION_WRITE");
1072 permission |= QJniObject::getStaticField<jint>(
1073 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1074 "PERMISSION_WRITE_ENCRYPTED");
1078 permission |= QJniObject::getStaticField<jint>(
1079 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1080 "PERMISSION_WRITE_ENCRYPTED_MITM");
1086 permission |= QJniObject::getStaticField<jint>(
1087 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1088 "PERMISSION_WRITE_SIGNED_MITM");
1090 permission |= QJniObject::getStaticField<jint>(
1091 QtJniTypes::className<QtJniTypes::BluetoothGattCharacteristic>(),
1092 "PERMISSION_WRITE_SIGNED");
1104 int permissions = 0;
1110 permissions |= QJniObject::getStaticField<jint>(
1111 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1117 permissions |= QJniObject::getStaticField<jint>(
1118 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1119 "PERMISSION_READ_ENCRYPTED");
1123 permissions |= QJniObject::getStaticField<jint>(
1124 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1125 "PERMISSION_READ_ENCRYPTED_MITM");
1133 permissions |= QJniObject::getStaticField<jint>(
1134 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1135 "PERMISSION_WRITE");
1140 permissions |= QJniObject::getStaticField<jint>(
1141 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1142 "PERMISSION_WRITE_ENCRYPTED");
1146 permissions |= QJniObject::getStaticField<jint>(
1147 QtJniTypes::className<QtJniTypes::BluetoothGattDescriptor>(),
1148 "PERMISSION_WRITE_ENCRYPTED_MITM");
1159 if (service.isNull())
1163 jint sType = QJniObject::getStaticField<jint>(
1164 QtJniTypes::className<QtJniTypes::BluetoothGattService>(),
1165 "SERVICE_TYPE_PRIMARY");
1167 sType = QJniObject::getStaticField<jint>(
1168 QtJniTypes::className<QtJniTypes::BluetoothGattService>(),
1169 "SERVICE_TYPE_SECONDARY");
1171 service->androidService = QJniObject::construct<QtJniTypes::BluetoothGattService>(
1176 for (
const auto includedServiceEntry: includedServices) {
1178 const jboolean
result = service->androidService.callMethod<jboolean>(
"addService",
1179 includedServiceEntry->d_ptr->androidService.object<QtJniTypes::BluetoothGattService>());
1181 qWarning(QT_BT_ANDROID) <<
"Cannot add included service " << includedServiceEntry->serviceUuid()
1182 <<
"to current service" << service->uuid;
1187 for (
const auto &charData: serviceCharsData) {
1193 if (charData.
value().
size() < charData.minimumValueLength() ||
1194 charData.
value().
size() > charData.maximumValueLength()) {
1195 qWarning() <<
"Warning: Ignoring characteristic" << charData.
uuid()
1196 <<
"with invalid length:" << charData.
value().
size()
1197 <<
"(minimum:" << charData.minimumValueLength()
1198 <<
"maximum:" << charData.maximumValueLength() <<
").";
1204 qCWarning(QT_BT_ANDROID) <<
"Warning: characteristic" << charData.
uuid() <<
"size"
1206 <<
", value size:" << charData.
value().
size();
1209 QJniObject javaChar = QJniObject::construct<QtJniTypes::QtBtGattCharacteristic>(
1213 charData.minimumValueLength(),
1214 charData.maximumValueLength());
1217 jbyteArray jb = env->NewByteArray(charData.
value().
size());
1218 env->SetByteArrayRegion(jb, 0, charData.
value().
size(), (jbyte*)charData.
value().
data());
1219 jboolean success = javaChar.callMethod<jboolean>(
"setLocalValue", jb);
1221 qCWarning(QT_BT_ANDROID) <<
"Cannot setup initial characteristic value for " << charData.
uuid();
1222 env->DeleteLocalRef(jb);
1225 for (
const auto &descData: descriptorList) {
1226 QJniObject javaDesc = QJniObject::construct<QtJniTypes::QtBtGattDescriptor>(
1230 jb = env->NewByteArray(descData.value().size());
1231 env->SetByteArrayRegion(jb, 0, descData.value().size(), (jbyte*)descData.value().data());
1232 success = javaDesc.callMethod<jboolean>(
"setLocalValue", jb);
1234 qCWarning(QT_BT_ANDROID) <<
"Cannot setup initial descriptor value for "
1235 << descData.uuid() <<
"(char" << charData.
uuid()
1236 <<
"on service " << service->uuid <<
")";
1239 env->DeleteLocalRef(jb);
1242 success = javaChar.callMethod<jboolean>(
"addDescriptor",
1243 javaDesc.object<QtJniTypes::BluetoothGattDescriptor>());
1245 qCWarning(QT_BT_ANDROID) <<
"Cannot add descriptor" << descData.uuid()
1246 <<
"to service" << service->uuid <<
"(char:"
1247 << charData.
uuid() <<
")";
1251 success = service->androidService.callMethod<jboolean>(
1252 "addCharacteristic",
1253 javaChar.object<QtJniTypes::BluetoothGattCharacteristic>());
1255 qCWarning(QT_BT_ANDROID) <<
"Cannot add characteristic" << charData.
uuid()
1256 <<
"to service" << service->uuid;
1260 hub->
javaObject().callMethod<
void>(
"addService",
1261 service->androidService.object<QtJniTypes::BluetoothGattService>());
1267 qCWarning(QT_BT_ANDROID) <<
"could not determine MTU, hub is does not exist";
1278 if (!hub || !hub->
javaObject().callMethod<jboolean>(
"readRemoteRssi")) {
1279 qCWarning(QT_BT_ANDROID) <<
"request to read RSSI failed";
QT_BEGIN_NAMESPACE bool ensureAndroidPermission(QBluetoothPermission::CommunicationModes modes)
std::vector< ObjCStrongReference< CBMutableService > > services
void serviceDetailsDiscoveryFinished(const QString &serviceUuid, int startHandle, int endHandle)
void characteristicRead(const QBluetoothUuid &serviceUuid, int handle, const QBluetoothUuid &charUuid, int properties, const QByteArray &data)
void servicesDiscovered(QLowEnergyController::Error errorCode, const QString &uuids)
void serverCharacteristicChanged(const QJniObject &characteristic, const QByteArray &newValue)
void serviceError(int attributeHandle, QLowEnergyService::ServiceError errorCode)
void serverDescriptorWritten(const QJniObject &descriptor, const QByteArray &newValue)
void characteristicChanged(int charHandle, const QByteArray &data)
void descriptorRead(const QBluetoothUuid &serviceUuid, const QBluetoothUuid &charUuid, int handle, const QBluetoothUuid &descUuid, const QByteArray &data)
void remoteRssiRead(int rssi, bool success)
void characteristicWritten(int charHandle, const QByteArray &data, QLowEnergyService::ServiceError errorCode)
void descriptorWritten(int descHandle, const QByteArray &data, QLowEnergyService::ServiceError errorCode)
void connectionUpdated(QLowEnergyController::ControllerState newState, QLowEnergyController::Error errorCode)
void advertisementError(int status)
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
The QLowEnergyAdvertisingData class represents the data to be broadcast during Bluetooth Low Energy a...
The QLowEnergyAdvertisingParameters class represents the parameters used for Bluetooth Low Energy adv...
The QLowEnergyCharacteristicData class is used to set up GATT service data. \inmodule QtBluetooth.
QBluetooth::AttAccessConstraints writeConstraints() const
Returns the constraints needed for a client to write the value of this characteristic.
QLowEnergyCharacteristic::PropertyTypes properties() const
Returns the properties of this characteristic.
QBluetooth::AttAccessConstraints readConstraints() const
Returns the constraints needed for a client to read the value of this characteristic.
QLowEnergyCharacteristic::PropertyTypes properties() const
Returns the properties of the characteristic.
PropertyType
This enum describes the properties of a characteristic.
bool isValid() const
Returns true if the QLowEnergyCharacteristic object is valid, otherwise returns false.
The QLowEnergyConnectionParameters class is used when requesting or reporting an update of the parame...
void writeDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle, const QByteArray &newValue) override
void connectToDevice() override
void discoverServices() override
~QLowEnergyControllerPrivateAndroid() override
void discoverServiceDetails(const QBluetoothUuid &service, QLowEnergyService::DiscoveryMode mode) override
QLowEnergyControllerPrivateAndroid()
void disconnectFromDevice() override
void readDescriptor(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QLowEnergyHandle descriptorHandle) override
void startAdvertising(const QLowEnergyAdvertisingParameters ¶ms, const QLowEnergyAdvertisingData &advertisingData, const QLowEnergyAdvertisingData &scanResponseData) override
void addToGenericAttributeList(const QLowEnergyServiceData &service, QLowEnergyHandle startHandle) override
void stopAdvertising() override
void readCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle) override
void requestConnectionUpdate(const QLowEnergyConnectionParameters ¶ms) override
void writeCharacteristic(const QSharedPointer< QLowEnergyServicePrivate > service, const QLowEnergyHandle charHandle, const QByteArray &newValue, QLowEnergyService::WriteMode mode) override
QLowEnergyCharacteristic characteristicForHandle(QLowEnergyHandle handle)
Returns a valid characteristic if the given handle is the handle of the characteristic itself or one ...
QSharedPointer< QLowEnergyServicePrivate > serviceForHandle(QLowEnergyHandle handle)
void invalidateServices()
quint16 updateValueOfDescriptor(QLowEnergyHandle charHandle, QLowEnergyHandle descriptorHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated descriptor value.
QLowEnergyDescriptor descriptorForHandle(QLowEnergyHandle handle)
Returns a valid descriptor if handle belongs to a descriptor; otherwise an invalid one.
ServiceDataMap localServices
ServiceDataMap serviceList
QLowEnergyController::Error error
void setError(QLowEnergyController::Error newError)
QLowEnergyController::Role role
quint16 updateValueOfCharacteristic(QLowEnergyHandle charHandle, const QByteArray &value, bool appendValue)
Returns the length of the updated characteristic value.
QLowEnergyController::ControllerState state
QBluetoothAddress remoteDevice
void setState(QLowEnergyController::ControllerState newState)
ControllerState
Indicates the state of the controller object.
Error
Indicates all possible error conditions found during the controller's existence.
@ UnknownRemoteDeviceError
@ MissingPermissionsError
The QLowEnergyDescriptorData class is used to create GATT service data. \inmodule QtBluetooth.
bool isReadable() const
Returns true if the value of this descriptor is readable and false otherwise.
QBluetooth::AttAccessConstraints readConstraints() const
Returns the constraints under which the value of this descriptor can be read.
bool isWritable() const
Returns true if the value of this descriptor is writable and false otherwise.
bool isValid() const
Returns true if the QLowEnergyDescriptor object is valid, otherwise returns false.
The QLowEnergyServiceData class is used to set up GATT service data. \inmodule QtBluetooth.
QList< QLowEnergyCharacteristicData > characteristics() const
Returns the list of characteristics.
QList< QLowEnergyService * > includedServices() const
Returns the list of included services.
ServiceType type() const
Returns the type of this service.
DiscoveryMode
This enum lists service discovery modes.
ServiceError
This enum describes all possible error conditions during the service's existence.
@ CharacteristicWriteError
@ CharacteristicReadError
@ RemoteServiceDiscovered
WriteMode
This enum describes the mode to be used when writing a characteristic value.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool isNull() const noexcept
Returns true if this object refers to \nullptr.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
QChar * data()
Returns a pointer to the data stored in the QString.
QString toString(StringFormat mode=WithBraces) const
bool isNull() const noexcept
Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false...
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
@ AttAuthorizationRequired
@ AttAuthenticationRequired
Combined button and popup list for selecting options.
Q_CORE_EXPORT QtJniTypes::Service service()
static const QCssKnownValue properties[NumProperties - 1]
#define qCCritical(category,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
static QJniObject javaParcelUuidfromQtUuid(const QBluetoothUuid &uuid)
static int setupCharPermissions(const QLowEnergyCharacteristicData &charData)
QT_BEGIN_NAMESPACE const int BTLE_MAX_ATTRIBUTE_VALUE_SIZE
static QJniObject createJavaAdvertiseSettings(const QLowEnergyAdvertisingParameters ¶ms)
static QJniObject createJavaAdvertiseData(const QLowEnergyAdvertisingData &data)
static QJniObject javaUuidfromQtUuid(const QBluetoothUuid &uuid)
static int setupDescPermissions(const QLowEnergyDescriptorData &descData)
void registerQLowEnergyControllerMetaType()
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const void * pointer
GLdouble GLdouble GLdouble GLdouble q
QT_BEGIN_NAMESPACE typedef uchar * output
char * toString(const MyType &t)
[31]
QHash< QLowEnergyHandle, DescData > descriptorList
QLowEnergyHandle valueHandle
QLowEnergyCharacteristic::PropertyTypes properties