Change states for bluetooth server

pull/13/head
Simon Stürz 2020-11-17 15:44:03 +01:00
parent 06cc977442
commit 6cc5735000
1 changed files with 5 additions and 5 deletions

View File

@ -242,7 +242,7 @@ void BluetoothServer::setRunning(bool running)
{
if (m_running == running)
return;
qCDebug(dcNetworkManagerBluetoothServer()) << "Set running" << running;
m_running = running;
emit runningChanged(m_running);
}
@ -252,6 +252,7 @@ void BluetoothServer::setConnected(bool connected)
if (m_connected == connected)
return;
qCDebug(dcNetworkManagerBluetoothServer()) << "Set connected" << connected;
m_connected = connected;
emit connectedChanged(m_connected);
}
@ -301,6 +302,7 @@ void BluetoothServer::onDeviceConnected(const QBluetoothAddress &address)
void BluetoothServer::onDeviceDisconnected(const QBluetoothAddress &address)
{
qCDebug(dcNetworkManagerBluetoothServer()) << "Device disconnected" << address.toString();
setConnected(false);
}
void BluetoothServer::onError(QLowEnergyController::Error error)
@ -317,7 +319,6 @@ void BluetoothServer::onConnected()
void BluetoothServer::onDisconnected()
{
qCDebug(dcNetworkManagerBluetoothServer()) << "Client disconnected";
setConnected(false);
stop();
}
@ -326,7 +327,7 @@ void BluetoothServer::onControllerStateChanged(QLowEnergyController::ControllerS
switch (state) {
case QLowEnergyController::UnconnectedState:
qCDebug(dcNetworkManagerBluetoothServer()) << "Controller state disonnected.";
setConnected(false);
setRunning(false);
break;
case QLowEnergyController::ConnectingState:
qCDebug(dcNetworkManagerBluetoothServer()) << "Controller state connecting...";
@ -493,6 +494,5 @@ void BluetoothServer::stop()
m_localDevice = nullptr;
}
setConnected(false);
setRunning(false);
// Let the events set the state connected and running
}