mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-25 04:32:10 +00:00
Format BluetoothDevices.cpp
This commit is contained in:
parent
180e472551
commit
2a66f1d64c
1 changed files with 25 additions and 23 deletions
|
@ -37,7 +37,7 @@ namespace BluetoothDevices
|
||||||
{
|
{
|
||||||
DeviceState& state = device.state;
|
DeviceState& state = device.state;
|
||||||
|
|
||||||
// Clear failed bit
|
// Clear failed bit
|
||||||
state &= ~DeviceState::Failed;
|
state &= ~DeviceState::Failed;
|
||||||
button.RemoveClass("failed");
|
button.RemoveClass("failed");
|
||||||
|
|
||||||
|
@ -48,17 +48,18 @@ namespace BluetoothDevices
|
||||||
button.RemoveClass("inactive");
|
button.RemoveClass("inactive");
|
||||||
state |= DeviceState::RequestConnect;
|
state |= DeviceState::RequestConnect;
|
||||||
|
|
||||||
System::ConnectBTDevice(device.device, [&dev = device, &but = button](bool success, System::BluetoothDevice&)
|
System::ConnectBTDevice(device.device,
|
||||||
{
|
[&dev = device, &but = button](bool success, System::BluetoothDevice&)
|
||||||
deviceMutex.lock();
|
{
|
||||||
if (!success)
|
deviceMutex.lock();
|
||||||
{
|
if (!success)
|
||||||
dev.state &= ~DeviceState::RequestConnect;
|
{
|
||||||
dev.state |= DeviceState::Failed;
|
dev.state &= ~DeviceState::RequestConnect;
|
||||||
but.AddClass("failed");
|
dev.state |= DeviceState::Failed;
|
||||||
}
|
but.AddClass("failed");
|
||||||
deviceMutex.unlock();
|
}
|
||||||
});
|
deviceMutex.unlock();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (FLAG_CHECK(state, DeviceState::Connected) && !FLAG_CHECK(state, DeviceState::RequestDisconnect))
|
else if (FLAG_CHECK(state, DeviceState::Connected) && !FLAG_CHECK(state, DeviceState::RequestDisconnect))
|
||||||
{
|
{
|
||||||
|
@ -66,17 +67,18 @@ namespace BluetoothDevices
|
||||||
button.RemoveClass("active");
|
button.RemoveClass("active");
|
||||||
state |= DeviceState::RequestDisconnect;
|
state |= DeviceState::RequestDisconnect;
|
||||||
|
|
||||||
System::DisconnectBTDevice(device.device, [&dev = device, &but = button](bool success, System::BluetoothDevice&)
|
System::DisconnectBTDevice(device.device,
|
||||||
{
|
[&dev = device, &but = button](bool success, System::BluetoothDevice&)
|
||||||
deviceMutex.lock();
|
{
|
||||||
if (!success)
|
deviceMutex.lock();
|
||||||
{
|
if (!success)
|
||||||
dev.state &= ~DeviceState::RequestDisconnect;
|
{
|
||||||
dev.state |= DeviceState::Failed;
|
dev.state &= ~DeviceState::RequestDisconnect;
|
||||||
but.AddClass("failed");
|
dev.state |= DeviceState::Failed;
|
||||||
}
|
but.AddClass("failed");
|
||||||
deviceMutex.unlock();
|
}
|
||||||
});
|
deviceMutex.unlock();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue