[Interest] Bluetooth LE: HowTo inspect QBluetoothDeviceInfo::serviceUuids

Oliver Wolff Oliver.Wolff at qt.io
Wed Apr 19 09:45:02 CEST 2017



On 18/04/2017 11:12, ekke wrote:
> Am 18.04.17 um 10:26 schrieb Oliver Wolff:
>> On 13/04/2017 19:01, ekke wrote:
>>>
>>> from QBluetoothDeviceInfo::serviceUuids I'm getting a list of 
>>> Service UUIDs ( QBluetoothUuid) without connecting to the device and 
>>> inspecting the Services.
>>>
>>> there's per ex:
>>>
>>> {0000180d-0000-1000-8000-00805f9b34fb}
>>>
>>> and I know this means the device supports
>>>
>>>
>>> HeartRate
>>>
>>> 0x180d
>>>
>>>
>>> How can I inspect the QBluetoothUuid to get 0x180d
>>>
>>>
>>> I found some Java code like this:
>>>
>>>
>>> private static int getAssignedNumber(UUID uuid) {
>>>     // Keep only the significant bits of the UUID
>>>     return (int) ((uuid.getMostSignificantBits() & 
>>> 0x0000FFFF00000000L) >> 32);
>>> }
>>>
>>>
>>> but have no idea HowTo do the same from Qt
>>>
>>
>> Hi ekke,
>>
>> I am not sure I fully understand the problem. If you want to check 
>> the availability of a heart rate sensor, you can just compare the 
>> Uuids with QBluetoothUuid(QBluetoothUuid::HeartRate) can't you?
> Hi Oliver,
>
> as soon as I connect to the device and discovered Services I can 
> compare with QBluetoothUuid::HeartRate (0x180d)
>
> if I only discover the Devices without connecting, most devices 
> provide ServiceUUIDs
> http://doc.qt.io/qt-5/qbluetoothdeviceinfo.html#serviceUuids
> but here the UUID isn't 0x180d for HeartRateService, but 
> {0000180d-0000-1000-8000-00805f9b34fb}
>
> so looking at the ServiceUUIDs I don't have to nonnect to the device 
> to know that it supports HeartRate :)
>
> now I'm simply comparing found ServiceUUIDs with the full value
> {0000180d-0000-1000-8000-00805f9b34fb}
> to detect the Device as a HeartRate Device
You don't need to compare to the full value. Comparing to 
QBluetoothUuid::HeartRate also works (at least it does here). I think if 
that does not work it's a bug or I am still not understanding the 
problem at hand.
>
> googled and found that there's a (Java) way to get the most 
> significant Bits from ServiceUUID to compare with
> QBluetoothUuid::HeartRate (0x180d)
>
> would make the example app easier to understand
>
> I'm just finishing a new BT LE Example APP - will be published soon
>
> ekke
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170419/572c6e2b/attachment.html>


More information about the Interest mailing list