Results 1 to 8 of 8

Thread: Regarding Bluetooth Low energy Heart Listener example

  1. #1
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Regarding Bluetooth Low energy Heart Listener example

    I am a novice in QT programming and require some help to modify the heart listener BLE code (http://doc.qt.io/qt-5/qtbluetooth-he...r-example.html).
    Basically, my task is to connect to a specific BLE device (I would like to select the device at the back-end, unlike the way it is presented in the example). After establishing the connection, I want to do the exact same thing which is presented in the code, i.e. filter the heart rate service and capture the heart rate measurement characteristic.
    Could anyone please suggest if it is possible to have a UI to display only the plot of the data that is received through the heart rate characteristic and perform all the other operations, i.e. connecting to the device, filtering the required service and the specific characteristic from the device back-end.

    Also, I tried (and still trying) reading & understanding the code but it is very difficult to understand the part that is for display.

    Thank You.

    System Info: Ubuntu 14.01, Bluez 4.101

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    Hmm, I am not sure I understand what you are referring to as the "backend".

    As far as I can tell all BT operations are done in the non-UI parts of the application, which is what I assumed you mean with backend.

    Cheers,
    _

  3. #3
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    Thanks for the reply. I understood the code and made some modifications, however, now I am unable to understand that how can I plot the data in real-time. The heart rate listener example provided on the website plots the graph after the measurements are stored in a list. However, I would like to plot the data in real-time and I have used QWT previously for this purpose but I am not sure if I can use qml and qwt both. Could you provide some suggestion as to how can this be achieved. Thanks.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    I don't know whether QWT has QtQuick components as well, better ask in the QWT sub forum.
    My guess would be that it does, both QPainter and OpenGL are available in QtWidgets and QtQuick.

    Otherwise you could check using the Qt Chart module, http://doc.qt.io/qt-5/qml-qtcharts-chartview.html

    Cheers,
    _

  5. #5
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Smile Re: Regarding Bluetooth Low energy Heart Listener example

    I am going to use QtCustomPlot for the same, however, I had a small query (would apologise if this sounds simple and irrelevant to most of the users, however, I'm using Qt for the first time and have been struggling since quite a few days to figure out things)
    So below is the query: I tried executing below mentioned function (picked up from the heartrate.cpp file)
    void ADCReader::updateHeartRateValue(const QLowEnergyCharacteristic &c,
    const QByteArray &value)
    {
    // ignore any other characteristic change -> shouldn't really happen though
    if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasuremen t))
    return;
    const quint8 *data = reinterpret_cast<const quint8 *>(value.constData());
    quint8 flags = data[0];
    }


    And on passing the numbers from 90 to 110, got the output as mentioned below:
    value,16
    value,144
    value,145
    value,146
    value,147
    value,148
    value,149
    value,150
    value,151
    value,152
    value,153
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16
    value,16.

    I think it is little endian format, but I am not sure about the series of 16 displayed in the output. Would be really helpful if someone would be able to explain the reason for getting this type of output.

    EDIT: I got the output after inserting
    QString s = value.toHex();
    Last edited by user03; 21st August 2016 at 19:19.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    Not sure what you are asking.

    You get series of values and print the first byte.

    Also not sure why you mentioned little endian, a one byte int doesn't have any endianess differences, only multi-byte integers do.

    Cheers,
    _

  7. #7
    Join Date
    Aug 2016
    Posts
    14
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    Quote Originally Posted by anda_skoa View Post
    I don't know whether QWT has QtQuick components as well, better ask in the QWT sub forum.
    My guess would be that it does, both QPainter and OpenGL are available in QtWidgets and QtQuick.

    Otherwise you could check using the Qt Chart module, http://doc.qt.io/qt-5/qml-qtcharts-chartview.html

    Cheers,
    _
    I checked Qt Chart module and found an example to plot the data (oscilloscope example), however, when i tried running the code on Qt Creator (5.5.1), I got error that Qt Chart not found, could you pls let me know if I need to install this separately, if yes, then how can I install it from the Qt Creator (or do i need to do that from the terminal). Thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Regarding Bluetooth Low energy Heart Listener example

    As far as I know there is no QtCreator version 5.5.1 but it would not matter.
    Your Qt version, however, needs to be 5.6.0 or higher for the open source licensed Qt Chart, or, in case you are using a commerical license, I think downloaded separately.

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 17th May 2016, 12:33
  2. Bluetooth Low Energy
    By flemingp in forum Newbie
    Replies: 0
    Last Post: 4th May 2016, 22:01
  3. How to send and receive data with Eluetooth Low Energy?
    By tanthinh1510 in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2016, 04:10
  4. UDP Listener
    By ricarlc in forum Newbie
    Replies: 6
    Last Post: 13th January 2014, 21:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.