Qt写的安卓程序能发现蓝牙,但是socket链接不上。
有没有成功的例子参考一下啊,因为没有两台安卓手机,examples的例子也无法实验。
现在是通过安卓手机链接pC蓝牙的,老师连接不上
能找到pc端蓝牙的服务,其中也有串口服务;但是就是连接不了,提示
ServiceNotFoundError D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Headset AG" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:74 (void Dialog::addService(const QBluetoothServiceInfo&)): create socketD/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Hands-Free" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Hands-Free AG" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/dalvikvm( 5218): threadid=12: interp stack at 0x5fa59000D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Advanced Audio Distribution Source" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Advanced Audio Distribution Sink" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Audio/Video Remote Control Target" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Audio/Video Remote Control" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Serial Port Profile" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "File Transfer" :Uuid= "{00000000-0000-0000-0000-000000000000}"D/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Personal Area Networking (PANU)" :Uuid= "{00000000-0000-0000-0000-000000000000}"I/BluetoothSocket_MTK( 5218): [JSR82] Bluetooth Socket ConstructorD/Qt ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Serial Port Profile" :Uuid= "{00001101-0000-1000-8000-00805f9b34fb}"我的连接代码是:
- socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
- connect(socket, SIGNAL(connected()), this, SLOT(connected()));
- connect(socket,SIGNAL(error(QBluetoothSocket::SocketError)),this,SLOT(error(QBluetoothSocket::SocketError)));
- // socket->connectToService(info);
- socket->connectToService(romeaddress,QBluetoothUuid(serviceUuid));