我有一个代码来监听蓝牙连接
rfcommServer = new QBluetoothServer(QBluetoothServiceInfo::RfcommProtocol, this);
connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
bool result = rfcommServer->listen(localAdapter);
如何编写客户端这样的代码,以便调用clientConnected插槽? 我找到了这段代码
QBluetoothSocket * socket;
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
qDebug() << "Create socket";
socket->connectToService(remoteService);
qDebug() << "ConnectToService done";
其中remoteService声明为QBluetoothServiceInfo &remoteService;
但是如何初始化remoteService?
我可以在客户端和服务器端使用rfcommServer->listen(localAdapter);
,因为,我想将两面都用作服务器,即双方都可以接受传入连接。