[Solved] QtMobility Bluetooth stringData is empty



  • 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?



  • 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);
    }@



  • 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)...



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

    Somebody got any direction?



  • 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.


Log in to reply
 

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