Unsolved Qt Quick QML Bluetooth StringData Empty
-
Hi guys,
For now I'm trying to make my phone 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.
Did anyone managed to solve this problem?
-
Hi! Are you talking about BluetoothSocket QML Type? To which QML type does
onDataAvailable
belong to? -
@Wieland
Hi Wieland,
Thanks a lot for your reply.
Yes I am talking about BluetoothSocket QML Type.
onDataAvailable: { console.log(socket.stringData) }
or
onStringDataChanged: {
var dataset = socket.stringData;
console.log(dataset)
}both returning empty and both belongs to bluetoothSocket
-
@Wieland
This is my code
//----------- BLUETOOTH CONNECTIONS -----------------
BluetoothDiscoveryModel { id: btmodel running: true remoteAddress: '00:06:66:7D:8F:D9' onServiceDiscovered: { if (serviceFound) return serviceFound = true service.serviceProtocol = BluetoothService.RfcommProtocol console.log("Found new service, Device Address: "+service.deviceAddress + ", Protocol Name: " + service.serviceProtocol + ", Service Name: " + service.serviceName); socket.setService(service) } } BluetoothSocket { id: socket connected: true onSocketStateChanged: { if (BluetoothSocket.Connecting) console.log("Connecting..."); } onErrorChanged: { if (error == BluetoothSocket.NoError) return; if (error == BluetoothSocket.ServiceNotFoundError) console.log("Service Not Found"); } onConnectedChanged: { //console.log("SERVER Connected: " + connected); if(connected) { console.log("SERVER Connected: " + connected); image22.source="png/BOn.png" } else { console.log("SERVER not Connected: " + connected); image22.source="png/BOff.png" } } onDataAvailable: { // console.log(socket.stringData) } onStringDataChanged: { var dataset = socket.stringData; console.log("Data") } }
-
Also seeing the same issue. Were you able to solve so far @sebpeterkasi ?
-
@7bitbyte for anybody who has this problem: try sending 0x0A (LF) in your packet
for example: 0xA text
also I have problem with receiving numbers more than 7f(127) which is maximum in utf8