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. [Solved] QtMobility Bluetooth stringData is empty
Forum Updated to NodeBB v4.3 + New Features

[Solved] QtMobility Bluetooth stringData is empty

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 1 Posters 3.0k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    DragoslaV
    wrote on last edited by
    #1

    Hey guys,

    I'm quiet new to developing with Qt and I love its simpleness :)

    For now I'm trying to make my phone (N9) communicate with my Arduino through bluetooth. I got my phone paired and I successfully connected to my device. However for some reason stringData is giving me an empty string. The event 'onDataAvailable' is triggered and the console is responding but with nothing.

    Connection started:
    @
    Connecting to: "00:07:MY:MAC:MASKED"
    Need a port/psm, doing discovery
    Starting discovery
    Got agent
    UUID filter ("{00001101-0000-1000-8000-00805f9b34fb}")
    (0) uint 65536
    (1) Sequence
    (1) uuid 1101
    (4) Sequence
    (4) Sequence
    (4) uuid 0100
    (4) Sequence
    (4) uuid 0003
    (4) int 1
    (5) Sequence
    (5) uuid 1002
    (6) Sequence
    (6) int 25966
    (6) int 106
    (6) int 256
    (256) string Bluetooth Serial Port
    FOUND SERVICE!
    Socket discovery finished
    Connection: true
    @

    Codes:
    @
    property string btAddress: "00:07:MY:MAC:MASKED"
    BluetoothSocket {
    id: blueSocket

        connected: true
        service: blueService
    
        onErrorChanged: {
            console.log("Error: " + blueSocket.error);
            blueSocket.connected = false;
        }
        onDataAvailable: {
            console.log(stringData);
        }
        onConnectedChanged: {
            console.log("Connection: " + connected);
        }
    }
    
    BluetoothService {
        id: blueService
    
        deviceAddress: btAddress
        serviceUuid: "00001101-0000-1000-8000-00805F9B34FB"
        serviceProtocol: "rfcomm"
    }
    
    Timer {
        interval: 1000; running: true; repeat: true
        onTriggered: {
            if (blueSocket.connected == true) {
               //do something
            } else {
                blueSocket.connected = true;
            }
        }
    }@
    

    Can anyone help me with this?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DragoslaV
      wrote on last edited by
      #2

      It seems I am able to send commands to my Arduino :D by using the follow (in combination with the codes above):
      @
      //this will activate a LED
      blueSocket.sendStringData("H");
      @
      But for now I am still unable to retrieve data;
      Do I retrieve this in the following function? with stringData? and what can I expect from stringData? (ASCII or BYTE?)
      @onDataAvailable: {
      console.log(stringData);
      }@

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DragoslaV
        wrote on last edited by
        #3

        After playing all day I'm still unable to retrieve any data, the events are triggered but I read nothing out stringData.... Could it be because my Arduino+Bluetooth runs on a 115200 baudrate and the RFCOMM runs on a 9600 baudrate??

        This is super frustrating since this is my last step to get things done (the rest of the application is working)...

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DragoslaV
          wrote on last edited by
          #4

          Arghhh after 3 days I'm still unable to retrieve any data in Qt...

          Somebody got any direction?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DragoslaV
            wrote on last edited by
            #5

            I got it solved.

            QtQuick's bluetooth is buggy.
            I made a C++ class and connected that with setContextRoot into my QtQuick application.
            I can send a println function in my arduino to get it readable in C++.


            I'm not a developer, so I cant report this bug.

            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