* @brief Static callback -- handles Bluetooth adapter power state changes. */
| 1331 | * @brief Static callback -- handles Bluetooth adapter power state changes. |
| 1332 | */ |
| 1333 | void IO::Drivers::BluetoothLE::onHostModeStateChanged(QBluetoothLocalDevice::HostMode state) |
| 1334 | { |
| 1335 | bool wasAvailable = s_adapterAvailable; |
| 1336 | s_adapterAvailable = (state != QBluetoothLocalDevice::HostPoweredOff); |
| 1337 | |
| 1338 | if (wasAvailable == s_adapterAvailable) |
| 1339 | return; |
| 1340 | |
| 1341 | for (auto* inst : std::as_const(s_instances)) |
| 1342 | Q_EMIT inst->adapterAvailabilityChanged(); |
| 1343 | |
| 1344 | if (!s_adapterAvailable) { |
| 1345 | if (s_discoveryAgent && s_discoveryAgent->isActive()) |
| 1346 | s_discoveryAgent->stop(); |
| 1347 | |
| 1348 | s_devices.clear(); |
| 1349 | s_deviceNames.clear(); |
| 1350 | for (auto* inst : std::as_const(s_instances)) { |
| 1351 | inst->close(); |
| 1352 | inst->m_deviceIndex = -1; |
| 1353 | Q_EMIT inst->devicesChanged(); |
| 1354 | } |
| 1355 | } |
| 1356 | } |
| 1357 | |
| 1358 | //-------------------------------------------------------------------------------------------------- |
| 1359 | // Stable device identification |