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