Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Bluetooth ibeacon update.



  • Hi, everyone! I'm trying to use Qt Bluetooth module to send advertisement packets (Apple ibeacon) in Linux. But i can not successful update ManufacturerData major and minor bytes on the fly. Basically i am trying this way bellow.

    #define SERVICE_UUID 0x1820
    #define APPLE_COMPANY 0x004C
    ...
     QTimer beaconTimer;
    QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
    QLowEnergyAdvertisingData advertisingData;
    QBluetoothUuid serviceRelayUuid((quint32)SERVICE_UUID);
    
    advertisingData.setDiscoverability(QLowEnergyAdvertisingData::DiscoverabilityGeneral);
    advertisingData.setManufacturerData(APPLE_COMPANY,QByteArray('\x02\x15\xc7\xC1\xA1\xBF\xBB\x00\x4C\xAD\x87\x04\x9F\x2D\x29\x17\xDE\xD2\x00\x00\x00\x00\xC8',23));
    
    QLowEnergyServiceData serviceData;
    serviceData.setType(QLowEnergyServiceData::ServiceTypePrimary);
    serviceData.setUuid(serviceRelayUuid);
    
    const QScopedPointer<QLowEnergyController> leController(QLowEnergyController::createPeripheral());
    
    QScopedPointer<QLowEnergyService> service(leController->addService(serviceData));
    QLowEnergyAdvertisingParameters advertisingParameters;
    advertisingParameters  = QLowEnergyAdvertisingParameters();
    advertisingParameters.setMode(QLowEnergyAdvertisingParameters::AdvNonConnInd);
    
    leController->startAdvertising(advertisingParameters, advertisingData, advertisingData);
    
    const auto ibeaconTimerHandler = [&service, &advertisingData, &leController]() {
     advertisingData.setManufacturerData(APPLE_COMPANY,QByteArray('\x02\x15\xc7\xC1\xA1\xBF\xBB\x00\x4C\xAD\x87\x04\x9F\x2D\x29\x17\xDE\xD2\x00\x00\x02\x00\xC8',23));
    };
        QObject::connect(&beaconTimer, &QTimer::timeout, ibeaconTimerHandler);
        beaconTimer.start(1000);
    

    I can achive it, using hcitool.

    
    sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 06 1A FF 4C 00 02 15 C7 C1 A1 BF BB 00 4C AD 87 04 9F 2D 29 17 DE D2 00 00 00 02 C8 00
    
    sudo hcitool -i hci0 cmd 0x08 0x000a 01
    ...
    sudo hcitool -i hci0 cmd 0x08 0x0008 1E 02 01 06 1A FF 4C 00 02 15 C7 C1 A1 BF BB 00 4C AD 87 04 9F 2D 29 17 DE D2 00 01 00 02 C8 00
    
    sudo hcitool -i hci0 cmd 0x08 0x000a 00
    

    What exactly am I supposed to have done wrong?

    Thanks in advance.


Log in to reply