Regarding the BLE heart listener sample code



  • Below is the part of the code of the heart listener example under bluetooth low energy application. My BLE peripheral module started sending values from 90 to 110 and the output that was displayed is also provided under the code

    void HeartRate::updateHeartRateValue(const QLowEnergyCharacteristic &c,
                                         const QByteArray &value)
    {
        // ignore any other characteristic change -> shouldn't really happen though
        if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement))
            return;
    
    
        const char *data = value.constData();
        quint8 flags = data[0];
        //qDebug()<<"value"<<data[0];
        printf("value,%d\n",data[0]);
    
    

    output: value,20
    value,-112
    value,-111
    value,-110
    value,-109
    value,-108
    value,-107
    value,-106
    value,-105
    value,-104
    value,-103
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    Now, I am unable to understand this format of output. Could someone explain why is the output in this format and what can I do in order to get the same numbers as I am sending from the BLE module.

    Thank You.



  • I used QString function to convert the value to hex as follows:
    QString s = value.toHex();

    And it worked.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Glad you found out and thanks for sharing.

    Since you have ti working now please mark the thread as solved using the "Topic Tools" button so that other forum uses may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.