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. Bluetooth Low Energy: Reading Sensor data in real time after retrieving characteristics

Bluetooth Low Energy: Reading Sensor data in real time after retrieving characteristics

Scheduled Pinned Locked Moved Solved General and Desktop
bluetooth low ebluetooth
3 Posts 2 Posters 1.0k 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.
  • T Offline
    T Offline
    TUStudi
    wrote on 20 Feb 2020, 19:24 last edited by
    #1

    Hello everyone,

    I am developing a desktop application for reading and plotting sensor datan from an Adafruit Feather M0 Bluefruit LE developing board. This board does have a UART Service with 2 characteristics: the TX (0x0002) is used to send data back to the sensor node and the RX (0x0003) is used to send data out to the connected Central device (my Laptop).

    So after connecting and creating serviceobject for the UART Service, I am able to retrieve the characteristics with

     QList<QLowEnergyCharacteristic> chars = service->characteristics();
    

    and when calling the UUIDS for the chars the UUIDS for the above mentioned characteristics TX and RX are shown, that's fine.
    So How can I now get the Value of the Characteristic RX (for reading the data) and how can I update this call, so that the data are send in realtime?
    When I call for both characters

    qDebug () << char.value();
    

    the output for both is

    ""
    ""
    

    So empty, but the value for the RX characteristic should be a sensor value..

    Thanks for the help!

    A 1 Reply Last reply 20 Feb 2020, 19:33
    0
    • T TUStudi
      20 Feb 2020, 19:24

      Hello everyone,

      I am developing a desktop application for reading and plotting sensor datan from an Adafruit Feather M0 Bluefruit LE developing board. This board does have a UART Service with 2 characteristics: the TX (0x0002) is used to send data back to the sensor node and the RX (0x0003) is used to send data out to the connected Central device (my Laptop).

      So after connecting and creating serviceobject for the UART Service, I am able to retrieve the characteristics with

       QList<QLowEnergyCharacteristic> chars = service->characteristics();
      

      and when calling the UUIDS for the chars the UUIDS for the above mentioned characteristics TX and RX are shown, that's fine.
      So How can I now get the Value of the Characteristic RX (for reading the data) and how can I update this call, so that the data are send in realtime?
      When I call for both characters

      qDebug () << char.value();
      

      the output for both is

      ""
      ""
      

      So empty, but the value for the RX characteristic should be a sensor value..

      Thanks for the help!

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 20 Feb 2020, 19:33 last edited by aha_1980
      #2

      @TUStudi said in Bluetooth Low Energy: Reading Sensor data in real time after retrieving characteristics:

      So How can I now get the Value of the Characteristic RX

      It seems (I have not used Qt Bluetooth), the characteristicChanged() signal is responsible for that.

      Regard

      Qt has to stay free or it will die.

      T 1 Reply Last reply 21 Feb 2020, 10:56
      2
      • A aha_1980
        20 Feb 2020, 19:33

        @TUStudi said in Bluetooth Low Energy: Reading Sensor data in real time after retrieving characteristics:

        So How can I now get the Value of the Characteristic RX

        It seems (I have not used Qt Bluetooth), the characteristicChanged() signal is responsible for that.

        Regard

        T Offline
        T Offline
        TUStudi
        wrote on 21 Feb 2020, 10:56 last edited by
        #3

        Thank you for your reply. I found this in the documentation:

        In some cases the peripheral generates value updates which the central is interested in receiving. In order for a characteristic to support such notifications it must have the QLowEnergyCharacteristic::Notify or QLowEnergyCharacteristic::Indicate property and a descriptor of type QBluetoothUuid::ClientCharacteristicConfiguration. Provided those conditions are fulfilled notifications can be enabled as shown in the following code segment:

            QLowEnergyCharacteristic batteryLevel = service->characteristic(
                        QBluetoothUuid::BatteryLevel);
            if (!batteryLevel.isValid())
                return;
        
            QLowEnergyDescriptor notification = batteryLevel.descriptor(
                        QBluetoothUuid::ClientCharacteristicConfiguration);
            if (!notification.isValid())
                return;
        
            // establish hook into notifications
            connect(service, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)),
                    this, SLOT(characteristicChanged(QLowEnergyCharacteristic,QByteArray)));
        
            // enable notification
            service->writeDescriptor(notification, QByteArray::fromHex("0100"));
        

        So you were right. But what I do not understand: The writeDescriptor function "Writes newValue as value for descriptor." But what "value" is the QByteArray::fromHex("0100") ? Because when i write the same code for my application and when I call value() on the ClientCharacteristicConfiguration Descriptor from my RX characteristic the output is \x00\x00

        1 Reply Last reply
        0

        1/3

        20 Feb 2020, 19:24

        • Login

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