MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / startDiscovery

Method startDiscovery

app/src/IO/Drivers/BluetoothLE.cpp:845–885  ·  view source on GitHub ↗

* @brief Starts the shared BLE device discovery process. */

Source from the content-addressed store, hash-verified

843 * @brief Starts the shared BLE device discovery process.
844 */
845void IO::Drivers::BluetoothLE::startDiscovery()
846{
847 if (!operatingSystemSupported())
848 return;
849
850 initializeSharedState();
851
852 if (!s_adapterAvailable)
853 return;
854
855 if (s_discoveryAgent && s_discoveryAgent->isActive())
856 return;
857
858 if (s_discoveryAgent) {
859 QObject::disconnect(s_discoveryAgent, nullptr, nullptr, nullptr);
860 s_discoveryAgent->deleteLater();
861 s_discoveryAgent = nullptr;
862 }
863
864 s_discoveryAgent = new QBluetoothDeviceDiscoveryAgent();
865 QObject::connect(s_discoveryAgent,
866 &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,
867 s_discoveryAgent,
868 [](const QBluetoothDeviceInfo& d) { onDeviceDiscovered(d); });
869
870#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
871 QObject::connect(
872 s_discoveryAgent,
873 static_cast<void (QBluetoothDeviceDiscoveryAgent::*)(QBluetoothDeviceDiscoveryAgent::Error)>(
874 &QBluetoothDeviceDiscoveryAgent::error),
875 s_discoveryAgent,
876 [](QBluetoothDeviceDiscoveryAgent::Error e) { onDiscoveryError(e); });
877#else
878 QObject::connect(s_discoveryAgent,
879 &QBluetoothDeviceDiscoveryAgent::errorOccurred,
880 s_discoveryAgent,
881 [](QBluetoothDeviceDiscoveryAgent::Error e) { onDiscoveryError(e); });
882#endif
883
884 s_discoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod);
885}
886
887/**
888 * @brief Changes the index of the device selected by the user.

Callers 2

driverForEditingMethod · 0.45
setBusTypeMethod · 0.45

Calls 2

isActiveMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected