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

Method getDeviceList

app/src/API/Handlers/BluetoothLEHandler.cpp:407–427  ·  view source on GitHub ↗

* @brief Get list of discovered Bluetooth LE devices */

Source from the content-addressed store, hash-verified

405 * @brief Get list of discovered Bluetooth LE devices
406 */
407API::CommandResponse API::Handlers::BluetoothLEHandler::getDeviceList(const QString& id,
408 const QJsonObject& params)
409{
410 Q_UNUSED(params)
411
412 auto* ble = IO::ConnectionManager::instance().bluetoothLE();
413 const auto& deviceNames = ble->deviceNames();
414
415 QJsonArray devices;
416 for (int i = 0; i < deviceNames.count(); ++i) {
417 QJsonObject device;
418 device[QStringLiteral("index")] = i;
419 device[QStringLiteral("name")] = deviceNames.at(i);
420 devices.append(device);
421 }
422
423 QJsonObject result;
424 result[QStringLiteral("deviceList")] = devices;
425 result[QStringLiteral("currentDeviceIndex")] = ble->deviceIndex();
426 return CommandResponse::makeSuccess(id, result);
427}
428
429/**
430 * @brief Get list of services for the selected BLE device

Callers

nothing calls this directly

Calls 5

bluetoothLEMethod · 0.80
deviceNamesMethod · 0.80
countMethod · 0.45
appendMethod · 0.45
deviceIndexMethod · 0.45

Tested by

no test coverage detected