我在我的设备上从Qt测试了蓝牙文件传输示例,但它仅实现客户端,如何实现服务器端,以便我可以从 transferProgress和完成的信号中获取传入文件的状态。
也许我可以在服务器端使用QBluetoothTransferReply,以下是示例中的一段代码。
QBluetoothTransferManager mgr;
QBluetoothTransferRequest req(m_service.device().address());
m_file = new QFile(ui->fileName->text());
QBluetoothTransferReply *reply = mgr.put(req, m_file);
//mgr is default parent
//ensure that mgr doesn't take reply down when leaving scope
reply->setParent(this);
if (reply->error()){
qDebug() << "Failed to send file";
p->finished(reply);
reply->deleteLater();
return;
}
connect(reply, SIGNAL(transferProgress(qint64,qint64)), p, SLOT(uploadProgress(qint64,qint64)));
connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), p, SLOT(finished(QBluetoothTransferReply*)));
this is file transfer example i used。
并且我还在github上找到了一个传入的example,但这取决于我没有安装的dbus。