I am trying to connect to local Bluetooth address:
void Widget::connect_to_local_Bluetooth( )
{
qDebug()<<"trying to connect"<<endl;
QBluetoothAddress address("00:1A:7D:DA:71:15");
qDebug()<<address.toString()<<endl;
if(socket.state() != QBluetoothSocket::UnconnectedState)
{
qDebug()<<"socket.state"<<endl;
if(address != socket.peerAddress())//???
{
qDebug()<<"socket.peeradress"<<endl;
socket.disconnectFromService();
socket.connectToService(address, QBluetoothUuid(QBluetoothUuid::SerialPort));
}
//else
// emit connected();
}
else{
qDebug()<<"else case"<<endl;
socket.connectToService(address, QBluetoothUuid(QBluetoothUuid::SerialPort));
}
}
When I compile and run this, it all is working, but when this SLOT is called program writes:
trying to connect
address
else
and then unexpectedly finishes. Why so? What should I correct here? Thank you!
P.S. When I compile and run it on my Android device it does not interrupt, but I have no idea, is he connected to my Desktop or not. local address of Desktop is 00:1A:7D:DA:71:15
here is message from debugger:
///////////////////////////////////////////////////// bluetooth is powered off
W/ResourceType(15962): No package identifier when getting name for resource number 0x00000005
I/View (15962): Touch down dispatch to org.qtproject.qt5.android.QtSurface{41e7a900 V.E..... ........ 0,0-1024,695 #5}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=175.8283, y[0]=70.87516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12082488, downTime=12082488, deviceId=3, source=0x1002 }
I/BufferQueue( 136): [SurfaceView](this:0xb8593b50,id:443,api:2,p:15962,c:136) [queue] fps:0.67, dur:3002.75, max:2887.19, min:115.55
I/BufferQueue( 136): [SurfaceView](this:0xb8593b50,id:443,api:2,p:15962,c:136) [release] fps:0.66, dur:3009.61, max:2887.47, min:122.15
W/ResourceType(15962): No package identifier when getting name for resource number 0x00000005
I/View (15962): Touch up dispatch to org.qtproject.qt5.android.QtSurface{41e7a900 V.E..... ........ 0,0-1024,695 #5}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=175.8283, y[0]=70.87516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12082557, downTime=12082488, deviceId=3, source=0x1002 }
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:59 (void Widget::try_connect_to_local_address()): trying to connect
D/libA_for_w8.so(15962):
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:61 (void Widget::try_connect_to_local_address()): "00:1A:7D:DA:71:15"
D/libA_for_w8.so(15962):
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:64 (void Widget::try_connect_to_local_address()): socket.state
D/libA_for_w8.so(15962):
D/BluetoothDevice(15962): mAddress: 00:1A:7D:DA:71:15
// /////////////////////////// bluetooth is on
W/ResourceType(15962): No package identifier when getting name for resource number 0x00000006
I/View (15962): Touch down dispatch to org.qtproject.qt5.android.QtSurface{41dce2d8 V.E..... ........ 0,0-1024,695 #6}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=178.82536, y[0]=70.87516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12161746, downTime=12161746, deviceId=3, source=0x1002 }
I/BufferQueue( 136): [SurfaceView](this:0xb85a3680,id:456,api:2,p:15962,c:136) new GraphicBuffer needed
D/GraphicBuffer(15962): create handle(0x6aa44f78) (w:1024, h:695, f:1)
I/BufferQueue( 136): [SurfaceView](this:0xb85a3680,id:456,api:2,p:15962,c:136) [queue] fps:0.40, dur:5054.98, max:4978.11, min:76.87
I/BufferQueue( 136): [SurfaceView](this:0xb85a3680,id:456,api:2,p:15962,c:136) [release] fps:0.20, dur:4970.67, max:4970.67, min:4970.67
W/ResourceType(15962): No package identifier when getting name for resource number 0x00000006
I/View (15962): Touch up dispatch to org.qtproject.qt5.android.QtSurface{41dce2d8 V.E..... ........ 0,0-1024,695 #6}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=178.82536, y[0]=70.87516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12161842, downTime=12161746, deviceId=3, source=0x1002 }
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:59 (void Widget::try_connect_to_local_address()): trying to connect
D/libA_for_w8.so(15962):
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:61 (void Widget::try_connect_to_local_address()): "00:1A:7D:DA:71:15"
D/libA_for_w8.so(15962):
D/libA_for_w8.so(15962): ..\A_for_w8\widget.cpp:64 (void Widget::try_connect_to_local_address()): socket.state
D/libA_for_w8.so(15962):
D/BluetoothDevice(15962): mAddress: 00:1A:7D:DA:71:15
///////////////////////////////////// bluetooth is on too
W/ResourceType(18110): No package identifier when getting name for resource number 0x00000004
I/View (18110): Touch down dispatch to org.qtproject.qt5.android.QtSurface{4202d638 V.E..... ........ 0,0-1024,695 #4}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=187.81659, y[0]=65.88166, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12572050, downTime=12572050, deviceId=3, source=0x1002 }
I/BufferQueue( 136): [SurfaceView](this:0xb85bf140,id:496,api:2,p:18110,c:136) new GraphicBuffer needed
D/GraphicBuffer(18110): create handle(0x6c277498) (w:1024, h:695, f:1)
I/BufferQueue( 136): [SurfaceView](this:0xb85bf140,id:496,api:2,p:18110,c:136) [queue] fps:0.39, dur:5184.50, max:5110.70, min:73.81
I/BufferQueue( 136): [SurfaceView](this:0xb85bf140,id:496,api:2,p:18110,c:136) [release] fps:0.20, dur:5127.71, max:5127.71, min:5127.71
W/ResourceType(18110): No package identifier when getting name for resource number 0x00000004
I/View (18110): Touch up dispatch to org.qtproject.qt5.android.QtSurface{4202d638 V.E..... ........ 0,0-1024,695 #4}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=187.81659, y[0]=65.88166, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12572146, downTime=12572050, deviceId=3, source=0x1002 }
D/libA_for_w8.so(18110): ..\A_for_w8\widget.cpp:59 (void Widget::try_connect_to_local_address()): trying to connect
D/libA_for_w8.so(18110):
D/libA_for_w8.so(18110): ..\A_for_w8\widget.cpp:61 (void Widget::try_connect_to_local_address()): "00:1A:7D:DA:71:15"
D/libA_for_w8.so(18110):
D/libA_for_w8.so(18110): ..\A_for_w8\widget.cpp:75 (void Widget::try_connect_to_local_address()): else
D/libA_for_w8.so(18110):
D/BluetoothAdapter(18110): 1105859416: getState(). Returning 12
D/BluetoothDevice(18110): mAddress: 00:1A:7D:DA:71:15
D/libA_for_w8.so(18110): ..\A_for_w8\widget.cpp:80 (void Widget::try_connect_to_local_address()):
D/libA_for_w8.so(18110):
D/dalvikvm(18110): threadid=13: interp stack at 0x6c857000
W/BluetoothAdapter(18110): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothSocket(18110): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[71]}
D/BluetoothDevice(18110): mAddress: 00:1A:7D:DA:71:15
W/System.err(18110): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
W/System.err(18110): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:505)
W/System.err(18110): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:516)
W/System.err(18110): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:320)
W/System.err(18110): at dalvik.system.NativeStart.run(Native Method)
W/libA_for_w8.so(18110): (null):0 ((null)): qt.bluetooth.android: Falling back to workaround.
W/libA_for_w8.so(18110): (null):0 ((null)): qt.bluetooth.android: Cannot determine RFCOMM service channel.
D/BluetoothDevice(18110): mAddress: 00:1A:7D:DA:71:15
W/libA_for_w8.so(18110): (null):0 ((null)): qt.bluetooth.android: Workaround thread invoked.
D/dalvikvm(18110): threadid=13: bye!
D/dalvikvm(18110): threadid=13: interp stack at 0x6c857000
W/BluetoothAdapter(18110): getBluetoothService() called with no BluetoothManagerCallback
D/BluetoothSocket(18110): connect(), SocketState: INIT, mPfd: {ParcelFileDescriptor: FileDescriptor[70]}
D/BluetoothDevice(18110): mAddress: 00:1A:7D:DA:71:15
To sum up: 1) Why it does not interrupt on Android, but does on Desktop ? 2) How can I understand, is there connection between two my devices ? 3) if doesn't what am I doing incorrectly?
User contributions licensed under CC BY-SA 3.0