Add socket state debug information for bluetooth server

This commit is contained in:
Simon Stürz 2018-07-06 09:01:53 +02:00 committed by Michael Zanetti
parent ff66e366b4
commit 22466a9bf7
2 changed files with 10 additions and 3 deletions

View File

@ -106,7 +106,8 @@ void BluetoothServer::onClientConnected()
connect(client, SIGNAL(readyRead()), this, SLOT(readData())); connect(client, SIGNAL(readyRead()), this, SLOT(readData()));
connect(client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected())); connect(client, SIGNAL(disconnected()), this, SLOT(onClientDisconnected()));
connect(client, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(onError(QBluetoothSocket::SocketError))); connect(client, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(onClientStateChanged(QBluetoothSocket::SocketState)));
connect(client, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(onClientError(QBluetoothSocket::SocketError)));
emit clientConnected(clientId); emit clientConnected(clientId);
} }
@ -123,11 +124,16 @@ void BluetoothServer::onClientDisconnected()
emit clientDisconnected(clientId); emit clientDisconnected(clientId);
} }
void BluetoothServer::onError(QBluetoothSocket::SocketError error) void BluetoothServer::onClientError(QBluetoothSocket::SocketError error)
{ {
qCWarning(dcBluetoothServer()) << "BluetoothServer: Error occured:" << error; qCWarning(dcBluetoothServer()) << "BluetoothServer: Error occured:" << error;
} }
void BluetoothServer::onClientStateChanged(QBluetoothSocket::SocketState state)
{
qCDebug(dcBluetoothServer()) << "Client socket state changed:" << state;
}
void BluetoothServer::readData() void BluetoothServer::readData()
{ {
QBluetoothSocket *client = qobject_cast<QBluetoothSocket *>(sender()); QBluetoothSocket *client = qobject_cast<QBluetoothSocket *>(sender());

View File

@ -56,7 +56,8 @@ private slots:
void onClientConnected(); void onClientConnected();
void onClientDisconnected(); void onClientDisconnected();
void onError(QBluetoothSocket::SocketError error); void onClientError(QBluetoothSocket::SocketError error);
void onClientStateChanged(QBluetoothSocket::SocketState state);
void readData(); void readData();
public slots: public slots: