GATT server definition
Unsolved
General and Desktop
-
Starting from official Qt5 examples I wrote a very short piece of code which defines a GATT server characteristic:
QLowEnergyCharacteristicData chrCommand; chrCommand.setUuid(UUID_CHR_COMMAND); chrCommand.setValue(QByteArray(2, 0)); chrCommand.setProperties(QLowEnergyCharacteristic::Write); const QLowEnergyDescriptorData clientConfigCommand(QBluetoothUuid::ClientCharacteristicConfiguration, QByteArray(2, 0)); chrCommand.addDescriptor(clientConfigCommand);
Then I set up the server itself:
advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral); advertisingData.setIncludePowerLevel(false); advertisingData.setLocalName("test"); advertisingData.setServices(QList<QBluetoothUuid>() << UUID_ADV_MIRROR); QLowEnergyServiceData srvService; srvService.setType(QLowEnergyServiceData::ServiceTypePrimary); srvService.setUuid(UUID_SRV_SERVICE); srvService.addCharacteristic(chrCommand); leController = QLowEnergyController::createPeripheral(); service = leController->addService(srvService); leController->startAdvertising(QLowEnergyAdvertisingParameters(), advertisingData, advertisingData);
Where all UUIDs constants are just my own random UUIDs.
It works and I can discover, bond, and write the 2-bytes to my characteristic.I'm reading though both the Qt5 and BLE documentations but I've still some questions I cannot answer by myself:
-
how to define a characteristic with longer payload? Say a 16-byte long "string" array?
-
what is the maximum length of a single characteristic?
-
what is the maximum length of all characteristics?
-
the localName should be summed in the previous size?
-