1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtnetworkexample/quserbluetoothprotocol.cpp

25 lines
655 B
C++
Raw Normal View History

2017-10-24 11:07:24 +08:00
#include "quserbluetoothprotocol.h"
2018-04-22 13:03:28 +08:00
#include "qqtbluetoothclient.h"
2017-10-24 11:07:24 +08:00
#include "qqtbluetoothmanager.h"
2017-11-27 20:15:23 +08:00
QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( parent )
2017-10-24 11:07:24 +08:00
{
}
2018-04-22 13:03:28 +08:00
QQtBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent )
2017-10-24 11:07:24 +08:00
{
2018-04-22 13:03:28 +08:00
static QQtBluetoothClient* cli = nullptr;
2017-11-27 20:15:23 +08:00
if ( !cli )
2017-10-24 11:07:24 +08:00
{
2017-11-27 20:15:23 +08:00
QQtBluetoothManager* inst = QQtBluetoothManager::Instance ( parent );
2017-10-24 11:07:24 +08:00
inst->getDeviceList().first().address();
2018-04-22 13:03:28 +08:00
cli = new QQtBluetoothClient ( QBluetoothServiceInfo::RfcommProtocol, parent );
2017-11-27 20:15:23 +08:00
cli->setServiceAddress ( inst->getDeviceList().first().address() );
2017-10-24 11:07:24 +08:00
}
2017-11-27 20:15:23 +08:00
2017-10-24 11:07:24 +08:00
return cli;
}