Merge lp:~kzapalowicz/ubuntu-system-settings/ubuntu-system-settings into lp:ubuntu-system-settings

Proposed by Konrad Zapałowicz on 2016-07-28
Status: Merged
Approved by: Ken VanDine on 2016-07-28
Approved revision: 1680
Merged at revision: 1687
Proposed branch: lp:~kzapalowicz/ubuntu-system-settings/ubuntu-system-settings
Merge into: lp:ubuntu-system-settings
Diff against target: 47 lines (+19/-0)
2 files modified
plugins/bluetooth/device.cpp (+18/-0)
plugins/bluetooth/device.h (+1/-0)
To merge this branch: bzr merge lp:~kzapalowicz/ubuntu-system-settings/ubuntu-system-settings
Reviewer Review Type Date Requested Status
Ken VanDine 2016-07-28 Approve on 2016-07-28
Review via email: mp+301370@code.launchpad.net

Commit Message

bluetooth: Add Apperance characteristic to type conversion

The Bluetooth LE devices use the GATT Apperance characteristic
instead of the CoD field to introduce themselves. So far the
Bluetooth plugin for u-s-s have not read it and as a result
the BLE devices were invisible on the found devices list. This
change allows them to be visible as right now the type of
device is also guessed based on the Apperance property.

Description of the Change

bluetooth: Add Apperance characteristic to type conversion

The Bluetooth LE devices use the GATT Apperance characteristic
instead of the CoD field to introduce themselves. So far the
Bluetooth plugin for u-s-s have not read it and as a result
the BLE devices were invisible on the found devices list. This
change allows them to be visible as right now the type of
device is also guessed based on the Apperance property.

To post a comment you must log in.
Ken VanDine (ken-vandine) wrote :

Looks good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/bluetooth/device.cpp'
2--- plugins/bluetooth/device.cpp 2016-03-11 07:15:54 +0000
3+++ plugins/bluetooth/device.cpp 2016-07-28 10:14:29 +0000
4@@ -373,6 +373,8 @@
5 updateConnection();
6 } else if (key == "Class") {
7 setType(getTypeFromClass(value.toUInt()));
8+ } else if (key == "Appearance") {
9+ setType(getTypeFromAppearance(value.toUInt()));
10 } else if (key == "Paired") {
11 setPaired(value.toBool());
12
13@@ -393,6 +395,22 @@
14 }
15 }
16
17+/* Determine the Type from the bits in the Appearance field.
18+ https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml */
19+Device::Type Device::getTypeFromAppearance(quint32 c)
20+{
21+ /* is it a HID class device? */
22+ if (c & 0x03C0) {
23+ switch (c & 0x000f) {
24+ case 0x1:
25+ return Type::Keyboard;
26+ case 0x02:
27+ return Type::Mouse;
28+ }
29+ }
30+ return Type::Other;
31+}
32+
33 /* Determine the Type from the bits in the Class of Device (CoD) field.
34 https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband */
35 Device::Type Device::getTypeFromClass (quint32 c)
36
37=== modified file 'plugins/bluetooth/device.h'
38--- plugins/bluetooth/device.h 2015-11-12 09:53:00 +0000
39+++ plugins/bluetooth/device.h 2016-07-28 10:14:29 +0000
40@@ -161,6 +161,7 @@
41 void updateProperties(QSharedPointer<QDBusInterface>);
42 void updateProperty(const QString &key, const QVariant &value);
43 static Type getTypeFromClass(quint32 bluetoothClass);
44+ static Type getTypeFromAppearance(quint32 bluetoothClass);
45 Device::Strength getStrengthFromRssi(int rssi);
46 void connectAfterPairing();
47 };

Subscribers

People subscribed via source and target branches