Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Regarding the BLE heart listener sample code

Regarding the BLE heart listener sample code

Scheduled Pinned Locked Moved Solved QML and Qt Quick
bluetooth low eqt5.5.1
3 Posts 2 Posters 1.2k Views
  • 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.
  • user_eduU Offline
    user_eduU Offline
    user_edu
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • user_eduU Offline
      user_eduU Offline
      user_edu
      wrote on last edited by
      #2

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

      And it worked.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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