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

Function bleUuidFromString

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

* @brief Parses a UUID string for GATT lookups. Accepts 16/32-bit shorthand ("FFF1", * "0xFFF1") by expanding it onto the Bluetooth base UUID, plus the full 128-bit * form with or without braces. QBluetoothUuid's own QString constructor rejects * the shorthand every script and doc example uses, so never call it directly. */

Source from the content-addressed store, hash-verified

366 * the shorthand every script and doc example uses, so never call it directly.
367 */
368static QBluetoothUuid bleUuidFromString(const QString& uuid)
369{
370 QString text = uuid.trimmed();
371 if (text.startsWith(QLatin1String("0x"), Qt::CaseInsensitive))
372 text.remove(0, 2);
373
374 if (text.size() == 4 || text.size() == 8) {
375 bool ok = false;
376 const quint32 hex = text.toUInt(&ok, 16);
377 if (ok) {
378 if (text.size() == 4)
379 return QBluetoothUuid(static_cast<quint16>(hex));
380
381 return QBluetoothUuid(hex);
382 }
383 }
384
385 return QBluetoothUuid(text);
386}
387
388/**
389 * @brief Resolves a friendly display name for a discovered BLE characteristic.

Callers 3

writeCharacteristicMethod · 0.85
selectServiceByUuidMethod · 0.85

Calls 2

removeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected