• 6101阅读
  • 4回复

Qt写的安卓程序能发现蓝牙,但是socket链接不上 [复制链接]

上一主题 下一主题
离线lindabell
 

只看楼主 倒序阅读 楼主  发表于: 2014-08-13
Qt写的安卓程序能发现蓝牙,但是socket链接不上
Qt写的安卓程序能发现蓝牙,但是socket链接不上。
没有成功的例子参考一下啊,因为没有两台安卓手机,examples的例子也无法实验。
现在是通过安卓手机链接pC蓝牙的,老师连接不上
离线lindabell

只看该作者 1楼 发表于: 2014-08-13
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 socket
D/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 0x5fa59000
D/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 Constructor
D/Qt      ( 5218): ..\BT\dialog.cpp:68 (void Dialog::addService(const QBluetoothServiceInfo&)): "Serial Port Profile" :Uuid= "{00001101-0000-1000-8000-00805f9b34fb}"
我的连接代码是:


  1. socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
  2.         connect(socket, SIGNAL(connected()), this, SLOT(connected()));
  3.         connect(socket,SIGNAL(error(QBluetoothSocket::SocketError)),this,SLOT(error(QBluetoothSocket::SocketError)));
  4.        // socket->connectToService(info);
  5.         socket->connectToService(romeaddress,QBluetoothUuid(serviceUuid));




离线lindabell

只看该作者 2楼 发表于: 2014-08-23
今天终于链接上并成功发送和接受数据了
原因是我用的红米的安卓版本是4.2的,改用小米3(安卓版本4.4)就ok了
离线圣域天子

只看该作者 3楼 发表于: 2014-08-24
离线xingfengshi

只看该作者 4楼 发表于: 2015-04-29
楼主能给QT下的蓝牙socket代码吗?最近在做这种东西,在mini2440开发板上,不会做啊,求救呢
快速回复
限100 字节
 
上一个 下一个