程序意外完成并与本地蓝牙地址

时间:2016-08-19 06:53:43

标签: qt bluetooth

我正在尝试连接到本地蓝牙地址:

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

当我编译并运行它时,一切正常,但是当这个SLOT被调用时程序写道:

尝试连接

地址

否则

然后意外地完成。 为什么这样?我应该在这里纠正什么? 谢谢!

P.S。 当我在我的Android设备上编译并运行它时,它不会中断,但我不知道,他是否连接到我的桌面。桌面的本地地址是00:1A:7D:DA:71:15

这是来自调试器的消息:

///////////////////////////////////////////////////// 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

总结: 1)为什么它不会在Android上中断,但在桌面上会中断? 2)我怎么理解,我的两台设备之间是否有连接? 3)如果我不正确地做什么?

0 个答案:

没有答案