* @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. */
| 366 | * the shorthand every script and doc example uses, so never call it directly. |
| 367 | */ |
| 368 | static 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. |
no test coverage detected