* @brief Start scanning for Bluetooth LE devices */
| 168 | * @brief Start scanning for Bluetooth LE devices |
| 169 | */ |
| 170 | API::CommandResponse API::Handlers::BluetoothLEHandler::startDiscovery(const QString& id, |
| 171 | const QJsonObject& params) |
| 172 | { |
| 173 | Q_UNUSED(params) |
| 174 | |
| 175 | auto* ble = IO::ConnectionManager::instance().bluetoothLE(); |
| 176 | |
| 177 | if (!ble->operatingSystemSupported()) { |
| 178 | return CommandResponse::makeError( |
| 179 | id, |
| 180 | ErrorCode::OperationFailed, |
| 181 | QStringLiteral("Bluetooth LE is not supported on this operating system")); |
| 182 | } |
| 183 | |
| 184 | if (!ble->adapterAvailable()) { |
| 185 | return CommandResponse::makeError( |
| 186 | id, ErrorCode::OperationFailed, QStringLiteral("No Bluetooth adapter available")); |
| 187 | } |
| 188 | |
| 189 | ble->startDiscovery(); |
| 190 | |
| 191 | QJsonObject result; |
| 192 | result[QStringLiteral("discoveryStarted")] = true; |
| 193 | return CommandResponse::makeSuccess(id, result); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * @brief Select BLE device by index |
nothing calls this directly
no test coverage detected