diff options
Diffstat (limited to 'gatoperipheral.cpp')
-rw-r--r-- | gatoperipheral.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/gatoperipheral.cpp b/gatoperipheral.cpp index c4339ec..cc4d6db 100644 --- a/gatoperipheral.cpp +++ b/gatoperipheral.cpp @@ -430,21 +430,16 @@ void GatoPeripheralPrivate::parseEIRUUIDs(int size, bool complete, quint8 data[] { Q_UNUSED(complete); + if (size != 16/8 && size != 32/8 && size != 128/8) { + qWarning() << "Unhandled UUID size: " << size; + return; + } + for (int pos = 0; pos < len; pos += size) { - GatoUUID uuid; - switch (size) { - case 16/8: - uuid = GatoUUID(qFromLittleEndian<quint16>(&data[pos])); - break; - case 32/8: - uuid = GatoUUID(qFromLittleEndian<quint32>(&data[pos])); - break; - case 128/8: - uuid = GatoUUID(qFromLittleEndian<gatouint128>(&data[pos])); - break; - } + char *ptr = reinterpret_cast<char*>(&data[pos]); + QByteArray ba = QByteArray::fromRawData(ptr, size/8); - service_uuids.insert(uuid); + service_uuids.insert(bytearray_to_gatouuid(ba)); } } |