Merge ~jocave/plainbox-provider-checkbox:bluez-controller-detect into plainbox-provider-checkbox:master

Proposed by Jonathan Cave
Status: Merged
Approved by: Chris Wayne
Approved revision: b8d8c2a9418eb75fa4362c743881502e5b252fd5
Merged at revision: a9ca90808e0313bf2bb906ccd67a85116780b48b
Proposed branch: ~jocave/plainbox-provider-checkbox:bluez-controller-detect
Merge into: plainbox-provider-checkbox:master
Diff against target: 70 lines (+53/-0)
2 files modified
bin/bluez_list_adapters.py (+37/-0)
units/bluetooth/jobs.pxu (+16/-0)
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+361576@code.launchpad.net

Description of the change

Add a follow on detect job so that if rfkill identifies a bluetooth adapter a simple test is carried out to see if Bluez is able to detect it.

This should give a better picture of whether basic bluez setup is correct before attempting to connect with another device (e.g. by the eddystone test)

Tested on a Pi3 B+ in the lab running remote.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/bluez_list_adapters.py b/bin/bluez_list_adapters.py
2new file mode 100755
3index 0000000..87c68c2
4--- /dev/null
5+++ b/bin/bluez_list_adapters.py
6@@ -0,0 +1,37 @@
7+#!/usr/bin/env python3
8+#
9+# This file is part of Checkbox.
10+#
11+# Copyright 2018 Canonical Ltd.
12+#
13+# Authors:
14+# Jonathan Cave <jonathan.cave@canonical.com>
15+#
16+# Checkbox is free software: you can redistribute it and/or modify
17+# it under the terms of the GNU General Public License version 3,
18+# as published by the Free Software Foundation.
19+#
20+# Checkbox is distributed in the hope that it will be useful,
21+# but WITHOUT ANY WARRANTY; without even the implied warranty of
22+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+# GNU General Public License for more details.
24+#
25+# You should have received a copy of the GNU General Public License
26+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
27+
28+import checkbox_support.bt_helper as bt_helper
29+
30+import sys
31+
32+
33+def main():
34+ manager = bt_helper.BtManager()
35+ bt_adapter_not_found = True
36+ for dev in manager.get_bt_adapters():
37+ bt_adapter_not_found = False
38+ print(dev._if.object_path.split('/')[-1])
39+ return bt_adapter_not_found
40+
41+
42+if __name__ == "__main__":
43+ sys.exit(main())
44diff --git a/units/bluetooth/jobs.pxu b/units/bluetooth/jobs.pxu
45index 3b71e70..f40a6e0 100644
46--- a/units/bluetooth/jobs.pxu
47+++ b/units/bluetooth/jobs.pxu
48@@ -10,6 +10,22 @@ flags: preserve-locale
49 requires: manifest.has_bt_adapter
50 imports: from com.canonical.plainbox import manifest
51
52+id: bluetooth/bluez-controller-detect
53+category_id: com.canonical.plainbox::bluetooth
54+_summary: Check bluez lists a controller if rfkill detects one
55+plugin: shell
56+user: root
57+depends: bluetooth/detect
58+template-engine: jinja2
59+requires:
60+ package.name == 'bluez' or snap.name == 'bluez'
61+ {%- if __on_ubuntucore__ %}
62+ connections.slot == 'bluez:service' and connections.plug == '{{ __system_env__["SNAP_NAME"] }}:bluez'
63+ {% endif -%}
64+command:
65+ bluez_list_adapters.py
66+estimated_duration: 2s
67+flags: preserve-locale
68
69 plugin: shell
70 category_id: com.canonical.plainbox::bluetooth

Subscribers

People subscribed via source and target branches