Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GATT server definition
Qt 6.11 is out! See what's new in the release blog

GATT server definition

Scheduled Pinned Locked Moved Unsolved General and Desktop
blebluetoothbluetooth low e
1 Posts 1 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved