From a7161d92f965848049dbb2eaa80cce0aa178c0ed Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 6 Dec 2013 23:07:49 +0100 Subject: Improve MTU exchange --- gatouuid.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gatouuid.cpp') diff --git a/gatouuid.cpp b/gatouuid.cpp index a1a3866..f87831a 100644 --- a/gatouuid.cpp +++ b/gatouuid.cpp @@ -86,6 +86,20 @@ bool GatoUUID::isNull() const return d->uuid.type == bt_uuid_t::BT_UUID_UNSPEC; } +int GatoUUID::minimumSize() const +{ + switch (d->uuid.type) { + case bt_uuid_t::BT_UUID_UNSPEC: + return 0; + case bt_uuid_t::BT_UUID16: + return 2; + case bt_uuid_t::BT_UUID32: + return 4; + default: + return 16; + } +} + quint16 GatoUUID::toUInt16(bool *ok) const { if (d->uuid.type == bt_uuid_t::BT_UUID16) { @@ -143,6 +157,28 @@ bool operator!=(const GatoUUID &a, const GatoUUID &b) return bt_uuid_cmp(&a.d->uuid, &b.d->uuid) != 0; } +QDebug operator<<(QDebug debug, const GatoUUID &uuid) +{ + quint16 uuid16; + quint32 uuid32; + bool ok = false; + + uuid16 = uuid.toUInt16(&ok); + if (ok) { + debug.nospace() << "0x" << uuid16; + return debug.space(); + } + + uuid32 = uuid.toUInt32(&ok); + if (ok) { + debug.nospace() << "0x" << uuid32; + return debug.space(); + } + + debug.nospace() << "{" << uuid.toString().toLatin1().constData() << "}"; + return debug.space(); +} + QDataStream & operator<<(QDataStream &s, const gatouint128 &u) { if (static_cast(s.byteOrder()) == QSysInfo::ByteOrder) { -- cgit v1.2.3