Skip to content
Snippets Groups Projects
Commit 95d990ed authored by Sjoerd Simons's avatar Sjoerd Simons
Browse files

simple-agent: Enable bluetooth technology.


We can't to anything with bluetooth until its enabled via connman
(otherwise everything else will blocked/soft rfkilled).

Enable it explicitely in the agent so the user doesn't have to first use
connmanctl.

Reviewed-by: default avatarPhilip Withnall <philip.withnall@collabora.co.uk>
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D2209
parent c11d1c36
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,29 @@ if __name__ == '__main__':
mainloop.quit()
bus = dbus.SystemBus()
connman_bt_tech = dbus.Interface(
bus.get_object("net.connman", "/net/connman/technology/bluetooth"),
"net.connman.Technology")
def property_changed(name, value):
if name == "Powered" and value:
print("Bluetooth powered on")
mainloop.quit()
# Enable the connman bluetooth technology so that connman removes its
# rfkill on the bluetooth adaptors
match = connman_bt_tech.connect_to_signal("PropertyChanged",
property_changed)
try:
connman_bt_tech.SetProperty("Powered", True)
mainloop.run()
except dbus.DBusException as e:
if e.get_dbus_name() != "net.connman.Error.AlreadyEnabled":
raise(e)
finally:
match.remove()
manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.freedesktop.DBus.ObjectManager")
agent_manager_iface = dbus.Interface(bus.get_object('org.bluez',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment