@@ -272,7 +272,13 @@ void Connection::open()
272
272
m_BLERxTxMode = BLE_2S2C;
273
273
else
274
274
m_BLERxTxMode = m_currBTArgument.RxCharacteristicUUID == m_currBTArgument.TxCharacteristicUUID ? BLE_1S1C : BLE_1S2C;
275
+ if (m_BLEController != nullptr )
276
+ m_BLEController->deleteLater ();
277
+ #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
278
+ m_BLEController = new QLowEnergyController (m_currBTArgument.deviceAddress , m_currBTArgument.localAdapterAddress );
279
+ #else
275
280
m_BLEController = QLowEnergyController::createCentral (m_currBTArgument.deviceAddress , m_currBTArgument.localAdapterAddress );
281
+ #endif
276
282
connect (m_BLEController, &QLowEnergyController::connected, m_BLEController, &QLowEnergyController::discoverServices);
277
283
connect (m_BLEController, QOverload<QLowEnergyController::Error>::of (&QLowEnergyController::error), this , &Connection::onErrorOccurred);
278
284
connect (m_BLEController, &QLowEnergyController::serviceDiscovered, this , &Connection::BLEC_onServiceDiscovered);
@@ -459,7 +465,11 @@ void Connection::updateSignalSlot()
459
465
else if (m_type == TCP_Client)
460
466
{
461
467
m_lastReadyReadConn = connect (m_TCPSocket, &QIODevice::readyRead, this , &Connection::onReadyRead);
468
+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
469
+ m_lastOnErrorConn = connect (m_TCPSocket, QOverload<QAbstractSocket::SocketError>::of (&QAbstractSocket::error), this , &Connection::onErrorOccurred);
470
+ #else
462
471
m_lastOnErrorConn = connect (m_TCPSocket, &QAbstractSocket::errorOccurred, this , &Connection::onErrorOccurred);
472
+ #endif
463
473
m_lastOnConnectedConn = connect (m_TCPSocket, &QAbstractSocket::connected, this , &Connection::onConnected);
464
474
m_lastOnDisconnectedConn = connect (m_TCPSocket, &QAbstractSocket::disconnected, this , &Connection::onDisconnected);
465
475
}
@@ -472,7 +482,11 @@ void Connection::updateSignalSlot()
472
482
else if (m_type == UDP)
473
483
{
474
484
m_lastReadyReadConn = connect (m_UDPSocket, &QIODevice::readyRead, this , &Connection::onReadyRead);
485
+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
486
+ m_lastOnErrorConn = connect (m_UDPSocket, QOverload<QAbstractSocket::SocketError>::of (&QAbstractSocket::error), this , &Connection::onErrorOccurred);
487
+ #else
475
488
m_lastOnErrorConn = connect (m_UDPSocket, &QAbstractSocket::errorOccurred, this , &Connection::onErrorOccurred);
489
+ #endif
476
490
m_lastOnConnectedConn = connect (m_UDPSocket, &QAbstractSocket::connected, this , &Connection::onConnected);
477
491
m_lastOnDisconnectedConn = connect (m_UDPSocket, &QAbstractSocket::disconnected, this , &Connection::onDisconnected);
478
492
}
@@ -849,7 +863,11 @@ void Connection::Server_onClientConnected()
849
863
changeState (Connected);
850
864
connect (socket, &QTcpSocket::readyRead, this , &Connection::onReadyRead);
851
865
connect (socket, &QTcpSocket::disconnected, this , &Connection::Server_onClientDisconnected);
866
+ #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
867
+ connect (socket, QOverload<QAbstractSocket::SocketError>::of (&QAbstractSocket::error), this , &Connection::onErrorOccurred);
868
+ #else
852
869
connect (socket, &QAbstractSocket::errorOccurred, this , &Connection::onErrorOccurred);
870
+ #endif
853
871
m_TCPConnectedClients.append (socket);
854
872
m_TCPTxClients.append (socket);
855
873
emit TCP_clientConnected ();
0 commit comments