Details
-
Suggestion
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.13.1
-
None
Description
It seems that the serviceData does not accept except 1 characteristic in one service.
I tried the following code
QLowEnergyAdvertisingData leAdd;
leAdd.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
leAdd.setLocalName("SensorServer");
leAdd.setIncludePowerLevel(true);
QList<QBluetoothUuid> servicesList;
servicesList.append(QBluetoothUuid::EnvironmentalSensing);
leAdd.setServices(servicesList);
QLowEnergyCharacteristicData chData, ipData;
chData.setUuid(QBluetoothUuid::TemperatureMeasurement);
chData.setValue(QByteArray(21,0)); //reset all the characteristic field
chData.setValueLength(2,21); //length of the characteristic from 2 to 21 bytes - maximum character length of a characteristics
chData.setProperties(QLowEnergyCharacteristic::WriteNoResponse | QLowEnergyCharacteristic::Write);
const QLowEnergyDescriptorData descriptorData(QBluetoothUuid::ClientCharacteristicConfiguration, QByteArray(2, 0));
chData.addDescriptor(descriptorData);
ipData.setUuid(QBluetoothUuid::GlucoseMeasurement);
ipData.setValue(QByteArray(21,0)); //reset all the characteristic field
ipData.setValueLength(2,21); //length of the characteristic from 2 to 21 bytes - maximum character length of a characteristics
ipData.setProperties(QLowEnergyCharacteristic::Read);
const QLowEnergyDescriptorData ipdescriptorData(QBluetoothUuid::ClientCharacteristicConfiguration, QByteArray(2, 0));
ipData.addDescriptor(ipdescriptorData);
QLowEnergyServiceData serviceData;
serviceData.setUuid(QBluetoothUuid::Temperature);
serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary);
serviceData.addCharacteristic(chData);
serviceData.setUuid(QBluetoothUuid::GlucoseMeasurement);
serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary);
serviceData.addCharacteristic(ipData);
controller = QLowEnergyController::createPeripheral();
but the first characteristic chData is added while the second ipData is not.